本时支付宝小程序

This commit is contained in:
唐明明
2020-09-24 11:08:03 +08:00
parent 11e0df1cc8
commit 6a67082c25
510 changed files with 20316 additions and 2 deletions

View File

@@ -0,0 +1,63 @@
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
})
})
}
});