|
|
|
@ -2,7 +2,11 @@
|
|
|
|
|
import {
|
|
|
|
|
httpUtil,
|
|
|
|
|
http,
|
|
|
|
|
login_check
|
|
|
|
|
} from '../../../../utils/util'
|
|
|
|
|
import {
|
|
|
|
|
host
|
|
|
|
|
} from '../../../../Gdata'
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -16,10 +20,11 @@ Page({
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
this.getcollect_list(options.activity_id)
|
|
|
|
|
if (login_check(1)) {
|
|
|
|
|
this.getcollect_list(options.activity_id)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getcollect_list(activity_id) {
|
|
|
|
|
console.log(activity_id);
|
|
|
|
|
http("/api/v1/bind-coupon-list", "post", {
|
|
|
|
|
activity_id
|
|
|
|
|
}).then(res => {
|
|
|
|
@ -29,19 +34,57 @@ Page({
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
collect_receive(e) {
|
|
|
|
|
http("/api/v1/bind-coupon", "post", {
|
|
|
|
|
activity_id: e.currentTarget.dataset.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '领取成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
mask: true
|
|
|
|
|
})
|
|
|
|
|
this.data.coupons_list[e.currentTarget.dataset.index].is_received = 1
|
|
|
|
|
this.setData({
|
|
|
|
|
coupons_list: this.data.coupons_list
|
|
|
|
|
})
|
|
|
|
|
let token = getApp().globalData.token
|
|
|
|
|
let uid = getApp().globalData.uid
|
|
|
|
|
wx.request({
|
|
|
|
|
url: host + '/api/v1/bind-coupon',
|
|
|
|
|
method: 'post',
|
|
|
|
|
data: { activity_id: e.currentTarget.dataset.id },
|
|
|
|
|
header: {
|
|
|
|
|
token: token,
|
|
|
|
|
uid: uid
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
console.log(res, 'res');
|
|
|
|
|
if (res.data.status == 200) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '领取成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1000,
|
|
|
|
|
mask: true
|
|
|
|
|
})
|
|
|
|
|
this.data.coupons_list[e.currentTarget.dataset.index].is_received = 1
|
|
|
|
|
this.setData({
|
|
|
|
|
coupons_list: this.data.coupons_list
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '已抢光',
|
|
|
|
|
icon: 'error',
|
|
|
|
|
duration: 1000,
|
|
|
|
|
mask: true
|
|
|
|
|
})
|
|
|
|
|
this.data.coupons_list[e.currentTarget.dataset.index].is_received = 2
|
|
|
|
|
this.setData({
|
|
|
|
|
coupons_list: this.data.coupons_list
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// http("/api/v1/bind-coupon", "post", {
|
|
|
|
|
// activity_id: e.currentTarget.dataset.id
|
|
|
|
|
// }).then(res => {
|
|
|
|
|
// console.log(res);
|
|
|
|
|
// wx.showToast({
|
|
|
|
|
// title: '领取成功',
|
|
|
|
|
// icon: 'success',
|
|
|
|
|
// mask: true
|
|
|
|
|
// })
|
|
|
|
|
// // this.data.coupons_list[e.currentTarget.dataset.index].is_received = 1
|
|
|
|
|
// // this.setData({
|
|
|
|
|
// // coupons_list: this.data.coupons_list
|
|
|
|
|
// // })
|
|
|
|
|
// })
|
|
|
|
|
},
|
|
|
|
|
mydiscount() {
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|