let config = require("../../../config/config.js"); let Http = require("../../../utils/HttpBasics"); // let Http = require("../../../utils/HttpBasics"); const app = getApp(); const imgurl = require("../../../utils/imgurl"); Component({ /** * 组件的属性列表 */ properties: {}, /** * 组件的初始数据 */ data: { list: [], cardlist:[],//消费卡列表 total:'' }, /** * 组件的方法列表 */ methods: { rushtobuy: function (e) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${ e.currentTarget.dataset.couponchannelid }&couponId=${e.currentTarget.dataset.couponid}` }) }, gotoRushList:function(){ wx.navigateTo({ url: '/pages/rushToBuy/index', }) }, gotoCardList:function(){ wx.navigateTo({ url: '/pages/discountCardList/discountCardList', }) }, gotodiscountCardList: function (e) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${e.currentTarget.dataset.quancode}&couponId=${e.currentTarget.dataset.couponid}&cardType=${e.currentTarget.dataset.type}` }); }, //获取限时抢购列表 getList(){ Http.get({ url: config.api.couponChannelList, data: { pageNum: 1, pageSize: 3, targetAd: 2 } }).then(res => { this.setData({ list: res.data.list, total: res.data.total, }); }) .catch(err => { console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, //获取消费卡列表 getcardList() { Http.get({ url: config.api.couponChannelList, data: { pageNum: 1, pageSize: 3, targetAd: 5 } }).then(res => { this.setData({ cardlist: res.data.list, total: res.data.total }); }) .catch(err => { console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) } }, ready() { app.couponChannelListCallback = token => { Http.setToken(token); this.getList(); this.getcardList(); }; if (app.globalData.token && app.globalData.token != null) { app.couponChannelListCallback(app.globalData.token); } } });