index.js 3.0 KB

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