feat: 延期微信支付在微信内直接拉起
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 19m17s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 19m17s
- 微信支付下单带 app_type;拿到 pay_config 后与套餐购买一样拉起微信支付,继续支付同样处理 - 微信内打开时支付方式默认微信;取消支付保留同一请求号,再次确认不重复建单
This commit is contained in:
@@ -155,6 +155,7 @@
|
||||
));
|
||||
|
||||
const showToast = (title) => uni.showToast({ title, icon: 'none', duration: 2500 });
|
||||
const isInWechatBrowser = () => typeof navigator !== 'undefined' && /micromessenger/i.test(navigator.userAgent);
|
||||
|
||||
const loadEligibility = async () => {
|
||||
loading.value = true;
|
||||
@@ -166,7 +167,7 @@
|
||||
assetApi.getInfo(userStore.state.identifier).catch(() => null)
|
||||
]);
|
||||
eligibility.value = data;
|
||||
paymentOptions.value = getSilencePaymentOptions(info?.allowed_payment_methods);
|
||||
paymentOptions.value = getSilencePaymentOptions(info?.allowed_payment_methods, isInWechatBrowser());
|
||||
if (!paymentOptions.value.some((option) => option.value === paymentMethod.value)) {
|
||||
paymentMethod.value = paymentOptions.value[0]?.value || '';
|
||||
}
|
||||
@@ -248,15 +249,17 @@
|
||||
request_id: requestIds.get(days, paymentMethod.value)
|
||||
});
|
||||
lastOrderId.value = order?.id || 0;
|
||||
if (!order?.qr_content) {
|
||||
if (!order?.qr_content && !order?.pay_config) {
|
||||
showToast('订单已创建,请在"我的延期订单"中继续支付');
|
||||
openOrders();
|
||||
return;
|
||||
}
|
||||
await openSilencePayment(order, SILENCE_REFRESH_TARGET.EXTENSION);
|
||||
const result = await openSilencePayment(order, SILENCE_REFRESH_TARGET.EXTENSION);
|
||||
// 微信内直接支付完成:立即查订单结果(不经过支付页回跳)
|
||||
if (result?.paid) await checkLastOrder();
|
||||
} catch (error) {
|
||||
// 网络异常时后端可能已建单:保留 request_id,客户再次点击会拿到同一笔订单。
|
||||
if (!error?.paymentResultUnknown) requestIds.reset();
|
||||
// 网络异常时后端可能已建单、取消微信支付时订单仍待支付:保留 request_id,客户再次点击会拿到同一笔订单。
|
||||
if (!error?.paymentResultUnknown && !error?.cancelled) requestIds.reset();
|
||||
showToast(getSilenceErrorMessage(error, '下单失败,请稍后重试'));
|
||||
if (Number(error?.code) === 1271) await loadEligibility();
|
||||
} finally {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
];
|
||||
});
|
||||
|
||||
const canContinuePay = computed(() => order.value?.status === 'pending_payment' && !!order.value?.qr_content);
|
||||
const canContinuePay = computed(() => order.value?.status === 'pending_payment' && (!!order.value?.qr_content || !!order.value?.pay_config));
|
||||
const canCancel = computed(() => order.value?.status === 'pending_payment');
|
||||
const cancelling = ref(false);
|
||||
|
||||
@@ -91,7 +91,8 @@
|
||||
|
||||
const continuePay = async () => {
|
||||
try {
|
||||
await openSilencePayment(order.value, SILENCE_REFRESH_TARGET.ORDER_DETAIL);
|
||||
const result = await openSilencePayment(order.value, SILENCE_REFRESH_TARGET.ORDER_DETAIL);
|
||||
if (result?.paid) await load();
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error?.message || '拉起支付失败', icon: 'none' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user