diff --git a/pages/annex/web_view/index.vue b/pages/annex/web_view/index.vue index 8a6e109..6d40aac 100644 --- a/pages/annex/web_view/index.vue +++ b/pages/annex/web_view/index.vue @@ -120,6 +120,24 @@ export default { this._initWebView(option); }, + onShow() { + // 登录返回后:页面仍在栈中,onLoad 不会再次触发 + // 检查是否有保存的 URL 和 token,重新处理身份 + if (this.savedUrl && store.state.app.token && !this.url) { + console.log('[web_view] onShow: 登录返回,重新处理 URL:', this.savedUrl.substring(0, 80)); + this.debugMsg = '[web_view] 登录返回...\n' + this.savedUrl.substring(0, 100); + const targetUrl = this.savedUrl; + const { openid, unionid } = getCurrentUser(); + const urlOpenid = getUrlParam(targetUrl, 'openid'); + if (openid) { + this._applyIdentity(targetUrl, openid, unionid, urlOpenid); + } else { + console.warn('[web_view] onShow: 仍无 openid,加载原始URL'); + this._finalizeUrl(targetUrl); + } + } + }, + methods: { /** * 太阳码 scene 解析:调 box_app /api/mp/apps 找 url,找到后注入到 option.url * 然后调用 _initWebView(option) 走标准 web_view 加载流程 @@ -229,24 +247,7 @@ export default { } catch (_) {} } }, - onShow() { - // 登录返回后:页面仍在栈中,onLoad 不会再次触发 - // 检查是否有保存的 URL 和 token,重新处理身份 - if (this.savedUrl && store.state.app.token && !this.url) { - console.log('[web_view] onShow: 登录返回,重新处理 URL:', this.savedUrl.substring(0, 80)); - this.debugMsg = '[web_view] 登录返回...\n' + this.savedUrl.substring(0, 100); - const targetUrl = this.savedUrl; - const { openid, unionid } = getCurrentUser(); - const urlOpenid = getUrlParam(targetUrl, 'openid'); - if (openid) { - this._applyIdentity(targetUrl, openid, unionid, urlOpenid); - } else { - console.warn('[web_view] onShow: 仍无 openid,加载原始URL'); - this._finalizeUrl(targetUrl); - } - } - }, - methods: { + _applyIdentity(targetUrl, openid, unionid, urlOpenid) { if (urlOpenid && urlOpenid !== openid) { targetUrl = stripAuthParams(targetUrl);