diff --git a/pages/shop/detail.vue b/pages/shop/detail.vue index a0c6ded..d59f322 100644 --- a/pages/shop/detail.vue +++ b/pages/shop/detail.vue @@ -146,50 +146,21 @@ else uni.reLaunch({ url: '/pages/index/index' }) }, // xuchao: 付款码——对齐 ysf 项目首页做法:upsdk.qrCodePay() 由云闪付容器原生拉起付款码,无 web 跳转。 - // SDK 加载复用加油页验证过的注入模式;非云闪付环境(微信/普通浏览器)给使用引导。 + // SDK 加载复用加油页验证过的注入模式;拉不起的场景(非容器/加载失败/非免密登录)统一弹 payGuide onPayCode() { this.loadUpSdk().then(ready => { - if (!ready) { - uni.showModal({ - title: '请在云闪付App内使用', - content: '付款码需在云闪付App中打开本页面后使用:打开云闪付App → 搜索怀化社保卡活动进入 → 点击付款码。', - showCancel: false, - confirmText: '知道了' - }) - return - } + if (!ready) { this.payGuide(); return } try { // xuchao: 微信等普通浏览器里 upsdk 脚本能加载但桥永不就绪,pluginReady 回调不到; - // 3 秒无响应即判定非云闪付容器,给使用引导(容器内通常 <1s 已拉起付款码) + // 3 秒无响应即判定非云闪付容器(容器内通常 <1s 已拉起付款码) let bridged = false - const timer = setTimeout(() => { - if (!bridged) { - uni.showModal({ - title: '请在云闪付App内使用', - content: '付款码需在云闪付App中打开本页面后使用:打开云闪付App → 搜索怀化社保卡活动进入 → 点击付款码。', - showCancel: false, - confirmText: '知道了' - }) - } - }, 3000) + const timer = setTimeout(() => { if (!bridged) this.payGuide() }, 3000) window.upsdk.pluginReady(() => { bridged = true clearTimeout(timer) // xuchao: 付款码依赖云闪付账号与社保卡的绑定关系——只对免密登录(ysf)会话开放; // 验证码登录/未登录时容器钱包账号与本活动身份可能不一致,提示而不是拉起 - const way = uni.getStorageSync('loginWay') - if (way !== 'ysf') { - const logged = !!uni.getStorageSync('phone') - uni.showModal({ - title: '暂无法使用付款码', - content: logged - ? '当前为手机号验证码登录,付款码立减需通过云闪付App的活动入口进入(自动免密登录,与钱包账号一致)后使用。' - : '请在云闪付App中通过本活动入口进入页面(自动免密登录)后,再使用付款码享优惠。', - showCancel: false, - confirmText: '知道了' - }) - return - } + if (uni.getStorageSync('loginWay') !== 'ysf') { this.payGuide(); return } try { window.upsdk.qrCodePay() } catch (e) { uni.showToast({ title: '拉起付款码失败,请重试', icon: 'none' }) } }) @@ -198,6 +169,15 @@ } }) }, + // xuchao: 付款码不可用时的统一提示(文案为运营定稿) + payGuide() { + uni.showModal({ + title: '温馨提示', + content: '暂无法使用付款码,请登录云闪付 app 打开付款码进行使用。', + showCancel: false, + confirmText: '知道了' + }) + }, // xuchao: upsdk 运行时注入并返回就绪 Promise(与 petrol/orderConfirm 同一模式,全局只注入一次; // 不能依赖 index.html 静态标签——HBuilderX 构建的 H5 模板不吃根 index.html) loadUpSdk(timeout = 9000) {