index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. },
  61. swiperChange: function(e) {
  62. // console.log(e.detail.source)
  63. if (e.detail.source == 'autoplay' || e.detail.source == 'touch') {
  64. this.setData({
  65. currentSwiper: e.detail.current
  66. })
  67. }
  68. },
  69. //跳转超值券包
  70. goToCouponBag:function () {
  71. wx.navigateTo({
  72. url: "/pages/welfareMall/activityList/activityList",
  73. })
  74. },
  75. goToCoupon:function(e){
  76. var appId = e.currentTarget.dataset.appid;
  77. var path = e.currentTarget.dataset.path;
  78. if(appId && path){
  79. wx.navigateToMiniProgram({
  80. appId: appId,
  81. path: path,
  82. success(res) {
  83. // 打开成功
  84. }
  85. })
  86. }
  87. if(!appId && path){
  88. wx.navigateTo({
  89. url: path,
  90. })
  91. }
  92. },
  93. goCouponDetail:function(e){
  94. let activityId = e.currentTarget.dataset.id
  95. wx.navigateTo({
  96. url: '/pages/welfareMall/activityInfo/activityInfo?activityId='+ activityId,
  97. })
  98. },
  99. async getIndexList(){
  100. let res = await WelfareMall.getIndexList();
  101. this.setData({
  102. activityList:res.data.activityList,
  103. bannerList:res.data.bannerList,
  104. navigationList:res.data.navigationList,
  105. grayTheme:res.data.config.grayTheme
  106. })
  107. this.setThrem(res.data.config.grayTheme)
  108. },
  109. //设置滤镜
  110. setThrem(grayTheme){
  111. app.globalData.grayTheme = grayTheme;
  112. let index0 = "images/welfareMall/home-active.png"
  113. let index1 = "images/welfareMall/user-active.png"
  114. if(grayTheme){
  115. index0 = "images/welfareMall/home_black.png"
  116. index1 = "images/welfareMall/user_black.png"
  117. }
  118. wx.setTabBarItem({
  119. index: 0,
  120. selectedIconPath: index0
  121. })
  122. wx.setTabBarItem({
  123. index: 1,
  124. selectedIconPath: index1
  125. })
  126. },
  127. goToBanner(e){
  128. var appId = e.currentTarget.dataset.appid;
  129. var path = e.currentTarget.dataset.path;
  130. if(appId && path){
  131. wx.navigateToMiniProgram({
  132. appId: appId,
  133. path: path,
  134. success(res) {
  135. // 打开成功
  136. }
  137. })
  138. }
  139. if(!appId && path){
  140. wx.navigateTo({
  141. url: path,
  142. })
  143. }
  144. }
  145. })