Commit 149cd9d1 authored by gaodapeng's avatar gaodapeng

增加收银台退出逻辑

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