index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. // pages/welfareMall/index/index.js
  2. import WelfareMall from '../../../api/welfareMall';
  3. const util = require('../../../utils/util.js');
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. activityList:[],
  11. bannerList:[],
  12. navigationList:[],
  13. adList:[],
  14. autoplay: true,
  15. interval: 5000,
  16. duration: 500,
  17. currentSwiper:0,
  18. // indicatorDots:true,
  19. grayTheme:false,
  20. config: {},
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. },
  27. /**
  28. * 生命周期函数--监听页面初次渲染完成
  29. */
  30. onReady: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面显示
  34. */
  35. onShow: function () {
  36. this.getIndexList()
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload: function () {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh: function () {
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom: function () {
  57. },
  58. /**
  59. * 用户点击右上角分享
  60. */
  61. onShareAppMessage: function () {
  62. return {
  63. title: "沪上阿姨福利GO",
  64. path: "/pages/welfareMall/index/index",
  65. imageUrl: this.data.bannerList[0]?.figure
  66. }
  67. },
  68. swiperChange: function(e) {
  69. // console.log(e.detail.source)
  70. if (e.detail.source == 'autoplay' || e.detail.source == 'touch') {
  71. this.setData({
  72. currentSwiper: e.detail.current
  73. })
  74. }
  75. },
  76. //跳转超值券包
  77. goToCouponBag:function () {
  78. wx.navigateTo({
  79. url: "/pages/welfareMall/activityList/activityList",
  80. })
  81. },
  82. goToCoupon:function(e){
  83. var appId = e.currentTarget.dataset.appid;
  84. var path = e.currentTarget.dataset.path;
  85. if(appId && path){
  86. wx.navigateToMiniProgram({
  87. appId: appId,
  88. path: path,
  89. success(res) {
  90. // 打开成功
  91. }
  92. })
  93. }
  94. if(!appId && path){
  95. wx.navigateTo({
  96. url: path,
  97. })
  98. }
  99. },
  100. goCouponDetail:function(e){
  101. let activityId = e.currentTarget.dataset.id
  102. wx.navigateTo({
  103. url: '/pages/welfareMall/activityInfo/activityInfo?activityId='+ activityId,
  104. })
  105. },
  106. async getIndexList(){
  107. let res = await WelfareMall.getIndexList();
  108. this.setData({
  109. activityList:res.data.activityList,
  110. bannerList:res.data.bannerList,
  111. navigationList:res.data.navigationList,
  112. adList:res.data.adList,
  113. grayTheme:res.data.config.grayTheme,
  114. config:res.data.config
  115. })
  116. this.setThrem(res.data.config.grayTheme)
  117. },
  118. //设置滤镜
  119. setThrem(grayTheme){
  120. app.globalData.grayTheme = grayTheme;
  121. let index0 = "images/welfareMall/home-active.png"
  122. let index1 = "images/welfareMall/user-active.png"
  123. if(grayTheme){
  124. index0 = "images/welfareMall/home_black.png"
  125. index1 = "images/welfareMall/user_black.png"
  126. }
  127. wx.setTabBarItem({
  128. index: 0,
  129. selectedIconPath: index0
  130. })
  131. wx.setTabBarItem({
  132. index: 1,
  133. selectedIconPath: index1
  134. })
  135. },
  136. goToBanner(e){
  137. var appId = e.currentTarget.dataset.appid;
  138. var path = e.currentTarget.dataset.path;
  139. if(appId && path){
  140. wx.navigateToMiniProgram({
  141. appId: appId,
  142. path: path,
  143. success(res) {
  144. // 打开成功
  145. }
  146. })
  147. }
  148. if(!appId && path){
  149. wx.navigateTo({
  150. url: path,
  151. })
  152. }
  153. },
  154. goToAd(e){
  155. var appId = e.currentTarget.dataset.appid;
  156. var path = e.currentTarget.dataset.path;
  157. if(appId && path){
  158. wx.navigateToMiniProgram({
  159. appId: appId,
  160. path: path,
  161. success(res) {
  162. // 打开成功
  163. }
  164. })
  165. }
  166. if(!appId && path){
  167. wx.navigateTo({
  168. url: path,
  169. })
  170. }
  171. }
  172. })