This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/components/diy/coupon/coupon.js
2020-04-25 22:59:04 +08:00

45 lines
795 B
JavaScript

const App = getApp();
Component({
options: {
addGlobalClass: true,
},
/**
* 组件的属性列表
* 用于组件自定义设置
*/
properties: {
itemIndex: String,
itemStyle: Object,
params: Object,
dataList: Object
},
methods: {
/**
* 领取优惠券
*/
receiveTap: function(e) {
let _this = this,
dataset = e.currentTarget.dataset;
if (!dataset.state) {
return false;
}
App._post_form('user.coupon/receive', {
coupon_id: dataset.couponId
}, function(result) {
App.showSuccess(result.msg);
_this.setData({
['dataList[' + dataset.index + '].state']: {
value: 0,
text: '已领取'
}
});
});
}
}
})