From 58b4c07fce0267d46eaaab7cb1acac447688fff2 Mon Sep 17 00:00:00 2001 From: whyneedname <542399163@qq.com> Date: Tue, 1 Nov 2022 17:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E5=8F=96=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E6=97=B6=E8=B0=83=E8=B5=B7=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/user/coupon/GetCoupon/index.vue | 41 +++++++++++-------- pages/user/coupon/UserCoupon/index.vue | 55 +++++++++++++++----------- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/pages/user/coupon/GetCoupon/index.vue b/pages/user/coupon/GetCoupon/index.vue index bd277d1..f7c3a2d 100644 --- a/pages/user/coupon/GetCoupon/index.vue +++ b/pages/user/coupon/GetCoupon/index.vue @@ -158,23 +158,30 @@ export default { }, getCoupon: function(id, index) { let that = this - let list = that.couponsList - getCouponReceive(id) - .then(function(res) { - list[index].isUse = true - uni.showToast({ - title: '领取成功', - icon: 'success', - duration: 2000, - }) - }) - .catch(function(err) { - uni.showToast({ - title: err.msg || err.response.data.msg || err.response.data.message, - icon: 'none', - duration: 2000, - }) - }) + let list = that.couponsList, + tmplIds = ['lOOnpYASRMKy81gh5tNMR7OXSHMKw05x-aosYjvhK-E', 'lejbsmRtheMLXEGNx_UhVHuq5P6Yjwfokc183n9oMek']; + uni.requestSubscribeMessage({ + tmplIds, + fail(err) { + console.log("requestSubscribeMessage err", err) + }, + complete() { + getCouponReceive(id).then(function(res) { + list[index].isUse = true + uni.showToast({ + title: '领取成功', + icon: 'success', + duration: 2000, + }) + }).catch(function(err) { + uni.showToast({ + title: err.msg || err.response.data.msg || err.response.data.message, + icon: 'none', + duration: 2000, + }) + }) + } + }) }, getUseCoupons() { if (this.loading) return //阻止下次请求(false可以进行请求); diff --git a/pages/user/coupon/UserCoupon/index.vue b/pages/user/coupon/UserCoupon/index.vue index 6de1f05..0e182d6 100644 --- a/pages/user/coupon/UserCoupon/index.vue +++ b/pages/user/coupon/UserCoupon/index.vue @@ -150,23 +150,30 @@ }) return } - let list = that.couponsList - getCouponReceive(id) - .then(function(res) { - list[index].isUse = true - uni.showToast({ - title: '领取成功', - icon: 'success', - duration: 2000, - }) - }) - .catch(function(err) { - uni.showToast({ - title: err.msg || err.response.data.msg || err.response.data.message, - icon: 'none', - duration: 2000, - }) - }) + let list = that.couponsList, + tmplIds = ['lOOnpYASRMKy81gh5tNMR7OXSHMKw05x-aosYjvhK-E', 'lejbsmRtheMLXEGNx_UhVHuq5P6Yjwfokc183n9oMek']; + uni.requestSubscribeMessage({ + tmplIds, + fail(err) { + console.log("requestSubscribeMessage err", err) + }, + complete() { + getCouponReceive(id).then(function(res) { + list[index].isUse = true + uni.showToast({ + title: '领取成功', + icon: 'success', + duration: 2000, + }) + }).catch(function(err) { + uni.showToast({ + title: err.msg || err.response.data.msg || err.response.data.message, + icon: 'none', + duration: 2000, + }) + }) + } + }) }, getUseCoupons: function(i) { @@ -191,14 +198,14 @@ }) }else if(i===0){ getCanReceive(q).then(res => { - res.data.forEach(item=>{ - if(!item.isUse){ - this.couponsList.push(item) - } + res.data.forEach(item=>{ + if(!item.isUse){ + this.couponsList.push(item) + } + }) + this.loading = false + this.page = this.page + 1 }) - this.loading = false - this.page = this.page + 1 - }) }else{ getUserFailure(type).then(res=>{ res.data.forEach(item=>{