Commit 85644c73 authored by gaodapeng's avatar gaodapeng

修改home页面

parent 4423a557
......@@ -14,6 +14,7 @@ Page({
data: {
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay: 0,
dialogShowType: "",//弹窗类型:如refund
dialogRemindText: "请扫描兑换码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "兑换码已识别",
......@@ -69,8 +70,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 +90,14 @@ 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})
this.setData({ scanDialogDisplay: res.data })
} else if (res.action == ACTION_REFUND) {
//显示弹窗
context.setData({
scanDialogDisplay: 1,
dialogShowType:"refund",
dialogRemindText: "请扫描订单编码",
dialogLoadingText: "识别中",
dialogResultSuccessRemind: "退款成功",
......@@ -106,18 +108,24 @@ Page({
} 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") {
refund(r);
} else {
this.verifyCoupon(r);
}
}
},
......@@ -136,7 +144,7 @@ Page({
//核销券
verifyCoupon(code) {
this.setData({scanDialogDisplay:2})
this.setData({ scanDialogDisplay: 2 })
var commonRequest = {};
commonRequest.state = 2
this.sendConvertCouponToBack(commonRequest)
......@@ -151,19 +159,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 +180,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',
......@@ -183,14 +191,6 @@ Page({
});
},
//增加扫码内容,以及退款等操作的内容
onKeyPress(r) {
//只有在弹窗出现时才扫码
if (this.data.scanDialogDisplay > 0) {
refund(r);
}
},
refund(barcode) {
this.setData({ scanDialogDisplay: 2 })
var request = api.createCommonRequest();
......@@ -203,10 +203,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));
......@@ -216,12 +220,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,
......@@ -241,23 +249,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