fix: 云闪付控件唤不起修复——upsdk.js 改为 main.js 挂载前 document-start 预热注入(HBuilderX 构建不吃根 index.html 静态标签),确认订单页轮询复用预热标签防重复加载
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
9f02144df7
commit
6bc9b2c0d7
@@ -22,6 +22,19 @@ export const VOUCHER_USE_FLOW = [
|
||||
'支付差额可选:油卡 / 现金等'
|
||||
]
|
||||
|
||||
// xuchao: 云闪付 SDK 前置预热注入。HBuilderX 的 H5 构建不吃项目根 index.html(静态标签会被丢),
|
||||
// 只能在 main.js 最早期(document-start、App 挂载前)动态注入,逼近 xghmall 的 head 静态加载时机,
|
||||
// 让云闪付原生控件桥在首屏就注册,避免到确认订单页才注入导致 upsdk.pay 唤不起。
|
||||
// 与 orderConfirm 页的 loadUpSdk 共用同一 script[data-upsdk] 标记,全局只注入一次。
|
||||
export function injectUpSdk() {
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') return
|
||||
if (window.upsdk || document.querySelector('script[data-upsdk]')) return
|
||||
const s = document.createElement('script')
|
||||
s.src = 'https://open.95516.com/s/open/js/upsdk.js'
|
||||
s.setAttribute('data-upsdk', '1')
|
||||
document.head.appendChild(s)
|
||||
}
|
||||
|
||||
// xuchao: 云闪付容器判定只看 UA——不能掺 window.upsdk 是否已加载(SDK 是异步注入的,
|
||||
// 首屏点击时可能还没 load 完,会把云闪付内首点误判为站外)。UA 关键字真机实测后定稿。
|
||||
export function isUnionPayApp() {
|
||||
|
||||
Reference in New Issue
Block a user