chore: 入库生产基线(2026-10-26 工作树快照)
- 含首页壳/容器页/授权页/分享图/首页配置等此前未入库的在途改动 - 新增未跟踪的 pages/index/mall.vue(第 5 个 tabBar 页,pages.json 已引用) - 排除本地备份文件(*.bak* / *.origin-bak) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -161,6 +161,11 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
/* 诊断日志(过滤关键字 enter-app):容器页每次被打开都会打这一行 ——
|
||||
它是「真的进入了某个 H5 应用」的最终证据(不管入口是恢复/分享/太阳码/商城宫格)。 */
|
||||
try {
|
||||
console.log('[enter-app] ===== 容器页 onLoad ===== option=' + JSON.stringify(option || {}));
|
||||
} catch (e) {}
|
||||
// 分享落地携带的推广人:与其它页面一致写进 globalData.spid(下单归因用)
|
||||
if (option && option.spid) {
|
||||
try { getApp().globalData.spid = option.spid; } catch (e) {}
|
||||
@@ -251,6 +256,9 @@ export default {
|
||||
this._applyShareImage(app.shareImageUrl, 'box', app.url);
|
||||
console.log('[web_view] 分享图片: ' + app.shareImageUrl);
|
||||
}
|
||||
// 同一响应里就有分享标题(后台「分享标题」,留空 = 应用名称)→ 直接落上,
|
||||
// 不必等反查表回来(太阳码是冷启动首发场景)
|
||||
this._applyShareTitleFromApp(app);
|
||||
let finalUrl = appUrl;
|
||||
if (option._channel) {
|
||||
const separator = finalUrl.includes('?') ? '&' : '?';
|
||||
@@ -446,6 +454,16 @@ export default {
|
||||
// #endif
|
||||
|
||||
this.url = targetUrl;
|
||||
console.log('[enter-app] ✅ 容器页开始加载 H5 应用: ' + targetUrl.split('#')[0]);
|
||||
|
||||
/* 宿主恢复:把「这次真正进入的 H5 应用」记到 box_app(/api/mp/public/last-app)。
|
||||
覆盖商城宫格 / 分享落地 / 朋友圈 / 太阳码 / JumpPath 这些**不经过 mama-box 宫格**
|
||||
的入口;经过 mama-box 宫格的由 H5 自己 sendBeacon 上报
|
||||
(见 mama-box js/app.js → reportLastApp)。冷启动恢复由 mama-box 首屏完成。
|
||||
⚠️ 只上报净地址(stripAuthParams):恢复时身份必须按**当前**用户重新注入。
|
||||
⚠️ 失败静默:这是旁路能力,绝不影响 H5 加载。 */
|
||||
this._reportLastApp(targetUrl);
|
||||
|
||||
try {
|
||||
const res = uni.getWindowInfo();
|
||||
this.windowW = res.windowWidth;
|
||||
@@ -458,6 +476,58 @@ export default {
|
||||
this._fetchShareImage(targetUrl);
|
||||
},
|
||||
|
||||
/* ---------- 宿主恢复:上报「本次进入的 H5 应用」(2026-09-22) ----------
|
||||
box_app /api/mp/public/last-app 是 Redis 里的 per-openid 记录(7 天 TTL),
|
||||
冷启动时由 mama-box 首屏读取并 location.replace 恢复(见 mama-box js/app.js resumeLastApp)。
|
||||
本页负责**非 mama-box 宫格**的入口:商城宫格 / 分享落地 / 朋友圈 / 太阳码 / JumpPath。
|
||||
⚠️ 传净地址:恢复时身份按当前用户重新注入,不能把记录时的 openid 带回去。
|
||||
⚠️ 失败静默:旁路能力,绝不影响 H5 加载。 */
|
||||
_reportLastApp(targetUrl) {
|
||||
try {
|
||||
const openid = getOpenid();
|
||||
if (!openid || !targetUrl) {
|
||||
console.log('[enter-app] ○ 容器页跳过 last-app 上报(openid=' + (openid ? '有' : '空') +
|
||||
', url=' + (targetUrl ? '有' : '空') + ')');
|
||||
return;
|
||||
}
|
||||
const clean = stripAuthParams(targetUrl);
|
||||
if (!clean) return;
|
||||
let api = 'https://mp.yizhezhe.com/api/mp/public/last-app?openid=' + encodeURIComponent(openid) +
|
||||
'&url=' + encodeURIComponent(clean);
|
||||
const id = this._lookupAppIdentifier(clean);
|
||||
if (id) api += '&identifier=' + encodeURIComponent(id);
|
||||
console.log('[enter-app] 容器页上报 last-app: url=' + clean + (id ? ' identifier=' + id : ''));
|
||||
uni.request({
|
||||
url: api,
|
||||
method: 'POST',
|
||||
timeout: 5000,
|
||||
success: (res) => {
|
||||
console.log('[enter-app] 容器页 last-app 上报结果: HTTP ' + ((res && res.statusCode) || '?') +
|
||||
' body=' + JSON.stringify(res && res.data));
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('[enter-app] ✗ 容器页 last-app 上报失败: ' + JSON.stringify(err));
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('[resume] 上报 last_app 失败(忽略):', e);
|
||||
}
|
||||
},
|
||||
/* 在内存应用表里按 URL 前缀反查 identifier(与 mixins/shareCard.js 的匹配同口径);
|
||||
表还没回来时返回空 —— identifier 是可选参数,服务端会按 URL 兜底校验。 */
|
||||
_lookupAppIdentifier(targetUrl) {
|
||||
const base = this._shareUrlBase(targetUrl);
|
||||
if (!base) return '';
|
||||
const apps = this.shareApps || [];
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
const a = apps[i];
|
||||
if (!a || !a.url || !a.identifier) continue;
|
||||
const ab = this._shareUrlBase(a.url);
|
||||
if (ab && (base === ab || base.indexOf(ab + '/') === 0)) return a.identifier;
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
/* 分享图反查 / 单应用缓存 / 朋友圈本地图转换,统一由 mixins/shareCard.js 提供:
|
||||
_fetchShareImage(targetUrl) —— 本页 onLoad 兜底(按当前 H5 URL 反查 box_app
|
||||
App.shareImageUrl;太阳码场景 _resolveAppScene 已直接设好)
|
||||
@@ -471,9 +541,11 @@ export default {
|
||||
// 含 H5 的 SPA 路由);this.shareHref(H5 postMessage)/ this.url(进入时的地址)
|
||||
// 都可能过期或落后,仅作兜底。
|
||||
const target = (options && options.webViewUrl) || this.shareHref || this.url;
|
||||
// 应用切换检测 + 按当前地址重新反查分享图(H5 postMessage 覆盖优先)
|
||||
// 应用切换检测 + 按当前地址重新反查分享图/标题(H5 postMessage 覆盖优先)
|
||||
this.resolveShareCard(target);
|
||||
return {
|
||||
// 标题来源优先级:H5 postMessage 上报 → box_app 反查(后台「分享标题」,留空 = 应用名称,
|
||||
// 由 resolveShareCard 写进 shareTitle)→ 兜底文案。
|
||||
title: this.shareTitle || '分享',
|
||||
// 分享出去必须剥离 openid/unionid/t 等身份参数:
|
||||
// 1) 避免把分享者的微信匿名标识泄露给接收者;
|
||||
@@ -483,12 +555,15 @@ export default {
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
// onShareTimeline 无回调参数,拿不到 webViewUrl,只能用 H5 传来的 href 兜底
|
||||
// onShareTimeline 无回调参数,拿不到 webViewUrl,只能用 H5 传来的 href 兜底。
|
||||
// 同一地址也解析一次:首次分享就走朋友圈时,标题/图不能还是空的。
|
||||
const target = this.shareHref || this.url;
|
||||
this.resolveShareCard(target);
|
||||
return {
|
||||
title: this.shareTitle || '分享',
|
||||
query: 'url=' + encodeURIComponent(stripAuthParams(this.shareHref || this.url)),
|
||||
query: 'url=' + encodeURIComponent(stripAuthParams(target)),
|
||||
// 朋友圈分享图必须是本地路径/代码包路径,网络图会被微信静默忽略;
|
||||
// 网络图已在 _prepareTimelineImage 中通过 getImageInfo 转成本地临时路径。
|
||||
// 网络图已在 _prepareTimelineImage 中通过 getImageInfo 转成临时路径。
|
||||
imageUrl: this.shareTimelineImage || ''
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user