Browse Source

领取优惠券时调起订阅消息

sxx
whyneedname 2 years ago
parent
commit
58b4c07fce
  1. 41
      pages/user/coupon/GetCoupon/index.vue
  2. 55
      pages/user/coupon/UserCoupon/index.vue

41
pages/user/coupon/GetCoupon/index.vue

@ -158,23 +158,30 @@ export default {
}, },
getCoupon: function(id, index) { getCoupon: function(id, index) {
let that = this let that = this
let list = that.couponsList let list = that.couponsList,
getCouponReceive(id) tmplIds = ['lOOnpYASRMKy81gh5tNMR7OXSHMKw05x-aosYjvhK-E', 'lejbsmRtheMLXEGNx_UhVHuq5P6Yjwfokc183n9oMek'];
.then(function(res) { uni.requestSubscribeMessage({
list[index].isUse = true tmplIds,
uni.showToast({ fail(err) {
title: '领取成功', console.log("requestSubscribeMessage err", err)
icon: 'success', },
duration: 2000, complete() {
}) getCouponReceive(id).then(function(res) {
}) list[index].isUse = true
.catch(function(err) { uni.showToast({
uni.showToast({ title: '领取成功',
title: err.msg || err.response.data.msg || err.response.data.message, icon: 'success',
icon: 'none', duration: 2000,
duration: 2000, })
}) }).catch(function(err) {
}) uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: 'none',
duration: 2000,
})
})
}
})
}, },
getUseCoupons() { getUseCoupons() {
if (this.loading) return //false if (this.loading) return //false

55
pages/user/coupon/UserCoupon/index.vue

@ -150,23 +150,30 @@
}) })
return return
} }
let list = that.couponsList let list = that.couponsList,
getCouponReceive(id) tmplIds = ['lOOnpYASRMKy81gh5tNMR7OXSHMKw05x-aosYjvhK-E', 'lejbsmRtheMLXEGNx_UhVHuq5P6Yjwfokc183n9oMek'];
.then(function(res) { uni.requestSubscribeMessage({
list[index].isUse = true tmplIds,
uni.showToast({ fail(err) {
title: '领取成功', console.log("requestSubscribeMessage err", err)
icon: 'success', },
duration: 2000, complete() {
}) getCouponReceive(id).then(function(res) {
}) list[index].isUse = true
.catch(function(err) { uni.showToast({
uni.showToast({ title: '领取成功',
title: err.msg || err.response.data.msg || err.response.data.message, icon: 'success',
icon: 'none', duration: 2000,
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) { getUseCoupons: function(i) {
@ -191,14 +198,14 @@
}) })
}else if(i===0){ }else if(i===0){
getCanReceive(q).then(res => { getCanReceive(q).then(res => {
res.data.forEach(item=>{ res.data.forEach(item=>{
if(!item.isUse){ if(!item.isUse){
this.couponsList.push(item) this.couponsList.push(item)
} }
})
this.loading = false
this.page = this.page + 1
}) })
this.loading = false
this.page = this.page + 1
})
}else{ }else{
getUserFailure(type).then(res=>{ getUserFailure(type).then(res=>{
res.data.forEach(item=>{ res.data.forEach(item=>{

Loading…
Cancel
Save