This commit is contained in:
parent
65d0127291
commit
d90ee01d79
|
|
@ -22,6 +22,7 @@ export type OrderPayload = Record<string, unknown> & {
|
||||||
|
|
||||||
export type OrderResult = {
|
export type OrderResult = {
|
||||||
appId?: string
|
appId?: string
|
||||||
|
h5_url?: string
|
||||||
orderId?: string
|
orderId?: string
|
||||||
outTradeNo?: string
|
outTradeNo?: string
|
||||||
payFee?: string
|
payFee?: string
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,16 @@ function isIOSSafari() {
|
||||||
return isIOS && /Safari/.test(userAgent) && !/CriOS|FxiOS|EdgiOS|OPiOS/.test(userAgent)
|
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) {
|
function getSupportedPayMethods(goods?: GoodsItem) {
|
||||||
if (!goods?.pay_type) {
|
if (!goods?.pay_type) {
|
||||||
return []
|
return []
|
||||||
|
|
@ -414,6 +424,18 @@ function PayPage() {
|
||||||
return
|
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')
|
navigate('/pay-result?success=true')
|
||||||
} catch {
|
} catch {
|
||||||
alipayWindow?.close()
|
alipayWindow?.close()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue