新用户空态: pregnancy 未建档返回 empty(不再默认今天+3个月); 样例信只对已完善资料用户播种; 前端 pregEmpty 引导占位 (v26090710)

This commit is contained in:
2026-09-08 00:21:51 +08:00
parent 8289245dd1
commit e72feb9326
2 changed files with 55 additions and 8 deletions

View File

@@ -6,8 +6,8 @@
<meta name="theme-color" content="#F4593C">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>妈妈盒子 · 孕育陪伴</title>
<!-- V:26090709 缓存版本标记:改 css/js 时同步 bump 该值,并给下方资源引用加 ?v= 以强制 webview 刷新子资源 -->
<link rel="stylesheet" href="mama-box.css?v=26090709">
<!-- V:26090710 缓存版本标记:改 css/js 时同步 bump 该值,并给下方资源引用加 ?v= 以强制 webview 刷新子资源 -->
<link rel="stylesheet" href="mama-box.css?v=26090710">
<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=26090709"></script>
<!-- 页面版本号(排查 webview 缓存):底部会显示 v26090709 -->
<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">v26090709</div>
<script src="js/app.js?v=26090710"></script>
<!-- 页面版本号(排查 webview 缓存):底部会显示 v26090710 -->
<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">v26090710</div>
</body>
</html>

View File

@@ -1740,6 +1740,46 @@
/* 把 state 里的孕期信息刷到「我的」孕期卡 + 首页头部 + 档案页顶部 */
function syncPregnancy() {
/* ---- 新用户空态:未完善资料(无预产期)→ 全部显示引导占位,不读演示数据 ----
me 页已有两条引导(授权卡 + 孕期信息必填卡);这里把首页/档案页的
孕周数字换成引导文案,避免新用户看到"孕 27 周"这类假数据。 */
if (state.pregEmpty) {
const nm = state.babyName || '宝宝';
/* ① 我的 · 孕期卡 → 引导 */
$('#pcTitle').textContent = '待完善孕期信息';
$('#pcSub').textContent = '填好预产期,开启孕期陪伴';
$('#pcBar').style.setProperty('--p', '0%');
const rg = $('#pcRing');
if (rg) {
const C = 2 * Math.PI * parseFloat(rg.getAttribute('r'));
rg.setAttribute('stroke-dasharray', '0 ' + C.toFixed(2));
}
$$('.pc-stage span').forEach((s) => {
s.textContent = s.textContent.split(' · ')[0];
s.classList.remove('cur');
});
/* ② 首页 hero → 占位 */
$('#heroWeek').textContent = '--';
$('#heroPlus').textContent = '';
$('#heroDays').textContent = '--';
$('#heroWho').textContent = nm;
setRing($('#heroRing'), 0);
/* ③ 档案页 → 占位 */
$('#arTitleName').textContent = nm;
$('#arLine1').textContent = '完善孕期信息后开启';
$('#arDays').textContent = '--';
$('#arLine2').textContent = '先去「我的资料」填预产期';
$('#arPct').textContent = '0%';
setArBar(0);
$('#genWeekTag').textContent = '--';
/* ④ 信件/称呼:新用户无信(后端不播种),列表走 letterEmpty 空提示 */
$('#replyTo').textContent = nm;
syncBabyWords();
pushLatestToHome();
renderLetters();
renderLetterDetail(curLetter());
return;
}
const week = state.week, day = state.day, name = state.babyName;
const days = week * 7 + day; // 一起生活了多少天
const weekTxt = '孕 ' + week + ' 周' + (day ? ' +' + day + ' 天' : '');
@@ -4033,9 +4073,16 @@
if (!p.userName) { var _ai2 = $('#meAvatarImg'); if (_ai2) _ai2.removeAttribute('src'); }
}
if (pg && pg.code === 200 && pg.result) {
state.week = pg.result.week;
state.day = pg.result.day;
if (pg.result.due) { const d = parseDay(pg.result.due); if (d) state.due = d; }
/* 新用户空态(未完善资料):后端不再给默认孕周 → 显示引导占位,
不读任何演示数据(详见 syncPregnancy 的 pregEmpty 分支) */
if (pg.result.empty || pg.result.week == null) {
state.pregEmpty = true;
} else {
state.pregEmpty = false;
state.week = pg.result.week;
state.day = pg.result.day;
if (pg.result.due) { const d = parseDay(pg.result.due); if (d) state.due = d; }
}
}
// 统一回刷依赖这些 state 的展示
syncPregnancy();