我的页:未授权/退出登录后显示「未登录」,点资料卡去授权;资料弹窗妈妈栏换授权提示 v26101007
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>兜爸心选 · 孕育陪伴</title>
|
||||
<!-- V:26101006 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<!-- V:26101007 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<link rel="stylesheet" href="mama-box.css">
|
||||
<link rel="stylesheet" href="night.css">
|
||||
<!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) -->
|
||||
@@ -2026,7 +2026,9 @@
|
||||
|
||||
<div class="pf-card">
|
||||
<div class="pf-ct">妈妈</div>
|
||||
<div class="pf-me">
|
||||
<!-- 2026-10-10 方案A:未授权(含退出登录后)不显示旧昵称/头像,换成授权提示;点它去授权。宝宝那栏不受影响 -->
|
||||
<button type="button" class="pf-unauth ripple" id="pfUnauth" style="display:none">授权登录后显示你的昵称和头像<b>去授权 ›</b></button>
|
||||
<div class="pf-me" id="pfMe">
|
||||
<div class="av-pick">
|
||||
<button class="av-big" id="avPick" aria-label="更换头像">
|
||||
<svg viewBox="0 0 40 40" aria-hidden="true">
|
||||
@@ -2047,7 +2049,7 @@
|
||||
</div>
|
||||
<label class="fld pf-fld"><span>怎么称呼你</span><input id="pfName" type="text" maxlength="16" placeholder="妈妈"></label>
|
||||
</div>
|
||||
<p class="pg-tip">点头像换张照片</p>
|
||||
<p class="pg-tip" id="pfMeTip">点头像换张照片</p>
|
||||
</div>
|
||||
|
||||
<!-- 2026-10-10 用户:「我的资料」里也要有「退出登录」。显示规则同「我的」页 #meLogoutCard(已授权才显示),共用 doLogout -->
|
||||
|
||||
41
js/app.js
41
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 只清「授权登录信息」三字段(昵称/头像/手机号),
|
||||
|
||||
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user