59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import { alertInfo, alertSuccess, loadingFunc } from "../../utils/index"
|
|
import { redeemCoupons } from "../../service/system";
|
|
import request from "../../utils/request"
|
|
const { OK } = request;
|
|
|
|
// components/discountCoupon/index.js
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
type: Number,
|
|
data: Object
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
handleChange() {
|
|
const { data } = this.data;
|
|
const that = this;
|
|
loadingFunc(async () => {
|
|
const { code, message } = await redeemCoupons({ id: data.id, type: 2 })
|
|
if (code !== OK) {
|
|
alertInfo(message)
|
|
return
|
|
}
|
|
alertSuccess("兑换成功")
|
|
that.triggerEvent("change", { id, type: 2 })
|
|
})
|
|
},
|
|
handleUseIt() {
|
|
alertInfo("敬请期待")
|
|
},
|
|
async handleUse(e) {
|
|
const { data } = this.data;
|
|
const that = this;
|
|
loadingFunc(async () => {
|
|
const { code, message } = await redeemCoupons({ id: data.id, type: 2 })
|
|
if (code !== OK) {
|
|
alertInfo(message)
|
|
return;
|
|
}
|
|
alertSuccess("领取成功")
|
|
that.triggerEvent("get", { id, type: 1 })
|
|
})
|
|
|
|
}
|
|
}
|
|
}) |