index.js 3.2 KB

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