feat(M08-A): 接入顾客端权益明细

This commit is contained in:
Codex
2026-06-25 12:04:55 +08:00
parent fb1b593b24
commit e24920c9cc
20 changed files with 661 additions and 38 deletions
+30
View File
@@ -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: '请先创建测试支付单' })