新用户空态: pregnancy 未建档返回 empty(不再默认今天+3个月); 样例信只对已完善资料用户播种; 前端 pregEmpty 引导占位 (v26090710)
This commit is contained in:
53
js/app.js
53
js/app.js
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user