// pages/index/sw/index.js let config = require("../../config/config.js"); let Http = require("../../utils/HttpBasics"); let app = getApp(); const imgurl = require("../../utils/imgurl"); const bgColor = require("../../utils/bgColor.js") Component({ /** * 组件的属性列表 */ properties: {}, /** * 组件的初始数据 */ data: { sql: bgColor.colorFirst.main.sql, txt: bgColor.colorFirst.main.txt, change: imgurl.change.url, None: imgurl.None.url, jianUrl: imgurl.jian.url, barginicon: imgurl.barginicon.url, wangmeimeibargin: imgurl.wangmeimeibargin.url, kData:[], pData:[], couponId:'', couponId1: '', }, /** * 组件的方法列表 */ methods: { //获取砍价列表 getList() { let that = this; let param ={ targetAd: 6, } Http.get({ url: config.api.change, data:param, }).then(res => { that.setData({ kData:res.data }); }) .catch(err => { console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, //获取拼团列表 getptList() { let param1 = { targetAd: 7, } Http.get({ url: config.api.change, data: param1, }).then(res => { this.setData({ pData:res.data, couponId: res.data.couponId }); console.log( this.data.couponId) }) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, // 换一换 getChange(){ let param1 = { targetAd: 7, couponId: this.data.couponId1 } Http.get({ url: config.api.change, data: param1, }).then(res => { this.setData({ pData: res.data, couponId1: res.data.couponId }); }) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) let param = { targetAd: 6, couponId: this.data.couponId } Http.get({ url: config.api.change, data: param, }).then(res => { this.setData({ kData: res.data, couponId: res.data.couponId }); }) .catch(err => { console.log(err) wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, //跳转砍价详情 gotokjdetail: function (e) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${ e.currentTarget.dataset.couponchannelid }&couponId=${ e.currentTarget.dataset.couponid }&targetAd=${ e.currentTarget.dataset.targetad }` }); }, //跳转拼团详情 gotoptdetail: function (e) { wx.navigateTo({ url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${ e.currentTarget.dataset.couponchannelid }&couponId=${ e.currentTarget.dataset.couponid }&targetAd=${ e.currentTarget.dataset.targetad }` }); }, }, ready() { app.couponChannelListCallback = token => { Http.setToken(token); this.getList(); this.getptList(); }; if (app.globalData.token && app.globalData.token != null) { app.couponChannelListCallback(app.globalData.token); } } });