【收银台】

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