fix(auth): 授权回传落点写死 MAMA_HOME + 假成功判据 → 宫格应用授权死循环
- 首页壳 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) 需重新发版生效
This commit is contained in:
@@ -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' })
|
||||
|
||||
Reference in New Issue
Block a user