From 97f32dfb11b064011dc31801dc085268a5c8eabe Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Tue, 8 Sep 2026 00:31:55 +0800 Subject: [PATCH] =?UTF-8?q?hashParam=20=E5=90=8C=E6=97=B6=E8=AF=BB=20hash+?= =?UTF-8?q?query:=20=E4=BF=AE=E5=A4=8D=E6=B5=8F=E8=A7=88=E5=99=A8=E7=9B=B4?= =?UTF-8?q?=E8=AE=BF(=3Fopenid=3D)=E8=AF=BB=E4=B8=8D=E5=88=B0=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E5=AF=BC=E8=87=B4=E6=95=B4=E9=A1=B5=E5=81=9C=E5=9C=A8?= =?UTF-8?q?=E6=BC=94=E7=A4=BA=E9=BB=98=E8=AE=A4=E5=80=BC=20(v26090712)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 10 +++++----- js/app.js | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 30f97ef..4659ab6 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,8 @@ 妈妈盒子 · 孕育陪伴 - - + + @@ -1758,8 +1758,8 @@ 加载失败/离线时 window.wx 为 undefined,goMall() 会降级为 toast 提示, 不影响应用其余功能。 --> - - -
v26090711
+ + +
v26090712
diff --git a/js/app.js b/js/app.js index cf1e2f6..4efdeb7 100644 --- a/js/app.js +++ b/js/app.js @@ -4035,11 +4035,14 @@ 打回白板。同样静默失败,不打断用户。 ⚠️ 竞态:fetch 异步,回来时 init() 已跑完,这里只需回刷那些读 state 的展示。 */ function hashParam(name) { + /* 同时读 hash 和 query:浏览器直访(?openid=x)只有 query; + 小程序 web-view 的授权回传在 hash(微信 webview 丢 query 不丢 hash)。 + ⚠️ 先在原始串上匹配、再对捕获值 decode —— 先 decode 整串会把 + %26 之类的编码提前还原成 &,破坏参数切分。 */ try { - const h = decodeURIComponent(location.hash.slice(1)); - /* openid 是首个参数时前面没有 &/#(如 "#openid=x"),[&#] 是"或",作可省处理 */ + const h = (location.hash.slice(1) || '') + '&' + (location.search.slice(1) || ''); const m = h.match(new RegExp('(?:^|[&#])' + name + '=([^&#]*)')); - return m ? m[1] : ''; + return m ? decodeURIComponent(m[1]) : ''; } catch (e) { return ''; } } let _profileApplied = false;