Commit 0c01dc9c authored by jiangjiantao's avatar jiangjiantao

bugfixed

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