产后改回孕期 (v26103101):孕期档案保存未来预产期后,「宝宝已出生」卡立即消失、本机阶段键改回孕期、整页重载

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-10-31 10:49:30 +00:00
parent dcc8dc3b30
commit d65c5512e9
3 changed files with 26 additions and 6 deletions

View File

@@ -3,7 +3,7 @@
(function () {
'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26102502';
var VER = '26103101';
const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
@@ -1998,7 +1998,9 @@
};
/* 预产期没改就不传:表单可能是几分钟前回填的,别的应用这期间改过的话会被旧值盖回去 */
var _due = due ? toISO(due) : '';
if (_due !== filledDue || _wasEmpty) body.dueDate = _due;
/* 2026-10-31:登记过出生的人在这里保存孕周 = 回到孕期 → 预产期没改也要传,后台据此把账号翻回孕期 */
var _wasPost = !!state.postpartum;
if (_due !== filledDue || _wasEmpty || (_wasPost && _due)) body.dueDate = _due;
if (!_unauth) body.userName = name;
if (avatarUrl && !_unauth) body.avatar = avatarUrl;
fetch('/api/mp/public/mama-box/profile?openid=' + encodeURIComponent(_oid), {
@@ -2017,8 +2019,11 @@
setBusy(false);
if (avatarUrl && !_unauth) { syncSharedAvatar(avatarUrl); pickedAvatar = ''; }
applyLocal(_unauth ? '' : avatarUrl);
/* 新用户首次完善资料:重载页面 → pregnancy 出真实孕周 */
if (_wasEmpty) setTimeout(bustReload, 700);
/* birth-flow.js 听这个事件:回到孕期时把本机「已出生」阶段改回孕期,并重读首页卡片 */
try { window.dispatchEvent(new CustomEvent('mmbox:profile-saved', { detail: { dueDate: body.dueDate || '', wasPostpartum: _wasPost } })); } catch (e) {}
/* 新用户首次完善资料 / 产后改回孕期:重载页面 → pregnancy 出真实孕周(首页 hero、「宝宝已出生」卡一起换掉) */
var _back = _wasPost && body.dueDate && body.dueDate >= toISO(new Date()); /* 预产期在未来才算回到孕期(和后台同一条规则) */
if (_wasEmpty || _back) setTimeout(bustReload, 700);
}).catch(function () { fail(); });
}
setBusy(true);