cleanup(web_view): 隐藏调试浮层,清除 DEBUG 日志
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view>
|
||||
<!-- 调试浮层(debugMsg 有值时显示,点击关闭) -->
|
||||
<cover-view v-if="debugMsg" class="debug-overlay" @click="debugMsg=''">
|
||||
<cover-view v-if="false" class="debug-overlay" @click="debugMsg=''">
|
||||
<cover-view class="debug-text">{{ debugMsg }}</cover-view>
|
||||
</cover-view>
|
||||
<web-view v-if="url" class="web-view" :webview-styles="webviewStyles" :src="url"
|
||||
@@ -112,7 +112,6 @@ export default {
|
||||
console.log('[DEBUG 太阳码] option.scene:', option.scene);
|
||||
console.log('[DEBUG 太阳码] option.url:', option.url);
|
||||
// 显示在页面
|
||||
this.debugMsg = 'onLoad: scene=' + (option.scene || '(空)') + ' url=' + (option.url || '(空)');
|
||||
// 太阳码 scene 解析:scene="app=<identifier>" 时调 box_app 查 url
|
||||
// 例如 box_app /api/wxacode?app=pregnancy → scene="app=pregnancy"
|
||||
// CRMEB 收到后查 box_app /api/mp/apps?isPublished=1 找 url,跳对应 H5
|
||||
@@ -120,7 +119,6 @@ export default {
|
||||
const sceneRaw = decodeURIComponent(option.scene || option.wxscene || '');
|
||||
if (sceneRaw.indexOf('app=') === 0) {
|
||||
console.log('[DEBUG 太阳码] ✅ scene 匹配成功! 原始:', option.scene, '解码:', sceneRaw);
|
||||
this.debugMsg = 'scene 匹配成功: ' + sceneRaw + ' (原始: ' + (option.scene || option.wxscene) + ')';
|
||||
const source = sceneRaw;
|
||||
const identifier = source.slice(4);
|
||||
console.log('[web_view] 太阳码 scene 解析: identifier=' + identifier);
|
||||
@@ -136,7 +134,6 @@ export default {
|
||||
// 检查是否有保存的 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');
|
||||
@@ -173,7 +170,6 @@ export default {
|
||||
} else {
|
||||
// 解析失败:降级到 CRMEB 首页
|
||||
console.warn('[DEBUG 太阳码] 降级到 CRMEB 首页');
|
||||
this.debugMsg = '⚠️ 降级: 未找到 H5 URL,跳转 CRMEB 首页';
|
||||
option.url = encodeURIComponent('https://shop.douba.top');
|
||||
}
|
||||
} else {
|
||||
@@ -195,7 +191,6 @@ export default {
|
||||
try {
|
||||
let targetUrl = decodeURIComponent(option.url);
|
||||
console.log('[web_view] 原始URL:', targetUrl);
|
||||
this.debugMsg = '[web_view] 加载中...\nurl=' + targetUrl.substring(0, 100);
|
||||
|
||||
console.log('[DEBUG 太阳码] 检查可信域...');
|
||||
console.log('[DEBUG 太阳码] targetUrl:', targetUrl);
|
||||
@@ -204,7 +199,6 @@ export default {
|
||||
(TRUSTED_DOMAINS || []).some(d => targetUrl.indexOf(d) === 0);
|
||||
|
||||
console.log('[DEBUG 太阳码] 可信域:', isTrustedDomain);
|
||||
this.debugMsg = '可信域=' + isTrustedDomain + ' url=' + targetUrl.substring(0, 50);
|
||||
if (isTrustedDomain) {
|
||||
const token = store.state.app.token;
|
||||
if (token) {
|
||||
@@ -216,26 +210,21 @@ export default {
|
||||
', myOpenid=' + (openid || '(空)') +
|
||||
', urlOpenid=' + (urlOpenid || '(空)') +
|
||||
', url=' + targetUrl.substring(0, 80);
|
||||
this.debugMsg = info;
|
||||
if (openid && urlOpenid && urlOpenid !== openid) this.debugMsg += '→ 身份不一致,将替换';
|
||||
|
||||
if (!openid) {
|
||||
// 获取不到身份信息,用 setTimeout 重试
|
||||
console.warn('[web_view] 首次获取 openid 为空,延迟重试', info);
|
||||
this.debugMsg = info + '\n→ 等待重试...';
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const retry = getCurrentUser();
|
||||
console.log('[web_view] 重试后 openid=' + (retry.openid || '(空)'));
|
||||
this.debugMsg = info + '\n→ 重试后 openid=' + (retry.openid || '(空)');
|
||||
if (retry.openid) {
|
||||
this._applyIdentity(targetUrl, retry.openid, retry.unionid, urlOpenid);
|
||||
} else {
|
||||
this.debugMsg = info + '\n→ 重试仍失败,直接加载原始URL';
|
||||
this.url = targetUrl;
|
||||
}
|
||||
} catch (e) {
|
||||
this.debugMsg = '重试异常: ' + e.message;
|
||||
this.url = targetUrl;
|
||||
}
|
||||
}, 500);
|
||||
@@ -257,7 +246,6 @@ export default {
|
||||
this._finalizeUrl(targetUrl);
|
||||
} catch (e) {
|
||||
console.error('[web_view] onLoad 异常:', e);
|
||||
this.debugMsg = 'onLoad异常: ' + e.message + '\n' + e.stack;
|
||||
// 异常时直接加载原始 URL
|
||||
try {
|
||||
this.url = decodeURIComponent(option.url);
|
||||
@@ -291,7 +279,6 @@ export default {
|
||||
_finalizeUrl(targetUrl) {
|
||||
console.log('[DEBUG 太阳码] _finalizeUrl 设置 this.url');
|
||||
console.log('[DEBUG 太阳码] 最终 URL:', targetUrl.substring(0, 100));
|
||||
this.debugMsg = '✅ 最终 URL: ' + targetUrl.substring(0, 80);
|
||||
console.log('[web_view] 最终URL:', targetUrl);
|
||||
try {
|
||||
const qIdx = targetUrl.indexOf('?');
|
||||
|
||||
Reference in New Issue
Block a user