diff --git a/index.html b/index.html index 4e4b358..30f97ef 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,8 @@ 妈妈盒子 · 孕育陪伴 - - + + @@ -1758,8 +1758,8 @@ 加载失败/离线时 window.wx 为 undefined,goMall() 会降级为 toast 提示, 不影响应用其余功能。 --> - - -
v26090710
+ + +
v26090711
diff --git a/js/app.js b/js/app.js index 2a5e0f0..cf1e2f6 100644 --- a/js/app.js +++ b/js/app.js @@ -1306,6 +1306,7 @@ } function renderLetterDetail(L) { + if (!L) return; /* 新用户空态:没有任何信件可渲染 */ $('#dlWeek').textContent = L.weekTxt; $('#dlTitle').textContent = L.title; $('#dlDate').textContent = L.dateFull; @@ -1989,6 +1990,7 @@ 若弹窗里新选了头像(avFile 有文件),先 POST /upload 换正式 URL 再一起提交; 上传失败则跳过头像字段(昵称/孕育照存)。断网/接口失败静默,本地已生效。 ---- */ var _oid = hashParam('openid'); + var _wasEmpty = state.pregEmpty; /* 新用户完善资料后 → 重载拉真实孕周+播种信 */ function _putProfile(avatarUrl) { if (!_oid) return; var body = { @@ -2005,6 +2007,9 @@ method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) + }).then(function () { + /* 新用户首次完善资料:重载页面 → pregnancy 出真实孕周、样例信播种 */ + if (_wasEmpty) setTimeout(function () { location.replace(location.href.split('#')[0] + '?t=' + Date.now()); }, 700); }).catch(function () { /* 保持本地值 */ }); } var newAvatarFile = (avFile.files && avFile.files[0]) || null; @@ -4165,7 +4170,18 @@ var base = '/api/mp/public/mama-box/'; var j = function (u) { return fetch(u).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; }); }; j(base + 'letters?openid=' + encodeURIComponent(openid)).then(function (lj) { - if (!lj || lj.code !== 200 || !lj.result || !lj.result.items || !lj.result.items.length) return; + if (!lj || lj.code !== 200 || !lj.result || !lj.result.items) return; + /* 新用户空态:后端成功返回空列表 → 清掉内置样例信,展示「这里还没有内容」。 + ⚠️ 不能直接 return —— 那会把 LETTERS 留在内置样例上,新用户看到演示信。 */ + if (!lj.result.items.length) { + LETTERS.splice(0, LETTERS.length); + state.curLetter = ''; + state.homeLetter = ''; + renderLetters(); + syncLetterCounts(); + pushLatestToHome(); + return; + } Promise.all(lj.result.items.map(function (it) { return j(base + 'letters/' + encodeURIComponent(it.key) + '?openid=' + encodeURIComponent(openid)); })).then(function (dets) {