fix: 云闪付控件唤不起修复——upsdk.js 改为 main.js 挂载前 document-start 预热注入(HBuilderX 构建不吃根 index.html 静态标签),确认订单页轮询复用预热标签防重复加载

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-09-28 14:26:14 +08:00
co-authored by Claude Fable 5
parent 9f02144df7
commit 6bc9b2c0d7
3 changed files with 28 additions and 0 deletions
+10
View File
@@ -95,6 +95,16 @@ export default {
const loading = new Promise(resolve => {
let done = false
const finish = v => { if (!done) { done = true; resolve(v) } }
const exists = document.querySelector('script[data-upsdk]')
if (exists) {
// main.js 已预热注入:轮询等 window.upsdk 出现(避免重复插标签)
const t0 = Date.now()
const timer = setInterval(() => {
if (window.upsdk) { clearInterval(timer); finish(true) }
else if (Date.now() - t0 > timeout) { clearInterval(timer); finish(false) }
}, 200)
return
}
const s = document.createElement('script')
s.src = 'https://open.95516.com/s/open/js/upsdk.js'
s.setAttribute('data-upsdk', '1')