Commit 1b0a4998 authored by jiangjiantao's avatar jiangjiantao

兑换券

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