fix:微信支付
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 4m41s

This commit is contained in:
luo
2026-09-23 09:32:48 +08:00
parent a81b403cce
commit e82b0ab5da
12 changed files with 254 additions and 13 deletions

View File

@@ -238,11 +238,13 @@
handlePaymentError,
isValidAlipayPaymentLink,
isValidWechatPayConfig,
markPendingPaymentRefresh,
openAlipayPayment,
PAYMENT_REFRESH_TARGETS,
showPaymentToast,
wechatH5Pay
} from '@/utils/payment.js';
import { getPaymentErrorMessage, isUnknownPaymentResult } from '@/utils/payment-attempt.js';
import { formatMoney } from '@/utils/display.js';
import { getDefaultPaymentMethod, getPaymentMethodOptions, normalizePaymentMethods } from '@/utils/payment-methods.js';
@@ -683,9 +685,12 @@
uni.hideLoading();
console.error('充值失败', error);
showRechargeModal.value = false;
if (isUnknownPaymentResult(error)) {
markPendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.MY_WALLET);
}
setTimeout(() => {
uni.showToast({
title: error.msg || error.message || '充值失败,请稍后重试',
title: getPaymentErrorMessage(error, '充值失败,请稍后重试'),
icon: 'none'
});
}, 50);
@@ -744,8 +749,11 @@
} catch (error) {
uni.hideLoading();
console.error('获取支付配置失败', error);
if (isUnknownPaymentResult(error)) {
markPendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.MY_WALLET);
}
uni.showToast({
title: error.msg || error.message || '支付失败,请稍后重试',
title: getPaymentErrorMessage(error),
icon: 'none'
});
} finally {

View File

@@ -112,11 +112,13 @@
handlePaymentError,
isValidAlipayPaymentLink,
isValidWechatPayConfig,
markPendingPaymentRefresh,
openAlipayPayment,
PAYMENT_REFRESH_TARGETS,
showPaymentToast,
wechatH5Pay
} from '@/utils/payment.js';
import { getPaymentErrorMessage, isUnknownPaymentResult } from '@/utils/payment-attempt.js';
import { formatMoney } from '@/utils/display.js';
import { getDefaultPaymentMethod, getPaymentMethodOptions, normalizePaymentMethods } from '@/utils/payment-methods.js';
@@ -443,7 +445,13 @@
mask: true
});
const payResult = await orderApi.pay(orderResult.order.order_id, paymentMethod.value);
// Newer create responses already contain payment preparation data.
// Reuse it to keep one user submission to one payment-creation
// attempt; retain the pay endpoint fallback for older responses.
const payResult = hasPreparedPaymentData(orderResult) ||
(paymentMethod.value === 'wallet' && orderResult.order.payment_status === 2)
? orderResult
: await orderApi.pay(orderResult.order.order_id, paymentMethod.value);
uni.hideLoading();
showModal.value = false;
@@ -467,6 +475,9 @@
uni.hideLoading();
showModal.value = false;
console.error('创建订单或支付失败', error);
if (isUnknownPaymentResult(error)) {
markPendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.PACKAGE_ORDER);
}
if (error.code === 1008) {
uni.showModal({
@@ -483,7 +494,7 @@
}
uni.showToast({
title: error.msg || error.message || '操作失败,请稍后重试',
title: getPaymentErrorMessage(error, '操作失败,请稍后重试'),
icon: 'none'
});
} finally {