|
|
@ -18,9 +18,12 @@ |
|
|
|
<view class="payment-method"> |
|
|
|
<view class="payment-method"> |
|
|
|
<view v-for="(item, index) in methods" :key="index" class="pay-item dis-flex flex-x-between" @click="handleSelectPayType(index)"> |
|
|
|
<view v-for="(item, index) in methods" :key="index" class="pay-item dis-flex flex-x-between" @click="handleSelectPayType(index)"> |
|
|
|
<view class="item-left dis-flex flex-y-center"> |
|
|
|
<view class="item-left dis-flex flex-y-center"> |
|
|
|
<view class="item-left_icon" :class="[item.method]"> |
|
|
|
<view v-if="item.method!=='huifu'" class="item-left_icon" :class="[item.method]"> |
|
|
|
<text class="iconfont" :class="[PayMethodIconEnum[item.method]]"></text> |
|
|
|
<text class="iconfont" :class="[PayMethodIconEnum[item.method]]"></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view v-else class="huifu-box"> |
|
|
|
|
|
|
|
<image :src="`${$picUrl}/static/yinlian.png`" mode="heightFix" class="huifu"></image> |
|
|
|
|
|
|
|
</view> |
|
|
|
<view class="item-left_text"> |
|
|
|
<view class="item-left_text"> |
|
|
|
<text>{{ PayMethodEnum[item.method].name }}</text> |
|
|
|
<text>{{ PayMethodEnum[item.method].name }}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -117,10 +120,19 @@ |
|
|
|
this.orderId = Number(orderId) |
|
|
|
this.orderId = Number(orderId) |
|
|
|
// 获取收银台信息 |
|
|
|
// 获取收银台信息 |
|
|
|
this.getCashierInfo() |
|
|
|
this.getCashierInfo() |
|
|
|
|
|
|
|
uni.$on('appShow', this.solveShowMsg); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
onUnload() { |
|
|
|
|
|
|
|
uni.$off('appShow', this.solveShowMsg); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
|
|
|
|
solveShowMsg(info) { |
|
|
|
|
|
|
|
console.log(info); |
|
|
|
|
|
|
|
if (this.miniPayRequest && Object.keys(this.miniPayRequest).length > 0 && info.appId === this.miniPayRequest.miniuser) { |
|
|
|
|
|
|
|
this.onTradeQuery(this.miniPayRequest.out_trade_no, this.curPaymentItem.method); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
// 获取收银台信息 |
|
|
|
// 获取收银台信息 |
|
|
|
getCashierInfo() { |
|
|
|
getCashierInfo() { |
|
|
|
const app = this |
|
|
|
const app = this |
|
|
@ -160,6 +172,9 @@ |
|
|
|
// 选择支付方式 |
|
|
|
// 选择支付方式 |
|
|
|
handleSelectPayType(index) { |
|
|
|
handleSelectPayType(index) { |
|
|
|
this.curPaymentItem = this.methods[index] |
|
|
|
this.curPaymentItem = this.methods[index] |
|
|
|
|
|
|
|
if (this.curPaymentItem.method === 'huifu') { |
|
|
|
|
|
|
|
this.createOrder(); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 判断当前页面来源于浏览器返回 |
|
|
|
// 判断当前页面来源于浏览器返回 |
|
|
@ -195,23 +210,55 @@ |
|
|
|
// 确认支付 |
|
|
|
// 确认支付 |
|
|
|
handleSubmit() { |
|
|
|
handleSubmit() { |
|
|
|
const app = this |
|
|
|
const app = this |
|
|
|
// 判断是否选择了支付方式 |
|
|
|
// 判断是否选择了支付方式 |
|
|
|
if (!app.curPaymentItem) { |
|
|
|
if (!app.curPaymentItem) { |
|
|
|
app.$toast('您还没有选择支付方式') |
|
|
|
app.$toast('您还没有选择支付方式') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
// 按钮禁用 |
|
|
|
// 按钮禁用 |
|
|
|
if (app.disabled) return |
|
|
|
if (app.disabled) return |
|
|
|
app.disabled = true |
|
|
|
app.disabled = true |
|
|
|
// 提交到后端API |
|
|
|
if (app.curPaymentItem.method === 'huifu') { |
|
|
|
CashierApi.orderPay(app.orderId, { |
|
|
|
app.disabled = false |
|
|
|
method: app.curPaymentItem.method, |
|
|
|
if (!app.miniPayRequest || Object.keys(app.miniPayRequest).length === 0) { |
|
|
|
client: app.platform, |
|
|
|
app.$toast(`暂无${app.PayMethodEnum[app.curPaymentItem.method].name}支付信息`); |
|
|
|
extra: app.getExtraAsUnify(app.curPaymentItem.method) |
|
|
|
return |
|
|
|
}) |
|
|
|
} |
|
|
|
.then(result => app.onSubmitCallback(result)) |
|
|
|
let appPayRequest = ''; |
|
|
|
.finally(err => setTimeout(() => app.disabled = false, 10)) |
|
|
|
appPayRequest = encodeURIComponent(JSON.stringify({ |
|
|
|
}, |
|
|
|
sign: app.miniPayRequest.sign, |
|
|
|
|
|
|
|
prepayid: app.miniPayRequest.prepayid, |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
uni.openEmbeddedMiniProgram({ |
|
|
|
|
|
|
|
appId: app.miniPayRequest.miniuser, |
|
|
|
|
|
|
|
path: `${app.miniPayRequest.minipath}?appPayRequest=${appPayRequest}` |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 提交到后端API |
|
|
|
|
|
|
|
this.createOrder(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createOrder() { |
|
|
|
|
|
|
|
const app = this; |
|
|
|
|
|
|
|
CashierApi.orderPay(app.orderId, { |
|
|
|
|
|
|
|
method: app.curPaymentItem.method, |
|
|
|
|
|
|
|
client: app.platform, |
|
|
|
|
|
|
|
extra: app.getExtraAsUnify(app.curPaymentItem.method) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.then(result => { |
|
|
|
|
|
|
|
console.log(result); |
|
|
|
|
|
|
|
if (app.curPaymentItem.method === 'huifu') { |
|
|
|
|
|
|
|
const { miniPayRequest, out_trade_no } = result.data.payment; |
|
|
|
|
|
|
|
app.miniPayRequest = miniPayRequest; |
|
|
|
|
|
|
|
app.miniPayRequest.out_trade_no = out_trade_no; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
app.onSubmitCallback(result) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.finally(err => setTimeout(() => app.disabled = false, 10)) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 获取第三方支付的扩展参数 |
|
|
|
// 获取第三方支付的扩展参数 |
|
|
|
getExtraAsUnify(method) { |
|
|
|
getExtraAsUnify(method) { |
|
|
@ -355,7 +402,7 @@ |
|
|
|
.payment-method { |
|
|
|
.payment-method { |
|
|
|
width: 94%; |
|
|
|
width: 94%; |
|
|
|
margin: 0 auto 20rpx auto; |
|
|
|
margin: 0 auto 20rpx auto; |
|
|
|
padding: 0 40rpx; |
|
|
|
padding: 0 40rpx 0 20rpx; |
|
|
|
background-color: #ffffff; |
|
|
|
background-color: #ffffff; |
|
|
|
border-radius: 20rpx; |
|
|
|
border-radius: 20rpx; |
|
|
|
|
|
|
|
|
|
|
@ -369,8 +416,9 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.item-left_icon { |
|
|
|
.item-left_icon { |
|
|
|
margin-right: 20rpx; |
|
|
|
width: 100rpx; |
|
|
|
font-size: 44rpx; |
|
|
|
text-align: center; |
|
|
|
|
|
|
|
font-size: 60rpx; |
|
|
|
|
|
|
|
|
|
|
|
&.wechat { |
|
|
|
&.wechat { |
|
|
|
color: #00c800; |
|
|
|
color: #00c800; |
|
|
@ -384,6 +432,14 @@ |
|
|
|
color: #ff9700; |
|
|
|
color: #ff9700; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.huifu-box { |
|
|
|
|
|
|
|
width: 100rpx; |
|
|
|
|
|
|
|
display: flex; |
|
|
|
|
|
|
|
justify-content: center; |
|
|
|
|
|
|
|
.huifu { |
|
|
|
|
|
|
|
height: 44rpx; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.item-left_text { |
|
|
|
.item-left_text { |
|
|
|
font-size: 28rpx; |
|
|
|
font-size: 28rpx; |
|
|
|