Commit 87d52a91 authored by jiangjiantao's avatar jiangjiantao

核销兑换券

parent 0b3d1e22
......@@ -12,7 +12,8 @@ App({
//小程序容器版本
containerVersionCode: null,
localAccountInfo:null,
sn:""
//模拟器上需要sn有值
sn:"xx"
},
onLaunch(options) {
......
//登陆
export const API_LOGIN = "store/cashier/login";
//查询商品
export const API_SCAN = "market/barcodeQuery";
//核销券
export const API_USE_COUPON = "coupon/use";
......@@ -17,10 +17,7 @@ Component({
resultSuccessText:"",
resultFailureRemind:"",
resultFailureText:"",
displayDialog: 0,
},// 可给外部传入的属性添加默认值
didMount() {
},// 生命周期函数,加载成功
......
{
"component2": true
}
\ No newline at end of file
<view class="page" >
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;background:url(/images/bg_home.png) no-repeat fixed top;background-size:100% 100%;"/>
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;background:url(/images/bg_home.png) no-repeat fixed top;background-size:100% 100%;" onTap="homeTap"/>
<scandialog displayDialog="{{scanDialogDisplay}}"
remindText="请扫描订单编码"
remindText="请扫描兑换码"
loadingText="识别中"
resultSuccessRemind="退款成功"
resultSuccessRemind="退款完成!会在1~2个工作日 返还到您的付款账户"
resultFailureRemind="退款失败"
resultFailureText="核销失败!无效的订单码"
resultSuccessRemind="兑换码已识别"
resultSuccessText="恭喜您!兑换成功 "
resultFailureRemind="兑换码未识别"
resultFailureText="兑换失败,请稍后重试!"
/>
</view>
\ No newline at end of file
import { Page } from '../../utils/scan';
import { API_USE_COUPON } from '../../const/apiurl'
var api = require("../../utils/api.js");
Page({
data: {
scanDialogDisplay:0
scanDialogDisplay: 0
},
onLoad() {
},
onReady(){
onReady() {
if (my.canIUse('hideBackHome')) {
my.hideBackHome();
}
},
scanDialog(ref){
scanDialog(ref) {
// if(ref.getAttribute("id") == "drawbackDialog"){
// }else if(ref.getAttribute("id") == ""){
// }
},
homeTap(){
homeTap() {
this.showDialog();
//FIXME 这里是跳转到新的界面
my.navigateTo({
url: "/pages/balance/balance"
});
// my.navigateTo({
// url: "/pages/balance/balance"
// });
},
<<<<<<< HEAD
//外接扫码枪事件
onKeyPress(r) {
console.log("scan onKeyPress==>" + r);
// this.getGoodInfoByBarcode(r);
console.log(" onKeyPress==>" + r);
//核销券
if (this.data.scanDialogDisplay == 1) {
this.verifyCoupon(r)
return;
}
my.navigateTo({
url: "/pages/scan/scan?barcode=" + r,
});
},
=======
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
showDialog(){
this.setData(
this.data.scanDialogDisplay = this.data.scanDialogDisplay+1
)
}
>>>>>>> b85311896b3b12a7e29afcc50be66f821096a0f3
showDialog() {
this.setData({
scanDialogDisplay: 1
}
)
console.log(this.data.scanDialogDisplay);
},
//核销券
verifyCoupon(code) {
this.setData({scanDialogDisplay:2})
var couponRequest = api.createCommonRequest();
couponRequest.couponCode = code;
console.log("核销券的请求 ==>" + JSON.stringify(couponRequest));
my.request({
url: getApp().globalData.BASE_URL + API_USE_COUPON,
method: 'POST',
dataType: 'json',
timeout: 30000,
data: couponRequest,
success: (res) => {
if (res.data.success != true) {
this.setData({scanDialogDisplay:4})
console.log("核销券失败 ==>" + res.data.message);
} else {
this.setData({scanDialogDisplay:3})
console.log("核销券成功 ==>" + JSON.stringify(res));
}
},
fail: (res) => {
this.setData({scanDialogDisplay:4})
console.log("核销券失败 ==>" + JSON.stringify(res));
my.showToast({
type: 'exception',
content: api.decodeErrorMessage(res.error),
duration: 2000
});
}
});
},
......
var api = require("../../utils/api.js");
import { Page } from '../../utils/scan';
import {API_SCAN} from '../../const/apiurl'
import {API_USE_COUPON} from '../../const/apiurl'
Page({
......@@ -132,7 +133,6 @@ Page({
this.setData({ goods: newgoods })
}
//汇总
this.setData({ totalQuantity: totalQuantityTemp,
totalPrice: totalPriceTemp,
......@@ -145,6 +145,50 @@ Page({
my.navigateTo({
url: "/pages/balance/balance?totalPrice=" + this.data.totalPrice+"&totalQuantity="+this.data.totalQuantity+"&totalDisc="+this.data.totalDisc,
});
}
},
//核销券
verifyCoupon(code) {
my.showLoading({});
var couponRequest = api.createCommonRequest();
couponRequest.couponCode = barcode;
console.log("核销券的请求 ==>" + JSON.stringify(couponRequest));
my.request({
url: getApp().globalData.BASE_URL + API_USE_COUPON,
method: 'POST',
dataType: 'json',
timeout: 30000,
data: couponRequest,
success: (res) => {
my.hideLoading();
console.log("核销券成功 ==>" + JSON.stringify(res));
if (res.data.success != true) {
my.showToast({
type: 'fail',
content: res.data.message,
duration: 2000
});
} else {
console.log("核销券成功");
}
},
fail: (res) => {
my.hideLoading();
console.log("核销券失败 ==>" + JSON.stringify(res));
my.showToast({
type: 'exception',
content: api.decodeErrorMessage(res.error),
duration: 2000
});
}
});
},
});
\ No newline at end of file
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