Commit dab0bd36 authored by gaodapeng's avatar gaodapeng

增加核验代码,fix bugs

parent ec00a0a0
......@@ -69,3 +69,11 @@ export const ACTION_BALANCE_BACK_GOODS = "ACTION_BALANCE_BACK_GOODS";
//打印日结订单
export const ACTION_DAY_CHECK = "ACTION_DAY_CHECK";
//核验
export const ACTION_VERIFY = "ACTION_VERIFY";
//核验成功
export const ACTION_VERIFY_SUCCESS = "ACTION_VERIFY_SUCCESS";
//核验失败
export const ACTION_VERIFY_FAILED = "ACTION_VERIFY_FAILED";
<view class="popUpScanBg" a:if="{{dialogDisplay >= show}}">
<view class="popUpScanBg" hidden="{{dialogDisplay < show}}">
<!-- 灰黑色背景 -->
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;background-color: rgba(0, 0, 0, 0.65);background-size:100% 100%;"/>
......
......@@ -82,7 +82,7 @@ Page({
}
});
var speechContent = totalPrice + "元";
var speechContent = this.data.payPrice + "元";
my.ix.speech({
text: speechContent,
speak: true,
......@@ -98,6 +98,12 @@ Page({
},
onReady() {
if (my.canIUse('hideBackHome')) {
my.hideBackHome();
}
},
onShow() {
my.ix.onBuddyMessage({
......@@ -168,6 +174,7 @@ Page({
this.doPay(this.data.orderNo, res.barCode);
}
}, fail: (res) => {
my.hideLoading();
my.showToast({
type: 'exception',
content: api.decodeErrorMessage(res.error),
......@@ -232,7 +239,7 @@ Page({
console.log("支付回调成功,跳转 ");
if (res.data.tradeAmount != null) {
var speechContent = "成功支付" + res.data.tradeAmount + "元";
var speechContent = "成功支付" + payUtils.fen2Yuan(res.data.tradeAmount) + "元";
my.ix.speech({
text: speechContent,
speak: true,
......
......@@ -9,7 +9,8 @@ import {
ACTION_DIRECT_PAYMENT, ACTION_CONVERT_COUPON,
ACTION_GO_HOME, ACTION_REFUND, ACTION_REFUND_FAILED,
ACTION_REFUND_SUCCESS, ACTION_PRINT_LAST_ORDER,
ACTION_SYSTEM_SETTING,ACTION_DAY_CHECK
ACTION_SYSTEM_SETTING, ACTION_VERIFY, ACTION_VERIFY_SUCCESS,
ACTION_VERIFY_FAILED,ACTION_DAY_CHECK,
} from '../../const/actioncmd'
......@@ -17,7 +18,7 @@ Page({
data: {
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay: 0,
dialogShowType: "",//弹窗类型:如refund coupon
dialogShowType: "",//弹窗类型:如refund coupon verify
dialogRemindText: "请扫描兑换码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "兑换码已识别",
......@@ -38,12 +39,12 @@ Page({
success: (res) => {
console.info(`onBuddyMessage success: ${JSON.stringify(res)}`);
if (res.action == ACTION_GO_SCAN) {
// if (res.data.printEnabled != null) {
// my.setStorageSync({
// key: 'printEnabled',
// data: { enabled: res.data.printEnabled }
// })
// }
if (res.data.printEnabled != null) {
my.setStorageSync({
key: 'printEnabled',
data: { enabled: res.data.printEnabled }
});
}
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
......@@ -176,6 +177,25 @@ Page({
} else if (res.action == ACTION_DAY_CHECK) {
//本地先写死数据
context.printDayCheck();
} else if (res.action == ACTION_VERIFY) {
console.log("核验事件");
//显示弹窗
context.setData({
scanDialogDisplay: 1,
dialogShowType: "verify",
dialogRemindText: "请扫描订单编码核销",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "核验通过",
dialogResultSuccessText: "核验通过!可以离场",
dialogResultFailureRemind: "核验未通过",
dialogResultFailureText: "核验未通过!无效的核验码",
});
var speechContent = "请扫描订单编码核销";
my.ix.speech({
text: speechContent,
speak: true,
success: (r) => { }
});
}
}
});
......@@ -356,6 +376,8 @@ Page({
} else if (this.data.dialogShowType == "coupon") {
// 兑换券
this.verifyCoupon(r);
} else if (this.data.dialogShowType == "verify") {
this.verify(r);
}
}
},
......@@ -432,6 +454,24 @@ 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)}`);
}
});
},
//退款
......@@ -500,23 +540,38 @@ Page({
},
//同步兑换券到后台
sendConvertCouponToBack(e) {
//核验
verify(result) {
//目前缺少核验的接口,数据都是自造
var speechContent = "核验通过";
my.ix.speech({
text: speechContent,
speak: true,
success: (r) => { }
});
this.setData({ scanDialogDisplay: 3 })
this.onVerifyCallback(ACTION_VERIFY_SUCCESS, null);
},
onVerifyCallback(action, result) {
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
data: {
action: ACTION_CONVERT_COUPON,
data: e
action: action,
data: result
},
success: (sres) => {
success: (res) => {
console.info(`sendBuddyMessage success: ${JSON.stringify(res)}`);
//跳转到扫码页面
},
fail: (fres) => {
sendConvertCouponToBack(e)
fail: (res) => {
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