This commit is contained in:
zhangjianjun 2026-07-15 15:16:32 +08:00
parent 65d0127291
commit d90ee01d79
2 changed files with 23 additions and 0 deletions

View File

@ -22,6 +22,7 @@ export type OrderPayload = Record<string, unknown> & {
export type OrderResult = {
appId?: string
h5_url?: string
orderId?: string
outTradeNo?: string
payFee?: string

View File

@ -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()