From d90ee01d794aa267c9b79a3d0acb219da8a5848f Mon Sep 17 00:00:00 2001 From: zhangjianjun Date: Wed, 15 Jul 2026 15:16:32 +0800 Subject: [PATCH] ud --- src/api/pay.ts | 1 + src/pages/PayPage.tsx | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/api/pay.ts b/src/api/pay.ts index e463260..13b0798 100644 --- a/src/api/pay.ts +++ b/src/api/pay.ts @@ -22,6 +22,7 @@ export type OrderPayload = Record & { export type OrderResult = { appId?: string + h5_url?: string orderId?: string outTradeNo?: string payFee?: string diff --git a/src/pages/PayPage.tsx b/src/pages/PayPage.tsx index a4f57c3..48d25b1 100644 --- a/src/pages/PayPage.tsx +++ b/src/pages/PayPage.tsx @@ -126,6 +126,16 @@ function isIOSSafari() { return isIOS && /Safari/.test(userAgent) && !/CriOS|FxiOS|EdgiOS|OPiOS/.test(userAgent) } +function getWeixinH5PayUrl(h5Url: string) { + const payUrl = new URL(h5Url) + + if (!payUrl.searchParams.has('redirect_url')) { + payUrl.searchParams.set('redirect_url', window.location.href) + } + + return payUrl.toString() +} + function getSupportedPayMethods(goods?: GoodsItem) { if (!goods?.pay_type) { return [] @@ -414,6 +424,18 @@ function PayPage() { return } + if (selectedPayType === 'weixin') { + if (!data.orderId || !data.h5_url) { + window.alert('微信支付信息获取失败,请稍后重试') + throw new Error('Missing Weixin orderId or h5_url') + } + + savePendingPayment(data.orderId) + startOrderPolling(data.orderId) + window.location.assign(getWeixinH5PayUrl(data.h5_url)) + return + } + navigate('/pay-result?success=true') } catch { alipayWindow?.close()