From 3b70f63dcefc1d0f1978d838ee056ed0b7a7e19b Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Mon, 21 Sep 2026 14:04:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=BA=AB=E4=BB=BD):=20bustReload=20?= =?UTF-8?q?=E9=87=8D=E8=BD=BD=E6=97=B6=E6=8B=BC=E5=9B=9E=20hash=20?= =?UTF-8?q?=E2=80=94=E2=80=94=20=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95/?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E5=AE=8C=E5=96=84=E8=B5=84=E6=96=99=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E4=B8=A2=E8=BA=AB=E4=BB=BD=E8=AF=AF=E6=8A=A5?= =?UTF-8?q?=E6=9C=AA=E8=8E=B7=E5=8F=96=E8=BA=AB=E4=BB=BD=20(v26092009)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- js/app.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index c661173..a49a778 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ 兜爸心选 · 孕育陪伴 - + diff --git a/js/app.js b/js/app.js index e997fa6..4a6f31e 100644 --- a/js/app.js +++ b/js/app.js @@ -3,7 +3,7 @@ (function () { 'use strict'; /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ - var VER = '26092008'; + var VER = '26092009'; const $ = (s, c) => (c || document).querySelector(s); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); @@ -738,11 +738,18 @@ ? '还没填预产期,孕周先锁着 —— 选好上面的预产期就会自动算出来。' : '已按预产期自动算出,觉得不准可以自己微调。'; } - /* 缓存戳重载:URL 已有 query 时必须用 & 拼接 —— 直接拼 '?t=' 会把 - 第二个 ? 吃进已有参数值里(?openid=abc001?t=123 → openid 变脏)。 */ + /* 缓存戳重载:只换查询串(?t=…),两处都不能丢: + ① URL 已有 query 时必须用 & 拼接 —— 直接拼 '?t=' 会把第二个 ? 吃进已有参数值里 + (?openid=abc001?t=123 → openid 变脏); + ② **hash 必须原样拼回去** —— openid/unionid 只活在 hash 里(宿主注入的形态是 + …/mama-box/#openid=…&unionid=…),丢掉 hash 再重载 = 把身份一起丢了 → + applyRemoteProfile 走访客分支:误报「未获取到微信身份」、孕周清空、 + 昵称/头像也拉不到(后端其实都保留着)。 + 调用它的两个场景都要求身份还在:① 退出授权登录(只翻授权状态,资料保留) + ② 新用户首次完善资料(重载后要按服务端孕周显示)。 */ function bustReload() { const b = location.href.split('#')[0]; - location.replace(b + (b.indexOf('?') >= 0 ? '&' : '?') + 't=' + Date.now()); + location.replace(b + (b.indexOf('?') >= 0 ? '&' : '?') + 't=' + Date.now() + location.hash); } /* state.due / week / day 在 fetch 返回前是内置默认 —— 不能在脚本加载时