From bda2639d78f432db41418253bffeaae7f4a1eb26 Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Tue, 27 Oct 2026 15:10:32 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=BB=98=E6=AC=BE=E7=A0=81?= =?UTF-8?q?=E5=85=A8=E9=93=BE=E8=B7=AF=E8=AF=8A=E6=96=AD=E5=8C=96=EF=BC=88?= =?UTF-8?q?=3Fvc=3D1=20=E5=BC=B9=E7=AA=97=E6=98=BE=E7=A4=BA=E5=8D=A1?= =?UTF-8?q?=E7=82=B9=EF=BC=89=EF=BC=8C=E6=8E=A5=E7=BA=BF=20vconsole?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - onPayCode 每步落诊断点:UA/SDK加载/桥就绪耗时/loginWay/qrCodePay异常 - 调试模式(?vc=1)卡点用弹窗展示完整诊断;普通用户仍是运营口径轻提示,行为不变 - main.js 接线 vconsole(URL 带 ?vc=1 启用,可看 console/网络/存储) Co-Authored-By: Claude Fable 5 --- main.js | 6 ++++++ pages/shop/detail.vue | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index b8308bb..227f31a 100644 --- a/main.js +++ b/main.js @@ -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' diff --git a/pages/shop/detail.vue b/pages/shop/detail.vue index f5410b3..68a9a60 100644 --- a/pages/shop/detail.vue +++ b/pages/shop/detail.vue @@ -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() {