fix:修复订单列表页面订单待支付状态下点击支付异常的问题
This commit is contained in:
+44
-11
@@ -115,8 +115,12 @@
|
||||
queryById,
|
||||
getOrderByOrderNoScorePayStatus,
|
||||
cancelOrder,
|
||||
confirmPaymentAndRent
|
||||
confirmPaymentAndRent,
|
||||
updateUserBalance
|
||||
} from '../../config/user.js';
|
||||
import {
|
||||
URL
|
||||
} from '../../config/url.js';
|
||||
|
||||
// 初始化状态
|
||||
const currentTab = ref(0);
|
||||
@@ -312,19 +316,48 @@
|
||||
title: '处理中'
|
||||
});
|
||||
|
||||
const res = await confirmPaymentAndRent(order.orderNo);
|
||||
if (res.code === 200) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success'
|
||||
});
|
||||
// 调用后端创建微信支付订单接口
|
||||
const res = await uni.request({
|
||||
url: `${URL || 'http://127.0.0.1:8080'}/app/wx-payment/create/${order.orderNo}`,
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Authorization': "Bearer " + uni.getStorageSync('token'),
|
||||
'Clientid': uni.getStorageSync('client_id')
|
||||
}
|
||||
});
|
||||
|
||||
if (res.statusCode === 200 && res.data.code === 200) {
|
||||
const payParams = res.data.data;
|
||||
|
||||
// 刷新订单列表
|
||||
await loadOrderList(orderStatusTabs[currentTab.value].status);
|
||||
// 调用微信支付
|
||||
await uni.requestPayment({
|
||||
...payParams,
|
||||
success: async () => {
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success'
|
||||
});
|
||||
|
||||
// 更新用户余额
|
||||
try {
|
||||
await updateUserBalance(order.orderId || order.orderNo);
|
||||
} catch (error) {
|
||||
console.warn('更新用户余额失败:', error);
|
||||
}
|
||||
|
||||
// 刷新订单列表
|
||||
await loadOrderList(orderStatusTabs[currentTab.value].status);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('支付失败:', err);
|
||||
throw new Error('支付失败,请重试');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new Error(res.msg || '支付失败');
|
||||
throw new Error(res.data.msg || '创建支付订单失败');
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
|
||||
Reference in New Issue
Block a user