index.js 2.9 KB

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