Commit 368687ce authored by jiangjiantao's avatar jiangjiantao

兑换券

parent 40dea23e
{
"pages": [
"pages/home/home",
"pages/login/login",
"pages/paysuccess/paysuccess",
"pages/balance/balance",
"pages/scan/scan",
"pages/home/home"
"pages/scan/scan"
],
"window": {
"defaultTitle": ""
......
......@@ -34,3 +34,5 @@ export const ACTION_GET_ACCOUNT = "ACTION_GET_ACCOUNT";
//直接收款
export const ACTION_DIRECT_PAYMENT = "ACTION_DIRECT_PAYMENT";
//兑换券
export const ACTION_CONVERT_COUPON = "ACTION_CONVERT_COUPON";
\ No newline at end of file
......@@ -4,10 +4,12 @@ import { API_USE_COUPON } from '../../const/apiurl'
import { ACTION_GO_SCAN } from '../../const/actioncmd'
import { ACTION_GET_ACCOUNT } from '../../const/actioncmd'
import { ACTION_DIRECT_PAYMENT } from '../../const/actioncmd'
import { ACTION_CONVERT_COUPON } from '../../const/actioncmd'
Page({
data: {
scanDialogDisplay: 0
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay: 1
},
onLoad() {
......@@ -76,11 +78,16 @@ Page({
console.log("通知后屏小程序跳转到结算页面 失败 ===》 " + JSON.stringify(fres));
}
})
}else if(res.action == ACTION_CONVERT_COUPON){
//兑换券
this.setData({scanDialogDisplay:res.data})
}
}
});
},
onHide() {
// 页面隐藏
//关闭后屏监听
......@@ -94,27 +101,14 @@ Page({
}
},
homeTap() {
},
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
showDialog() {
this.setData({
scanDialogDisplay: 1
}
)
console.log(this.data.scanDialogDisplay);
},
//核销券
verifyCoupon(code) {
this.setData({scanDialogDisplay:2})
this.sendConvertCouponToBack(2)
var couponRequest = api.createCommonRequest();
couponRequest.couponCode = code;
console.log("核销券的请求 ==>" + JSON.stringify(couponRequest));
let context = this;
my.request({
url: getApp().globalData.BASE_URL + API_USE_COUPON,
method: 'POST',
......@@ -123,14 +117,17 @@ Page({
data: couponRequest,
success: (res) => {
if (res.data.success != true) {
context.sendConvertCouponToBack(4)
this.setData({scanDialogDisplay:4})
console.log("核销券失败 ==>" + res.data.message);
} else {
context.sendConvertCouponToBack(3)
this.setData({scanDialogDisplay:3})
console.log("核销券成功 ==>" + JSON.stringify(res));
}
},
fail: (res) => {
context.sendConvertCouponToBack(4)
this.setData({scanDialogDisplay:4})
console.log("核销券失败 ==>" + JSON.stringify(res));
my.showToast({
......@@ -143,6 +140,25 @@ Page({
},
//同步兑换券到后台
sendConvertCouponToBack(e){
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_CONVERT_COUPON,
data: e
},
success: (sres) => {
},
fail: (fres) => {
sendConvertCouponToBack(e)
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment