index.js 3.8 KB

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