diff --git a/components/hot/index.js b/components/hot/index.js index e9071c6..db7b134 100644 --- a/components/hot/index.js +++ b/components/hot/index.js @@ -30,22 +30,39 @@ Component({ * 组件的方法列表 */ methods: { - //获取砍价列表 - getList() { + //获取砍价拼团数据 + getList(val) { let that = this; - let param = { - targetAd: 6, + let param = '' + if(val=='1'){ + param={ + targetAd : 6, + couponId: this.data.couponId + } + }else{ + param = { + targetAd : 7, + couponId: this.data.couponId1 + } } Http.get({ url: config.api.change, data:param, }).then(res => { if(res.data){ - that.setData({ - kData:res.data, - couponId: res.data.couponId - }); + if(val=='1'){ + that.setData({ + kData: res.data, + couponId: res.data.couponId + }); + }else{ + that.setData({ + pData: res.data, + couponId1: res.data.couponId + }); + } } + }) .catch(err => { console.log(err) @@ -57,82 +74,14 @@ Component({ }); }) }, - //获取拼团列表 - getptList() { - let param1 = { - targetAd: 7, - } - Http.get({ - url: config.api.change, - data: param1, - }).then(res => { - if(res.data){ - this.setData({ - pData:res.data, - couponId1: res.data.couponId - }); - } - }) - .catch(err => { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) - }, // 换一换 getChange(){ - if(this.data.couponId){ - let that = this; - let param = { - targetAd: 6, - couponid:this.data.couponId - } - Http.get({ - url: config.api.change, - data:param, - }).then(res => { - that.setData({ - kData:res.data, - couponId: res.data.couponId - }); - }) - .catch(err => { - console.log(err) - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) + if (this.data.couponId){ + this.getList(1) } - if(this.data.couponId1){ - let param1 = { - targetAd: 7, - couponid1: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 - }); - }) + if (this.data.couponId1) { + this.getList(2) } - }, //跳转砍价详情 gotokjdetail: function (e) { @@ -160,11 +109,10 @@ Component({ }, }, ready() { - app.couponChannelListCallback = token => { + app.couponChannelListCallback = (token,val) => { Http.setToken(token); - this.getList(); - this.getptList(); - // this.getChange(); + this.getList('1'); + this.getList('2'); }; if (app.globalData.token && app.globalData.token != null) { app.couponChannelListCallback(app.globalData.token); diff --git a/pages/main/index.js b/pages/main/index.js index 3632f46..c485842 100644 --- a/pages/main/index.js +++ b/pages/main/index.js @@ -579,7 +579,6 @@ Page({ }; // 砍价下拉刷新 that.selectComponent("#hot").getList(); - that.selectComponent("#hot").getptList(); // that.selectComponent("#bargain").getList(); // that.selectComponent("#spellGroup").getList(); // that.selectComponent("#rushtobyCard").getList();