index.js 3.4 KB

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