64 lines
1.3 KiB
JavaScript
Executable File
64 lines
1.3 KiB
JavaScript
Executable File
|
|
const api = require("../../api/api"),
|
|
app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
codeType: ""
|
|
},
|
|
onLoad(e) {
|
|
this.setData({
|
|
codeType: e.type || ""
|
|
})
|
|
},
|
|
//核销
|
|
qrcodeScan(e){
|
|
if(this.data.codeType == 1){
|
|
if(e.detail.value.price == "" || e.detail.value.no == ""){
|
|
my.showToast({
|
|
type : "none",
|
|
content : "消费金额与优惠券码不能为空~"
|
|
})
|
|
return
|
|
}
|
|
}else if(this.data.codeType == 0 && e.detail.value.no == ""){
|
|
my.showToast({
|
|
type : "none",
|
|
content : "优惠券码不能为空~"
|
|
})
|
|
return
|
|
}
|
|
my.showLoading({
|
|
content: "加载中"
|
|
})
|
|
|
|
api.request({
|
|
url : "coupon/scan",
|
|
header: {
|
|
"Authorization": app.globalData.token
|
|
},
|
|
method: "POST",
|
|
data : {
|
|
no : e.detail.value.no,
|
|
total : e.detail.value.price || 0,
|
|
type : this.data.codeType == 0 ? 2 : 1 //1满减 2实物
|
|
}
|
|
}).then(res=>{
|
|
my.hideLoading()
|
|
my.alert({
|
|
title : "提示",
|
|
content : res.data,
|
|
success : res=>{
|
|
my.navigateBack();
|
|
}
|
|
})
|
|
}).catch(err=>{
|
|
my.hideLoading()
|
|
my.showToast({
|
|
type : "fail",
|
|
content : err.data.message
|
|
})
|
|
})
|
|
}
|
|
});
|