Commit 1b0a4998 authored by jiangjiantao's avatar jiangjiantao

兑换券

parent 368687ce
{ {
"pages": [ "pages": [
"pages/home/home",
"pages/login/login", "pages/login/login",
"pages/paysuccess/paysuccess", "pages/paysuccess/paysuccess",
"pages/balance/balance", "pages/balance/balance",
"pages/scan/scan" "pages/scan/scan",
"pages/home/home"
], ],
"window": { "window": {
"defaultTitle": "" "defaultTitle": ""
......
...@@ -9,7 +9,7 @@ import { ACTION_CONVERT_COUPON } from '../../const/actioncmd' ...@@ -9,7 +9,7 @@ import { ACTION_CONVERT_COUPON } from '../../const/actioncmd'
Page({ Page({
data: { data: {
//显示弹窗,>1为显示,2loading 3 result success 4 result failed //显示弹窗,>1为显示,2loading 3 result success 4 result failed
scanDialogDisplay: 1 scanDialogDisplay: 0
}, },
onLoad() { onLoad() {
...@@ -86,7 +86,13 @@ Page({ ...@@ -86,7 +86,13 @@ Page({
}); });
}, },
//外接扫码枪事件
onKeyPress(r) {
console.log("scan onKeyPress==>" + r);
if(this.data.scanDialogDisplay != 0){
this.verifyCoupon(r);
}
},
onHide() { onHide() {
// 页面隐藏 // 页面隐藏
...@@ -104,7 +110,9 @@ Page({ ...@@ -104,7 +110,9 @@ Page({
//核销券 //核销券
verifyCoupon(code) { verifyCoupon(code) {
this.setData({scanDialogDisplay:2}) this.setData({scanDialogDisplay:2})
this.sendConvertCouponToBack(2) var commonRequest = {};
commonRequest.state = 2
this.sendConvertCouponToBack(commonRequest)
var couponRequest = api.createCommonRequest(); var couponRequest = api.createCommonRequest();
couponRequest.couponCode = code; couponRequest.couponCode = code;
console.log("核销券的请求 ==>" + JSON.stringify(couponRequest)); console.log("核销券的请求 ==>" + JSON.stringify(couponRequest));
...@@ -116,18 +124,27 @@ Page({ ...@@ -116,18 +124,27 @@ Page({
timeout: 30000, timeout: 30000,
data: couponRequest, data: couponRequest,
success: (res) => { success: (res) => {
console.log("核销券成功 ==>" + JSON.stringify(res));
if (res.data.success != true) { if (res.data.success != true) {
context.sendConvertCouponToBack(4) 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.message); console.log("核销券失败 ==>" + res.data.errorMsg);
} else { } else {
context.sendConvertCouponToBack(3) var commonRequest = {};
commonRequest.state = 3
context.sendConvertCouponToBack(commonRequest)
this.setData({scanDialogDisplay:3}) this.setData({scanDialogDisplay:3})
console.log("核销券成功 ==>" + JSON.stringify(res)); console.log("核销券成功 ==>" + JSON.stringify(res));
} }
}, },
fail: (res) => { fail: (res) => {
context.sendConvertCouponToBack(4) var commonRequest = {};
commonRequest.state = 4
commonRequest.msg = "网络异常"
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({
......
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