123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- // 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,
- })
- }
- }
- })
|