refactor(web_view): 把 _resolveAppScene 和 _initWebView 移到 methods 块内
HBuilderX 编译错误"Unexpected token (350:0)"
根因:Vue 2 Options API 要求所有方法在 methods: { ... } 块内
之前把这两个方法放在 export default 顶层,违反规范
修复:把 _resolveAppScene 和 _initWebView 移到 methods 块开头
Node.js --check 验证:语法通过
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user