fix:修复订单列表页面订单待支付状态下点击支付异常的问题

This commit is contained in:
2025-07-08 15:19:32 +08:00
parent 893a2a55c6
commit 4851e0500d
8 changed files with 84 additions and 28 deletions
+34 -11
View File
@@ -2,6 +2,7 @@
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const config_user = require("../../config/user.js");
const config_url = require("../../config/url.js");
const _sfc_main = {
__name: "index",
setup(__props) {
@@ -88,7 +89,7 @@ const _sfc_main = {
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/index.vue:222", "获取订单详情失败:", error);
common_vendor.index.__f__("error", "at pages/order/index.vue:226", "获取订单详情失败:", error);
}
}
await loadOrderList();
@@ -122,7 +123,7 @@ const _sfc_main = {
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/index.vue:266", "获取订单列表失败:", error);
common_vendor.index.__f__("error", "at pages/order/index.vue:270", "获取订单列表失败:", error);
common_vendor.index.showToast({
title: "获取订单列表失败",
icon: "none"
@@ -130,7 +131,7 @@ const _sfc_main = {
}
};
const navigateToReturn = (deviceId, orderId) => {
common_vendor.index.__f__("log", "at pages/order/index.vue:295", orderId);
common_vendor.index.__f__("log", "at pages/order/index.vue:299", orderId);
common_vendor.index.navigateTo({
url: `/pages/return/index?deviceId=${deviceId}&orderId=${orderId}`
});
@@ -145,17 +146,39 @@ const _sfc_main = {
common_vendor.index.showLoading({
title: "处理中"
});
const res = await config_user.confirmPaymentAndRent(order.orderNo);
if (res.code === 200) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
title: "支付成功",
icon: "success"
const res = await common_vendor.index.request({
url: `${config_url.URL || "http://127.0.0.1:8080"}/app/wx-payment/create/${order.orderNo}`,
method: "GET",
header: {
"Authorization": "Bearer " + common_vendor.index.getStorageSync("token"),
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
if (res.statusCode === 200 && res.data.code === 200) {
const payParams = res.data.data;
await common_vendor.index.requestPayment({
...payParams,
success: async () => {
common_vendor.index.showToast({
title: "支付成功",
icon: "success"
});
try {
await config_user.updateUserBalance(order.orderId || order.orderNo);
} catch (error) {
common_vendor.index.__f__("warn", "at pages/order/index.vue:345", "更新用户余额失败:", error);
}
await loadOrderList(orderStatusTabs[currentTab.value].status);
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/order/index.vue:352", "支付失败:", err);
throw new Error("支付失败,请重试");
}
});
await loadOrderList(orderStatusTabs[currentTab.value].status);
} else {
throw new Error(res.msg || "支付失败");
throw new Error(res.data.msg || "创建支付订单失败");
}
common_vendor.index.hideLoading();
} catch (error) {
common_vendor.index.hideLoading();
common_vendor.index.showToast({