Commit bfeefbf3 authored by jiangjiantao's avatar jiangjiantao

bugfix

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