【收银台】

1. 接入 mock 支付
2. 接入提交支付后,直接成功的返回
pull/1/MERGE
YunaiV 2023-08-13 17:30:20 +08:00
parent 04ccd6d704
commit 1279ba6b5d
1 changed files with 48 additions and 30 deletions

View File

@ -11,7 +11,7 @@
:datatime="invalidTime / 1000" :is-col="true" :bgColor="bgColor" />
</view>
</view>
<view class="payment" v-if="code.length > 0">
<view class="payment" v-if="channelCode.length > 0">
<view class="title">
支付方式
</view>
@ -26,11 +26,11 @@
<view class="info" v-else>{{item.title}}</view>
</view>
</view>
<view class="iconfont" :class="item.code === code?'icon-xuanzhong11 font-num':'icon-weixuan'" />
<view class="iconfont" :class="item.code === channelCode ? 'icon-xuanzhong11 font-num':'icon-weixuan'" />
</view>
</view>
<view class="btn">
<view class="button acea-row row-center-wrapper" @click='goPay(code)'>确认支付</view>
<view class="button acea-row row-center-wrapper" @click='goPay(channelCode)'>确认支付</view>
<view class="wait-pay" @click="goReturnUrl('cancel')"></view>
</view>
</view>
@ -52,7 +52,7 @@
payPrice: 0, //
invalidTime: 0, //
code: '', //
channelCode: '', //
channels: [{ //
name: '微信支付', //
icon: "icon-weixin2",
@ -72,6 +72,11 @@
name: '余额支付',
icon: "icon-yuezhifu",
title: '可用余额',
}, {
name: '模拟支付',
icon: "icon-yuezhifu",
title: '使用模拟支付',
code: "mock"
},
//
@ -107,19 +112,15 @@
});
PayOrderApi.getOrder(this.orderId).then(res => {
//
if (!res.data){
this.goReturnUrl('close');
return;
}
if (res.data.status === 10) {
uni.showToast({
title: '支付成功'
})
this.goReturnUrl('success');
uni.hideLoading();
return;
} else if (res.data.status === 20) {
uni.showToast({
title: '无法支付,原因:订单已关闭'
})
this.goReturnUrl('close');
uni.hideLoading();
return;
}
@ -138,32 +139,49 @@
})
})
},
goPay(code) {
let that = this;
if (!that.orderId) return that.$util.Tips({
goPay(channelCode) {
if (!this.orderId) {
return this.$util.Tips({
title: '请选择要支付的订单'
});
if (code === 'yue' && parseFloat(number) < parseFloat(that.payPrice)) return that.$util.Tips({
}
if (channelCode === 'yue' && parseFloat(number) < parseFloat(this.payPrice)) {
return this.$util.Tips({
title: '余额不足'
});
}
uni.showLoading({
title: '支付中'
});
PayOrderApi.submitOrder({
id: that.orderId,
code: code,
displayMode: 'url', // TODO
id: this.orderId,
channelCode1: channelCode,
returnUrl: this.getPayReturnUrl(),
channelExtras: {
channelExtras: { // TODO
// openid: "ockUAwIZ-0OeMZl9ogcZ4ILrGba0" // wx_pub openid
openid: "oLefc4g5GjKWHJjLjMSXB3wX0fD0" // wx_lite openid
}
}).then(res => {
this.handleSubmitOrderResult(res.data);
}).catch(err => {
uni.hideLoading();
this.$util.Tips({
title: err
})
})
},
handleSubmitOrderResult(data) {
// 1.
if (data.status === 10) {
this.goReturnUrl('success');
return;
} else if (data.status === 20) {
this.goReturnUrl('close');
return;
}
// 2. displayMode
const displayMode = data.displayMode;
const displayContent = data.displayContent
// 2.1 URL
@ -171,13 +189,13 @@
window.location = displayContent;
return;
}
// 2.2 CUSTOM
if (displayMode === 'custom') {
if (this.code === 'wx_pub') {
// 2.2 APP
if (displayMode === 'app') {
if (this.channelCode === 'wx_pub') {
this.handleSubmitOrderResultForWxPub(displayContent)
return;
}
if (this.code === 'wx_lite') {
if (this.channelCode === 'wx_lite') {
this.handleSubmitOrderResultForWxLite(displayContent)
return;
}
@ -291,8 +309,8 @@
/**
* 设置支付方式
*/
payType(code) {
this.code = code
payType(channelCode) {
this.channelCode = channelCode
},
/**
* 获得支付的 return url