Commit 149cd9d1 authored by gaodapeng's avatar gaodapeng

增加收银台退出逻辑

parent 64e523c9
......@@ -15,6 +15,7 @@ Page({
list: [],
orderNo: "",
isPaying: false,
},
//回退到上一个页面
......@@ -99,36 +100,51 @@ Page({
},
onShow() {
console.log("balance onShow");
my.ix.onBuddyMessage({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if (res.action == ACTION_GO_SCAN) {//返回扫码页
//增加跳转回去的内容
my.navigateBack();
my.ix.exitApp({ appName: 'cashier' });
} else if (res.action == ACTION_GO_HOME) {
//去首页
my.reLaunch({
url: "/pages/home/home",
});
//取消操作
my.ix.exitApp({ appName: 'cashier' });
}
}
});
},
onHide() {
},
onUnload() {
console.log("balance onShow");
// 页面隐藏
//关闭后屏监听
my.ix.offBuddyMessage();
},
/**
* @todo 支付结果的获取
* @todo 跳转数据的保存
*/
* 支付
*/
startPay() {
//开始loading
if (this.data.isPaying == true) {
return
}
my.showLoading({});
this.setData({
isPaying: true,
})
//获取order
var payAmount = payUtils.yuan2Fen(this.data.payPrice);
payUtils.getOrder(payAmount, this.data.list, function (res) {
......@@ -140,6 +156,10 @@ Page({
orderNo: res.data
});
this.payWithOpenCashier(res.data);
} else {
this.setData({
isPaying: false
});
}
}
}.bind(this));
......@@ -167,12 +187,16 @@ Page({
this.doPay(this.data.orderNo, res.barCode);
}
}, fail: (res) => {
console.log("收银台启动失败 ==>" + JSON.stringify(res));
my.hideLoading();
my.showToast({
type: 'exception',
content: api.decodeErrorMessage(res.error),
duration: 2000
});
this.setData({
isPaying: false
});
}
});
//收银台回调
......@@ -183,23 +207,9 @@ Page({
console.log("收银台关闭");
//关闭监听
my.ix.offCashierEventReceive();
if (this.data.isPaying == true) {
//如果正在支付中,则等待支付结果返回
} else {
//跳转支付结果页面,说明支付已完成,无论取消支付还是支付成功等都跳转支付结果页
// if (this.data.actualPayPriceYuan != null) {
// my.redirectTo({
// //payPrice和couponPrice需要考虑支付宝优惠
// url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
// });
// } else {
// //说明用户取消了支付
// my.redirectTo({
// url: '/pages/paysuccess/paysuccess?payFailedMsg=' + "用户取消" + "&payPriceYuan=" + this.data.payPriceYuan,
// });
// }
}
this.setData({
isPaying: false
});
} else if (res.bizType == 'RESULT_BTN_FUNCTION')
console.log("收银台自定义按钮按下");
else if (res.bizType == 'RESULT_MEMBER')
......@@ -243,7 +253,7 @@ Page({
my.ix.offCashierEventReceive();
this.saveData(this.data.list, res.data);
my.redirectTo({
my.reLaunch({
url: '/pages/paysuccess/paysuccess?totalGoodsNum=' + this.data.goodsNum,
});
......
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