hashParam 同时读 hash+query: 修复浏览器直访(?openid=)读不到身份导致整页停在演示默认值 (v26090712)
This commit is contained in:
10
index.html
10
index.html
@@ -6,8 +6,8 @@
|
||||
<meta name="theme-color" content="#F4593C">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>妈妈盒子 · 孕育陪伴</title>
|
||||
<!-- V:26090711 缓存版本标记:改 css/js 时同步 bump 该值,并给下方资源引用加 ?v= 以强制 webview 刷新子资源 -->
|
||||
<link rel="stylesheet" href="mama-box.css?v=26090711">
|
||||
<!-- V:26090712 缓存版本标记:改 css/js 时同步 bump 该值,并给下方资源引用加 ?v= 以强制 webview 刷新子资源 -->
|
||||
<link rel="stylesheet" href="mama-box.css?v=26090712">
|
||||
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -1758,8 +1758,8 @@
|
||||
加载失败/离线时 window.wx 为 undefined,goMall() 会降级为 toast 提示,
|
||||
不影响应用其余功能。 -->
|
||||
|
||||
<script src="js/app.js?v=26090711"></script>
|
||||
<!-- 页面版本号(排查 webview 缓存):底部会显示 v26090711 -->
|
||||
<div id="ver" style="position:fixed;left:0;right:0;bottom:10px;text-align:center;z-index:9999;pointer-events:none;color:#B3A69C;font-size:10px;letter-spacing:.5px">v26090711</div>
|
||||
<script src="js/app.js?v=26090712"></script>
|
||||
<!-- 页面版本号(排查 webview 缓存):底部会显示 v26090712 -->
|
||||
<div id="ver" style="position:fixed;left:0;right:0;bottom:10px;text-align:center;z-index:9999;pointer-events:none;color:#B3A69C;font-size:10px;letter-spacing:.5px">v26090712</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user