Commit bfeefbf3 authored by jiangjiantao's avatar jiangjiantao

bugfix

parents 695eb834 5c7679cf
......@@ -9,11 +9,14 @@ import { ACTION_GO_HOME } from '../../const/actioncmd'
import { ACTION_REFUND } from '../../const/actioncmd'
import { ACTION_REFUND_FAILED } from '../../const/actioncmd'
import { ACTION_REFUND_SUCCESS } from '../../const/actioncmd'
import { API_REFUND } from '../../const/apiurl'
Page({
data: {
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay: 0,
dialogShowType: "",//弹窗类型:如refund coupon
dialogRemindText: "请扫描兑换码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "兑换码已识别",
......@@ -69,8 +72,8 @@ Page({
console.info(`sendBuddyMessage failed: ${JSON.stringify(res)}`);
}
});
}else if (res.action == ACTION_DIRECT_PAYMENT) {
} else if (res.action == ACTION_DIRECT_PAYMENT) {
//直接收款
my.ix.sendBuddyMessage({
target: getApp().globalData.backScreenAppId,
......@@ -89,13 +92,24 @@ Page({
console.log("通知后屏小程序跳转到结算页面 失败 ===》 " + JSON.stringify(fres));
}
})
}else if(res.action == ACTION_CONVERT_COUPON){
} else if (res.action == ACTION_CONVERT_COUPON) {
//兑换券
this.setData({scanDialogDisplay:res.data})
context.setData({
scanDialogDisplay: res.data,
dialogShowType: "coupon",//弹窗类型:如refund coupon
dialogRemindText: "请扫描兑换码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "兑换码已识别",
dialogResultSuccessText: "恭喜您!兑换成功",
dialogResultFailureRemind: "兑换码未识别",
dialogResultFailureText: "兑换失败,请稍后重试!",
})
} else if (res.action == ACTION_REFUND) {
//显示弹窗
context.setData({
scanDialogDisplay: 1,
dialogShowType: "refund",
dialogRemindText: "请扫描订单编码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "退款成功",
......@@ -103,21 +117,29 @@ Page({
dialogResultFailureRemind: "退款失败",
dialogResultFailureText: "退款失败!无效的订单码",
});
} else if (res.action == ACTION_GO_HOME) {
//home界面收到,则返回界面上
context.setData({
scanDialogDisplay: 0
scanDialogDisplay: 0,
dialogShowType: "",//重置类型
})
}
}
});
},
//外接扫码枪事件
//外接扫码枪事件
onKeyPress(r) {
console.log("scan onKeyPress==>" + r);
if(this.data.scanDialogDisplay != 0){
this.verifyCoupon(r);
if (this.data.scanDialogDisplay != 0) {
if (this.data.dialogShowType == "refund") {
//退款
this.refund(r);
} else if(this.data.dialogShowType == "coupon") {
// 兑换券
this.verifyCoupon(r);
}
}
},
......@@ -136,7 +158,7 @@ Page({
//核销券
verifyCoupon(code) {
this.setData({scanDialogDisplay:2})
this.setData({ scanDialogDisplay: 2 })
var commonRequest = {};
commonRequest.state = 2
this.sendConvertCouponToBack(commonRequest)
......@@ -151,19 +173,19 @@ Page({
timeout: 30000,
data: couponRequest,
success: (res) => {
console.log("核销券成功 ==>" + JSON.stringify(res));
console.log("核销券成功 ==>" + JSON.stringify(res));
if (res.data.success != true) {
var commonRequest = {};
commonRequest.state = 4
commonRequest.msg = res.data.errorMsg
var commonRequest = {};
commonRequest.state = 4
commonRequest.msg = res.data.errorMsg
context.sendConvertCouponToBack(commonRequest)
this.setData({scanDialogDisplay:4})
this.setData({ scanDialogDisplay: 4 })
console.log("核销券失败 ==>" + res.data.errorMsg);
} else {
var commonRequest = {};
commonRequest.state = 3
var commonRequest = {};
commonRequest.state = 3
context.sendConvertCouponToBack(commonRequest)
this.setData({scanDialogDisplay:3})
this.setData({ scanDialogDisplay: 3 })
console.log("核销券成功 ==>" + JSON.stringify(res));
}
},
......@@ -172,7 +194,7 @@ Page({
commonRequest.state = 4
commonRequest.msg = "网络异常"
context.sendConvertCouponToBack(commonRequest)
this.setData({scanDialogDisplay:4})
this.setData({ scanDialogDisplay: 4 })
console.log("核销券失败 ==>" + JSON.stringify(res));
my.showToast({
type: 'exception',
......@@ -204,10 +226,14 @@ Page({
timeout: 30000,
data: request,
success: (res) => {
if (res.data.success != true||res.data.data == null) {
if (res.data.success != true || res.data.data == null) {
this.setData({ scanDialogDisplay: 4 })
console.log("退款失败 ==>" + JSON.stringify(res.data));
this.refundCallback(ACTION_REFUND_FAILED,null);
var message = res.data.message;
if (message == null) {
message = "退款失败,请检查退款订单号,稍后再试";
}
this.refundCallback(ACTION_REFUND_FAILED, message);
} else {
this.setData({ scanDialogDisplay: 3 })
console.log("退款成功 ==>" + JSON.stringify(res.data));
......@@ -217,12 +243,16 @@ Page({
fail: (res) => {
this.setData({ scanDialogDisplay: 4 })
console.log("退款失败 ==>" + JSON.stringify(res.data));
this.refundCallback(ACTION_REFUND_FAILED,null);
var message = res.data.message;
if (message == null) {
message = "退款失败,请检查退款订单号,稍后再试";
}
this.refundCallback(ACTION_REFUND_FAILED, message);
}
});
},
refundCallback(action,data){
refundCallback(action, data) {
my.ix.sendBuddyMessage({
// 填入目标小程序的 AppID
target: getApp().globalData.backScreenAppId,
......@@ -242,23 +272,23 @@ 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)}`);
}
});
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)}`);
}
});
}
......
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