feat:付款码全链路诊断化(?vc=1 弹窗显示卡点),接线 vconsole

- onPayCode 每步落诊断点:UA/SDK加载/桥就绪耗时/loginWay/qrCodePay异常
- 调试模式(?vc=1)卡点用弹窗展示完整诊断;普通用户仍是运营口径轻提示,行为不变
- main.js 接线 vconsole(URL 带 ?vc=1 启用,可看 console/网络/存储)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-10-27 15:10:32 +08:00
co-authored by Claude Fable 5
parent 2b57392ce0
commit bda2639d78
2 changed files with 35 additions and 9 deletions
+6
View File
@@ -5,6 +5,12 @@ import { injectUpSdk } from '@/common/petrolVoucher.js'
// 在 App 挂载前(document-start 最早 JS 点)注入,逼近静态 head 加载时机(石油券支付修复)
injectUpSdk()
// xuchao: 真机调试开关——URL 带 ?vc=1 时加载 vconsole,可看 console/网络/存储;
// 普通用户链接无此参数,零影响
if (typeof window !== 'undefined' && /[?&#]vc=1/.test(window.location.href || '')) {
import('vconsole').then(m => { const V = m.default || m.VConsole; if (V) new V() }).catch(() => {})
}
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
+29 -9
View File
@@ -148,26 +148,46 @@
// xuchao: 付款码——对齐 ysf 项目首页做法:upsdk.qrCodePay() 由云闪付容器原生拉起付款码,无 web 跳转。
// SDK 加载复用加油页验证过的注入模式;拉不起的场景(非容器/加载失败/非免密登录)统一弹 payGuide
onPayCode() {
// xuchao: 付款码诊断版——每步落诊断点;?vc=1 时卡点用弹窗展示完整诊断,普通用户仍是轻提示
const diag = []
const t0 = Date.now()
const dbg = /[?&#]vc=1/.test(typeof window !== 'undefined' ? window.location.href : '')
diag.push('UA=' + String(navigator.userAgent || '').slice(0, 90))
const fail = (why) => {
diag.push('结果=' + why + ' 耗时' + (Date.now() - t0) + 'ms')
console.warn('[paycode]', diag.join(' | '))
if (dbg) {
uni.showModal({ title: '付款码诊断', content: diag.join('\n'), showCancel: false, confirmText: '关闭' })
} else {
this.payGuide()
}
}
this.loadUpSdk().then(ready => {
if (!ready) { this.payGuide(); return }
diag.push('upsdk加载=' + ready)
if (!ready) { fail('SDK脚本未加载'); return }
diag.push('window.upsdk=' + typeof window.upsdk)
try {
// xuchao: 微信等普通浏览器里 upsdk 脚本能加载但桥永不就绪,pluginReady 回调不到;
// 3 秒无响应即判定非云闪付容器(容器内通常 <1s 已拉起付款码)
let bridged = false
const timer = setTimeout(() => { if (!bridged) this.payGuide() }, 3000)
const timer = setTimeout(() => { if (!bridged) fail('桥未就绪(3s超时,非云闪付容器)') }, 3000)
window.upsdk.pluginReady(() => {
bridged = true
clearTimeout(timer)
diag.push('pluginReady=ok')
// xuchao: 付款码依赖云闪付账号与社保卡的绑定关系——只对免密登录(ysf)会话开放;
// 验证码登录/未登录时容器钱包账号与本活动身份可能不一致,提示而不是拉起
if (uni.getStorageSync('loginWay') !== 'ysf') { this.payGuide(); return }
try { window.upsdk.qrCodePay() }
catch (e) { uni.showToast({ title: '拉起付款码失败,请重试', icon: 'none' }) }
const way = uni.getStorageSync('loginWay') || '(空)'
diag.push('loginWay=' + way)
if (way !== 'ysf') { fail('非免密会话:' + way); return }
try {
window.upsdk.qrCodePay()
diag.push('qrCodePay=已调用')
console.warn('[paycode]', diag.join(' | '))
} catch (e) { fail('qrCodePay异常:' + (e && e.message || e)) }
})
} catch (e) {
uni.showToast({ title: '拉起付款码失败,请重试', icon: 'none' })
}
})
} catch (e) { fail('pluginReady异常:' + (e && e.message || e)) }
}).catch(e => fail('loadUpSdk异常:' + (e && e.message || e)))
},
// xuchao: 付款码不可用时的统一提示(运营定稿文案;按反馈改为轻提示两行显示,不用确认弹窗)
payGuide() {