From 67eaae0cebbd5ed3d100abcdad020a4571082764 Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Fri, 18 Sep 2026 19:36:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E6=8E=88=E6=9D=83=E5=9B=9E?= =?UTF-8?q?=E4=BC=A0=E8=90=BD=E7=82=B9=E5=86=99=E6=AD=BB=20MAMA=5FHOME=20+?= =?UTF-8?q?=20=E5=81=87=E6=88=90=E5=8A=9F=E5=88=A4=E6=8D=AE=20=E2=86=92=20?= =?UTF-8?q?=E5=AE=AB=E6=A0=BC=E5=BA=94=E7=94=A8=E6=8E=88=E6=9D=83=E6=AD=BB?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 首页壳 onShow consumeAuthResult:回传基址改为 shareHref(H5 发起授权前 reportLocation 上报的当前地址)|| webUrl || MAMA_HOME —— 此前写死 MAMA_HOME, 宫格 location.href 换应用后(webUrl 数据未变),授权结果被送回 mama-box, 目标应用(孕检日历等)永远收不到 phone,弹层复现 - 首页壳 else 分支的 ?t= 重载同样以 shareHref 为基址(不再把宫格应用用户踢回 mama-box) - 首页壳 submitAuth(原生面板)同步改用当前 H5 地址 - 授权页成功判据:提交了 code 时必须核对 result.phone 非空才写 __AUTH_RESULT__/ 提示成功 —— 配合 box_app 后端 400 如实报错(box_app commit e6b98e7) 需重新发版生效 --- pages/annex/auth/index.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pages/annex/auth/index.vue b/pages/annex/auth/index.vue index fde9a6e..2aa5dbe 100644 --- a/pages/annex/auth/index.vue +++ b/pages/annex/auth/index.vue @@ -141,9 +141,15 @@ url: api, method: 'POST', timeout: 10000, success: (r) => { const d = r.data || {}; - if (d.code === 200) { - const res = d.result || {}; - // 把授权结果写入 storage,web_view onShow 读取后刷新 H5 URL + const res = d.result || {}; + // ⚠️ 成功判据必须核对「手机号真的拿到了」:提交了 code 时, + // 后端解密失败(如 access_token 被商城后端挤掉)会如实返回 + // code!=200;旧版后端也可能 200 但 result.phone 为空。 + // 两种情况都不能写 __AUTH_RESULT__、不能提示成功 —— 否则 H5 + // 收到空 phone 的回传,闸门拦截,用户会陷入「授权成功却又 + // 要求授权」的死循环(2026-09-18 孕检日历实测)。 + const phoneMissing = !!this._authCode && !res.phone; + if (d.code === 200 && !phoneMissing) { uni.setStorageSync('__AUTH_RESULT__', { openid: openid, phone: res.phone || '', @@ -155,7 +161,7 @@ uni.navigateBack(); }, 600); } else { - uni.showToast({ title: d.message || '授权保存失败', icon: 'none' }); + uni.showToast({ title: (d.message || '授权保存失败,请稍后重试'), icon: 'none', duration: 3000 }); } }, fail: () => uni.showToast({ title: '授权请求失败,请检查网络', icon: 'none' })