Commit 0c01dc9c authored by jiangjiantao's avatar jiangjiantao

bugfixed

parent fdc651fe
...@@ -82,6 +82,8 @@ Page({ ...@@ -82,6 +82,8 @@ Page({
scanDialogDisplay: res.data.discCouponState, scanDialogDisplay: res.data.discCouponState,
totalDisc:res.data. discCouponPrice totalDisc:res.data. discCouponPrice
}); });
if (res.data.discCouponState == 1) {
var speechContent = "请扫描优惠券码"; var speechContent = "请扫描优惠券码";
my.ix.speech({ my.ix.speech({
text: speechContent, text: speechContent,
...@@ -92,6 +94,8 @@ Page({ ...@@ -92,6 +94,8 @@ Page({
} }
} }
}
}); });
}, },
...@@ -116,18 +120,36 @@ Page({ ...@@ -116,18 +120,36 @@ Page({
setTimeout(() => { setTimeout(() => {
let totalDiscTemp = this.data.totalDisc + Math.round(Math.random() * 4) + 1; let totalDiscTemp = this.data.totalDisc + Math.round(Math.random() * 4) + 1;
let context = this; //超额
if(totalDiscTemp > this.data.totalPrice){
let req = {}
req.discCouponErrMsg = "超额优惠券"
req.discCouponState = 4;
this.useCouponCallback(ACTION_USE_COUPON, req)
return
}
let req = {} let req = {}
req.discCouponPrice = totalDiscTemp; req.discCouponPrice = totalDiscTemp;
req.discCouponState = 3; req.discCouponState = 3;
var commonRequest = { this.useCouponCallback(ACTION_USE_COUPON,req)
action: ACTION_USE_COUPON,
data: req }, 700);
}; },
//用券回调
useCouponCallback(action, result) {
let context = this;
my.ix.sendBuddyMessage({ my.ix.sendBuddyMessage({
target: getApp().globalData.backScreenAppId, target: getApp().globalData.backScreenAppId,
data: commonRequest, data: {
action: action,
data: result
},
success: (res) => { success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
//用券成功
if(result.discCouponState == 3){
//模拟数据 1 - 5 随机整数 //模拟数据 1 - 5 随机整数
context.setData({ scanDialogDisplay: 0, totalDisc: totalDiscTemp }) context.setData({ scanDialogDisplay: 0, totalDisc: totalDiscTemp })
my.showToast({ my.showToast({
...@@ -138,15 +160,16 @@ Page({ ...@@ -138,15 +160,16 @@ Page({
}, },
}); });
console.log("用券成功到后屏小程序成功 ===》" + JSON.stringify(res)); //用券失败
}else if(result.discCouponState == 4){
context.setData({ scanDialogDisplay: 4 })
}
}, },
fail: (res) => { fail: (res) => {
console.log("用券成功后屏小程序 失败 ===》 " + JSON.stringify(res)); console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
//发送失败重试 context.useCouponCallback(action,result)
context.sendGoodInfoToBack();
} }
}) });
}, 700);
}, },
//获取商品信息 //获取商品信息
......
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