首页撤下今日脚印;孕期小知识改为「其他妈妈也在搜」问题列表 v26103107
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
84
js/app.js
84
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26103106';
|
||||
var VER = '26103107';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -5022,46 +5022,16 @@
|
||||
if (!wk || !(wk.days || []).length) { sec.classList.add('hide'); return; }
|
||||
const today = Math.max(0, Math.min(6, state.day || 0));
|
||||
const size = babySize(w);
|
||||
$('#ptWk').textContent = '孕 ' + state.week + ' 周';
|
||||
/* 孕期专题入口:12 周起显示;20 周起肚子长得最快,换提醒文案。专题页自己按 openid 点亮对应阶段,链接带上身份 */
|
||||
const _tp = $('#ptTopic');
|
||||
if (_tp) {
|
||||
_tp.classList.toggle('hide', !(state.week >= 12));
|
||||
_tp.setAttribute('href', 'topic/wen/' + location.search + location.hash);
|
||||
const _td = $('#ptTopicD');
|
||||
if (_td) _td.textContent = state.week >= 20 ? '肚子长得最快的时候,该开始护理肚皮了' : '3 分钟看懂,从现在开始打底';
|
||||
}
|
||||
$('#ptWhen').textContent = '本周第 ' + (today + 1) + ' 天';
|
||||
/* 2026-10-12 用户:小知识里的 emoji 换成兜爸手绘图标库(/_bridge/hand-icons.js,小程序后台 375797cf 维护);
|
||||
图标按孕周从 handIcons.week() 取,SIZE 表只管文字;库没加载 / 图片挂了 → 退回原来的 emoji,位置不空 */
|
||||
const hw = window.handIcons && handIcons.week(w);
|
||||
setHandIco($('#ptFloat'), hw && hw.id, size.emoji);
|
||||
setHandIco($('#ptBabyIco'), hw && hw.id, size.emoji);
|
||||
/* 四张卡全文只在详情页 #detailTips;首页那排入口只有图标 + 标题 */
|
||||
$('#ptBaby').textContent = '像' + size.name + '那么大。' + (wk.baby || '');
|
||||
$('#ptMom').textContent = wk.mom || '';
|
||||
$('#ptEat').textContent = wk.eat || '';
|
||||
$('#ptCare').textContent = wk.care || '';
|
||||
setHandIco($('#ptChipBaby'), hw && hw.id, size.emoji);
|
||||
$('#ptDtTitle').textContent = '孕 ' + state.week + ' 周 · 这一周';
|
||||
/* 一周 7 个圆点:以前可回看,今天实心,以后锁着 */
|
||||
const box = $('#ptDays');
|
||||
box.textContent = '';
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const b = document.createElement('button');
|
||||
b.type = 'button';
|
||||
b.className = 'pt-day ' + (i < today ? 'is-past' : i === today ? 'is-today' : 'is-lock');
|
||||
b.setAttribute('role', 'tab');
|
||||
const n = document.createElement('i'); n.textContent = i + 1;
|
||||
const t = document.createElement('span');
|
||||
t.textContent = i === today ? '今天' : (i === today + 1 ? '明天' : '\u00a0'); // 圈里已是「第几天」,只给今天/明天配字
|
||||
b.appendChild(n); b.appendChild(t);
|
||||
b.addEventListener('click', () => {
|
||||
if (i > today) { toast(i === today + 1 ? '明天再来看新的小知识~' : '到那天再来看哦~'); return; }
|
||||
showTip(wk, i, today);
|
||||
});
|
||||
box.appendChild(b);
|
||||
}
|
||||
/* 详情页「本周每日小知识」:今天在上,往前倒着排到第 1 天;后面几天只露一行「明天见」 */
|
||||
const list = $('#ptList');
|
||||
list.textContent = '';
|
||||
@@ -5083,24 +5053,41 @@
|
||||
lk.textContent = '第 ' + (today + 2) + (today < 5 ? '–7' : '') + ' 天 · 明天见,每天解锁一条';
|
||||
list.appendChild(lk);
|
||||
}
|
||||
tipSel = -1;
|
||||
showTip(wk, today, today);
|
||||
renderSearch(wk, today, size);
|
||||
sec.classList.remove('hide');
|
||||
revealTipsGrid();
|
||||
}
|
||||
function showTip(wk, i, today) {
|
||||
if (i === tipSel) return;
|
||||
tipSel = i;
|
||||
const d = wk.days[i] || wk.days[0];
|
||||
$('#ptBadge').textContent = i === today ? '今日小知识' : '第 ' + (i + 1) + ' 天 · 回看';
|
||||
$('#ptT').textContent = d.t || '';
|
||||
$('#ptD').textContent = d.d || '';
|
||||
$$('#ptDays .pt-day').forEach((b, k) => {
|
||||
b.classList.toggle('is-sel', k === i);
|
||||
b.setAttribute('aria-selected', k === i ? 'true' : 'false');
|
||||
/* 2026-10-31 首页「其他妈妈也在搜」:6 条问题,全部有落点(专题页 / 小知识详情页),按孕周每周换 */
|
||||
function renderSearch(wk, today, size) {
|
||||
const W = state.week, L = $('#msList');
|
||||
if (!L) return;
|
||||
$('#msWk').textContent = '孕 ' + W + ' 周';
|
||||
$('#msCnt').textContent = '孕 ' + W + ' 周的妈妈都在看';
|
||||
const pool = AVA_TOP.concat(AVA_FEED), s0 = (W * 7) % pool.length;
|
||||
$('#msAvs').innerHTML = [0, 1, 2, 3, 4, 5, 6, 7].map(i => avaImg(pool[(s0 + i * 3) % pool.length])).join('');
|
||||
const q = t => /[??吗呢]$/.test(t) ? t : t + (/怎么办|什么|多少|怎么|几/.test(t) ? '?' : '');
|
||||
const items = [];
|
||||
if (W >= 12) items.push({ q: '妊娠纹怎么防?现在该抹什么', tag: '专题', cls: 'hot', href: 'topic/wen/' + location.search + location.hash });
|
||||
const d0 = wk.days[today];
|
||||
if (d0 && d0.t) items.push({ q: q(d0.t), tag: '今日', cls: 'new' });
|
||||
items.push({ q: '孕' + W + '周,宝宝长多大了?', tag: '热', cls: 'hot', pt: 'baby' });
|
||||
items.push({ q: '这周身体会有哪些变化?', pt: 'mom' });
|
||||
items.push({ q: '孕' + W + '周吃什么对宝宝好?', pt: 'eat' });
|
||||
items.push({ q: '这周产检和生活要留心什么?', pt: 'care' });
|
||||
const d1 = today > 0 && wk.days[today - 1];
|
||||
if (items.length < 6 && d1 && d1.t) items.push({ q: q(d1.t), tag: '昨天' });
|
||||
L.textContent = '';
|
||||
items.slice(0, 6).forEach((it, i) => {
|
||||
const el = document.createElement(it.href ? 'a' : 'button');
|
||||
el.className = 'ms-it ripple';
|
||||
if (it.href) el.href = it.href; else { el.type = 'button'; el.addEventListener('click', () => openTips(it.pt)); }
|
||||
const no = document.createElement('i'); no.className = 'ms-no'; no.textContent = i + 1;
|
||||
const t = document.createElement('span'); t.className = 'ms-q'; t.textContent = it.q;
|
||||
el.appendChild(no); el.appendChild(t);
|
||||
if (it.tag) { const g = document.createElement('span'); g.className = 'ms-tag' + (it.cls ? ' ' + it.cls : ''); g.textContent = it.tag; el.appendChild(g); }
|
||||
const go = document.createElement('i'); go.className = 'ms-go'; go.textContent = '›'; el.appendChild(go);
|
||||
L.appendChild(el);
|
||||
});
|
||||
const body = $('#ptBody');
|
||||
body.classList.remove('is-in'); void body.offsetWidth; body.classList.add('is-in'); // 重播进场动画
|
||||
}
|
||||
/* 首页四个入口 → 详情页,滚到对应那张卡并闪一下 */
|
||||
function openTips(key) {
|
||||
@@ -5114,13 +5101,6 @@
|
||||
c.classList.remove('is-hit'); void c.offsetWidth; c.classList.add('is-hit');
|
||||
}, 400); // 等详情页滑入再滚
|
||||
}
|
||||
(function () {
|
||||
const ch = $('#ptChips');
|
||||
if (ch) ch.addEventListener('click', e => { const b = e.target.closest('.pt-chip'); if (b) openTips(b.dataset.pt); });
|
||||
/* 首页今日小知识大卡也能点进详情页;底下 7 个圆点仍是切换回看,不跳页 */
|
||||
const td = $('#ptToday');
|
||||
if (td) td.addEventListener('click', e => { if (!e.target.closest('#ptDays')) openTips(); });
|
||||
})();
|
||||
function revealTipsGrid() {
|
||||
const g = $('#ptGrid');
|
||||
if (!g || g.classList.contains('is-shown')) return;
|
||||
|
||||
Reference in New Issue
Block a user