From b4e80def9eda76356d27f776352461d1c8dd2e91 Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Sat, 10 Oct 2026 06:14:30 +0000 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E9=A1=B5=EF=BC=9A=E6=9C=AA?= =?UTF-8?q?=E6=8E=88=E6=9D=83/=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E6=98=BE=E7=A4=BA=E3=80=8C=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E3=80=8D=EF=BC=8C=E7=82=B9=E8=B5=84=E6=96=99=E5=8D=A1=E5=8E=BB?= =?UTF-8?q?=E6=8E=88=E6=9D=83=EF=BC=9B=E8=B5=84=E6=96=99=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E5=A6=88=E5=A6=88=E6=A0=8F=E6=8D=A2=E6=8E=88=E6=9D=83=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=20v26101007?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- index.html | 8 +++++--- js/app.js | 41 ++++++++++++++++++++++++++++++++--------- mama-box.css | 3 +++ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index e28d23d..dbfd860 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ 兜爸心选 · 孕育陪伴 - + @@ -2026,7 +2026,9 @@
妈妈
-
+ + +
-

点头像换张照片

+

点头像换张照片

diff --git a/js/app.js b/js/app.js index e4e4362..392b024 100644 --- a/js/app.js +++ b/js/app.js @@ -3,7 +3,7 @@ (function () { 'use strict'; /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ - var VER = '26101006'; + var VER = '26101007'; const $ = (s, c) => (c || document).querySelector(s); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); @@ -1138,6 +1138,10 @@ 新用户(未完善资料):昵称/小名/预产期/孕周全空 + 孕周锁定,只留 placeholder。 */ function fillProfileForm() { $('#pfName').value = state.userName || ''; + /* 方案A(2026-10-10):未授权 → 妈妈栏换成授权提示,旧昵称/头像不露出 */ + var _ua = state.authorized === false; + ['#pfMe', '#pfMeTip'].forEach(function (sel) { var el = $(sel); if (el) el.style.display = _ua ? 'none' : ''; }); + var _uh = $('#pfUnauth'); if (_uh) _uh.style.display = _ua ? '' : 'none'; pgName.value = state.babyName || ''; $$('#pgSex .pick').forEach(b => b.classList.toggle('is-active', (b.dataset.sex || 'unknown') === (state.babySex || 'unknown'))); if (state.postpartum) { @@ -1676,8 +1680,12 @@ /* ---- 妈妈那半(本地即时生效)---- 身份模型:卡片统一读档案;资料编辑的昵称/头像也是档案的一部分(最后写者胜)。 落库在下方 fetch(头像需先上传换 URL)。 */ - $('#meName').textContent = name; - state.userName = name; + /* 未授权时妈妈栏是隐藏的:不写昵称/头像,否则会把旧昵称重新存回去 */ + const _unauth = state.authorized === false; + if (!_unauth) { + $('#meName').textContent = name; + state.userName = name; + } /* ⚠️ 这里原来还有一行 state.userBio = bio 和一次 syncBio() 调用。 一句话签名整块已按用户要求删除(输入框 #pfBio、展示行 #meBio、 syncBio()、state.userBio 四处一起删),别只加回其中一处。 */ @@ -1699,10 +1707,10 @@ var body = { babyName: babyName, babySex: state.babySex, - dueDate: state.due ? toISO(state.due) : '', - userName: name + dueDate: state.due ? toISO(state.due) : '' }; - if (avatarUrl) { + if (!_unauth) body.userName = name; + if (avatarUrl && !_unauth) { body.avatar = avatarUrl; meAvatarImg.src = avatarUrl; /* 用正式 URL 替换 base64 预览 */ } @@ -3222,8 +3230,10 @@ if (p.dueDate) { const d = parseDay(p.dueDate); if (d) state.due = d; } /* 状态化「我的」页:未授权→占位+显示授权入口;已授权→资料+隐藏授权入口;已建档(B→C)由孕期信息卡引导 */ var _authorized = !!p.authorized || !!p.isAuthorized; - var _n = $('#meName'); if (_n) _n.textContent = p.userName || '未登录'; - if (p.avatar) { + state.authorized = _authorized; + /* 方案A:显示看 authorized 而不是 userName —— 后端退出只置 authorized=false,昵称/头像仍在库里 */ + var _n = $('#meName'); if (_n) _n.textContent = (_authorized && p.userName) || '未登录'; + if (p.avatar && _authorized) { var _ai = $('#meAvatarImg'), _aw = $('#meAvatar'); if (_ai) _ai.src = p.avatar; if (_aw) _aw.classList.add('has-img'); @@ -3231,7 +3241,11 @@ /* 授权入口:未授权时显示(引导先授权);退出按钮:已授权时显示 */ var _box = $('#meAuthBox'); if (_box) _box.style.display = _authorized ? 'none' : ''; ['#meLogoutCard', '#pfLogout'].forEach(function (sel) { var _lx = $(sel); if (_lx) _lx.style.display = _authorized ? '' : 'none'; }); - if (!p.userName) { var _ai2 = $('#meAvatarImg'); if (_ai2) _ai2.removeAttribute('src'); } + if (!p.userName || !_authorized) { + var _ai2 = $('#meAvatarImg'), _aw2 = $('#meAvatar'); + if (_ai2) _ai2.removeAttribute('src'); + if (_aw2) _aw2.classList.remove('has-img'); + } } if (pg && pg.code === 200 && pg.result) { if (pg.result.postpartum) { @@ -5406,6 +5420,15 @@ } var meAuth = $('#meAuthCard'); if (meAuth) meAuth.addEventListener('click', goAuth); + /* 方案A:未授权时点「我的」页顶部资料卡 → 直接去授权,不打开资料弹窗(捕获阶段拦在 data-modal 之前) */ + var meCard = $('.me-card'); + if (meCard) meCard.addEventListener('click', function (e) { + if (state.authorized !== false) return; + if (e.target.closest && e.target.closest('#meLogoutCard')) return; + e.preventDefault(); e.stopImmediatePropagation(); goAuth(); + }, true); + var pfUnauth = $('#pfUnauth'); + if (pfUnauth) pfUnauth.addEventListener('click', function () { closeModal(); goAuth(); }); /* 「退出登录」(个人资料卡右上角图标按钮): 调后端 /api/mp/public/auth/logout 只清「授权登录信息」三字段(昵称/头像/手机号), diff --git a/mama-box.css b/mama-box.css index b823819..17850c1 100644 --- a/mama-box.css +++ b/mama-box.css @@ -4734,3 +4734,6 @@ a.skip:focus{left:16px;top:16px} .wg-modal .wg-n{color:var(--brand)} .wg-modal .modal-foot{display:flex;gap:10px} .wg-modal .modal-foot .dl-btn{flex:1} +/* 2026-10-10 方案A:未授权时「我的资料」妈妈栏的授权提示 */ +.pf-unauth{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;margin-top:8px;padding:14px;border-radius:14px;background:#FFF6F1;font-size:14px;color:var(--ink-2);text-align:left} +.pf-unauth b{flex:none;font-size:13px;font-weight:700;color:var(--brand)}