Commit 0341da15 authored by pengguangpu's avatar pengguangpu

合并远程代码;

parents 7435e495 137c5dcb
......@@ -4,3 +4,9 @@ export const API_LOGIN = "store/cashier/login";
export const API_SCAN = "market/barcodeQuery";
//核销券
export const API_USE_COUPON = "coupon/use";
//创建订单
export const API_CREATE_ORDER = "order/create";
//支付接口
export const API_PAY = "pay/micropay";
//查询支付结果
export const API_QUERY = "order/query";
\ No newline at end of file
......@@ -17,11 +17,11 @@
<view style="font-size:38rpx;width:300rpx;color:rgba(0,0,0,0.85);font-weight:500;font-family:PingFangSC-Medium,PingFang SC;opacity:0.85;margin:75rpx auto;">请选择支付方式</view>
<view style="width:750rpx;margin-top:78rpx;justify-content:space-between;display:flex;flex-direction:row;box-sizing:border-box;padding-left:96rpx;padding-right:96rpx;">
<view class="payWayContainer">
<view class="payWayContainer" onTap="startPay">
<image mode="aspectFit" src="/images/icon_facepay.png" style="width:134rpx;height:131rpx;margin:10rpx 10rpx 10rpx 10rpx;"/>
<view class="payWayText">刷脸支付</view>
</view>
<view class="payWayContainer">
<view class="payWayContainer" onTap="startPay">
<image mode="aspectFit" src="/images/icon_qrpay.png" style="width:134rpx;height:131rpx;margin:10rpx 10rpx 10rpx 10rpx;"/>
<view class="payWayText">扫码支付</view>
</view>
......
var payUtils = require("../../utils/payUtils.js");
Page({
data: {
goodsNum: 0,
payPrice: 0.00,
totalPrice: 0.00,
couponPrice: 0.00,
qrPayShow: false,
goodsNum:0,
payPrice:0.00,
totalPrice:0.00,
couponPrice:0.00,
qrPayShow:false,
list:[],
orderNo:"",
isCashierClosed:false,
isPaying: false,
},
onLoad(options) {
var totalQuantity = options.totalQuantity
......@@ -27,6 +33,7 @@ Page({
},
facePay() {
},
......@@ -52,5 +59,131 @@ Page({
key: 'paySuccessResponse',
data: paySuccessResponse
});
},
/**
* @todo 支付结果的获取
* @todo 跳转数据的保存
*/
startPay(){
//开始loading
my.showLoading({});
//获取order
payUtils.getOrder(/*this.data.payPrice*/1,this.data.list, function(res){
if(res != null){
console.log("callback调用,res="+JSON.stringify(res));
if(res.resultCode ==1){
this.setData({
orderNo:res.data
});
this.payWithOpenCashier();
}
}
}.bind(this));
},
//调用收款接口
doPay(orderNo, payCode) {
console.log("doPay调用");
this.setData({isPaying:true});
//使用barCode来当面付
payUtils.startPay(orderNo, payCode, 1, this.data.list, function(res){
my.hideLoading();
console.log("支付回调 ===>" + JSON.stringify(res));
this.setData({isPaying:false});
if(res == null){
return;
}
if(res.code > 0){
//成功
console.log("支付回调成功,跳转 " );
// if(data.isCashierClosed == true){
my.ix.offCashierEventReceive();
my.redirectTo({
url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
});
// }
}else{
console.log("支付回调失败,toast提示 ");
my.ix.offCashierEventReceive();
my.showToast({
type: 'fail',
content: res.data,
duration: 2000
});
}
}.bind(this));
},
/**
* 打开收银台,进行扫码收款
*/
payWithOpenCashier(orderNo){
try{
console.info("收银台版本" + my.ix.getVersionSync({
packageName: 'zoloz.phone.android.alipay.com.dragonfly'
}).versionName);
//开启收银台监听
my.ix.startApp({
appName: "cashier",
bizNo: this.data.orderNo,
totalAmount: this.data.payPrice,
success: (res) => {
console.log("收银台启动回调 success==>" + JSON.stringify(res));
if (res.codeType == "F") {
this.doPay(orderNo, res.barCode);
} else {
this.data.isCashierClosed = true;
this.doPay(orderNo, res.barCode);
}
},fail:(res) => {
my.showToast({
type: 'exception',
content: api.decodeErrorMessage(res.error),
duration: 2000
});
}
});
//收银台回调
my.ix.onCashierEventReceive((res) => {
console.log("onCashierEventReceive==>" + JSON.stringify(res));
if (res.bizType == 'RESULT_CLOSED' || res.status == "RESULT_CLOSE") {
console.log("收银台关闭");
this.data.isCashierClosed = true;
//关闭监听
my.ix.offCashierEventReceive();
if (this.data.isPaying == true) {
//如果正在支付中,则等待支付结果返回
} else {
//跳转支付结果页面,说明支付已完成,无论取消支付还是支付成功等都跳转支付结果页
// if (this.data.actualPayPriceYuan != null) {
// my.redirectTo({
// //payPrice和couponPrice需要考虑支付宝优惠
// url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
// });
// } else {
// //说明用户取消了支付
// my.redirectTo({
// url: '/pages/paysuccess/paysuccess?payFailedMsg=' + "用户取消" + "&payPriceYuan=" + this.data.payPriceYuan,
// });
// }
}
} else if (res.bizType == 'RESULT_BTN_FUNCTION')
console.log("收银台自定义按钮按下");
else if (res.bizType == 'RESULT_MEMBER')
console.log("支付结果页会员开卡");
else
console.log('RESULT: ' + res.bizType);
});
} catch (err) {
console.log("收银台启动回调 异常==>" + JSON.stringify(err));
}
},
});
This diff is collapsed.
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