feat(M08-A): 接入顾客端权益明细
This commit is contained in:
@@ -3,6 +3,7 @@ const {
|
||||
ensureLogin,
|
||||
cents,
|
||||
clientRequestId,
|
||||
requestWechatPayment,
|
||||
} = require('../../utils/api.js')
|
||||
|
||||
function defaultStartAt() {
|
||||
@@ -96,6 +97,35 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
async createWechatPayment() {
|
||||
if (!this.data.order || !this.data.order.orderId) {
|
||||
this.setData({ errorMessage: '请先预占订单' })
|
||||
return
|
||||
}
|
||||
await this.withRequest(async () => {
|
||||
const paymentResponse = await request('/payments', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
orderId: this.data.order.orderId,
|
||||
provider: 'WECHAT',
|
||||
clientRequestId: clientRequestId('miniapp-wxpay'),
|
||||
},
|
||||
})
|
||||
const prepayResponse = await request('/pay/wechat/prepay', {
|
||||
method: 'POST',
|
||||
data: { paymentId: paymentResponse.data.paymentId },
|
||||
})
|
||||
await requestWechatPayment(prepayResponse.data)
|
||||
this.setData({
|
||||
payment: {
|
||||
...paymentResponse.data,
|
||||
amountText: cents(paymentResponse.data.amountCents),
|
||||
},
|
||||
successMessage: '微信支付已提交,请稍后查看订单状态',
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async completeTestPayment() {
|
||||
if (!this.data.payment || !this.data.payment.paymentId) {
|
||||
this.setData({ errorMessage: '请先创建测试支付单' })
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<view class="action-grid">
|
||||
<button loading="{{loading}}" bindtap="quote">报价</button>
|
||||
<button loading="{{loading}}" bindtap="reserve">预占</button>
|
||||
<button loading="{{loading}}" bindtap="createWechatPayment">微信支付</button>
|
||||
<button loading="{{loading}}" bindtap="createTestPayment">测试支付</button>
|
||||
<button loading="{{loading}}" bindtap="completeTestPayment">完成测试支付</button>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user