// pages/welfareMall/index/index.js import WelfareMall from '../../../api/welfareMall'; const util = require('../../../utils/util.js'); import {getColor} from '../../../utils/user' const app = getApp(); Page({ /** * 页面的初始数据 */ data: { activityList:[], bannerList:[], navigationList:[], adList:[], autoplay: true, interval: 5000, duration: 500, currentSwiper:0, // indicatorDots:true, grayTheme:false, config: {}, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getIndexList() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: "沪上阿姨福利GO", path: "/pages/welfareMall/index/index", imageUrl: this.data.bannerList[0]?.figure } }, swiperChange: function(e) { // console.log(e.detail.source) if (e.detail.source == 'autoplay' || e.detail.source == 'touch') { this.setData({ currentSwiper: e.detail.current }) } }, //跳转超值券包 goToCouponBag:function () { wx.navigateTo({ url: "/pages/welfareMall/activityList/activityList", }) }, goToCoupon:function(e){ var appId = e.currentTarget.dataset.appid; var path = e.currentTarget.dataset.path; if(appId && path){ wx.navigateToMiniProgram({ appId: appId, path: path, success(res) { // 打开成功 } }) } if(!appId && path){ wx.navigateTo({ url: path, }) } }, goCouponDetail:function(e){ let activityId = e.currentTarget.dataset.id wx.navigateTo({ url: '/pages/welfareMall/activityInfo/activityInfo?activityId='+ activityId, }) }, async getIndexList(){ let res = await WelfareMall.getIndexList(); this.setData({ activityList:res.data.activityList, bannerList:res.data.bannerList, navigationList:res.data.navigationList, adList:res.data.adList, grayTheme:res.data.config.grayTheme, // config:res.data.config }) let info = await getColor(); this.setData({ config:info.config }) this.setThrem(res.data.config.grayTheme) }, //设置滤镜 setThrem(grayTheme){ app.globalData.grayTheme = grayTheme; let index0 = "images/welfareMall/home-active.png" let index1 = "images/welfareMall/user-active.png" if(grayTheme){ index0 = "images/welfareMall/home_black.png" index1 = "images/welfareMall/user_black.png" } wx.setTabBarItem({ index: 0, selectedIconPath: index0 }) wx.setTabBarItem({ index: 1, selectedIconPath: index1 }) }, goToBanner(e){ var appId = e.currentTarget.dataset.appid; var path = e.currentTarget.dataset.path; if(appId && path){ wx.navigateToMiniProgram({ appId: appId, path: path, success(res) { // 打开成功 } }) } if(!appId && path){ wx.navigateTo({ url: path, }) } }, goToAd(e){ var appId = e.currentTarget.dataset.appid; var path = e.currentTarget.dataset.path; if(appId && path){ wx.navigateToMiniProgram({ appId: appId, path: path, success(res) { // 打开成功 } }) } if(!appId && path){ wx.navigateTo({ url: path, }) } } })