67 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var http = require('../../utils/http.js');
Component({
/**
* 组件的属性列表
*/
properties: {
item: Object,
type: Number,
order: Boolean,
canUse: Boolean,
index: Number,
showTimeType: Number
},
/**
* 组件的初始数据
*/
data: {
stsType: 4
},
// 生命周期函数可以为函数或一个在methods段中定义的方法名
attached: function() {
//console.log(this.data.item);
},
/**
* 组件的方法列表
*/
methods: {
receiveCoupon() {
var couponId = this.data.item.couponId;
http.request({
url: "/p/myCoupon/receive",
method: "POST",
data: couponId,
callBack: () => {
var coupon = this.data.item;
coupon.canReceive = false;
this.setData({
item: coupon
})
}
})
},
checkCoupon(e) {
// this.triggerEvent('checkCoupon', this.data.index);
this.triggerEvent('checkCoupon', {
couponId: e.currentTarget.dataset.couponid
});
},
/**
* 立即使用
*/
useCoupon() {
var url = '/pages/prod-classify/prod-classify?sts=' + this.data.stsType;
var id = this.data.item.couponId;
var title = "优惠券活动商品";
if (id) {
url += "&tagid=" + id + "&title=" + title;
}
wx.navigateTo({
url: url
})
}
}
})