index.js 4.0 KB

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