孕期小知识恢复上一版:首页完整卡片(今日小知识+7天圆点+四张横滑卡+免责),撤掉详情页 #detailTips (v26100127)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
33
js/app.js
33
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26100126';
|
||||
var VER = '26100127';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -3788,14 +3788,6 @@
|
||||
$('#ptMom').textContent = wk.mom || '';
|
||||
$('#ptEat').textContent = wk.eat || '';
|
||||
$('#ptCare').textContent = wk.care || '';
|
||||
/* 首页只放核心:今天这条的标题 + 一行摘要(CSS 截一行),全文在详情页 */
|
||||
const td = wk.days[today] || wk.days[0];
|
||||
$('#ptMiniFloat').textContent = size.emoji;
|
||||
$('#ptMiniT').textContent = td.t || '';
|
||||
$('#ptMiniD').textContent = td.d || '';
|
||||
$('#ptChipBaby').textContent = size.emoji;
|
||||
$('#ptChipBabyT').textContent = '像' + size.name;
|
||||
$('#ptDtTitle').textContent = '孕 ' + state.week + ' 周 · 孕期小知识';
|
||||
/* 一周 7 个圆点:以前可回看,今天实心,以后锁着 */
|
||||
const box = $('#ptDays');
|
||||
box.textContent = '';
|
||||
@@ -3833,27 +3825,10 @@
|
||||
const body = $('#ptBody');
|
||||
body.classList.remove('is-in'); void body.offsetWidth; body.classList.add('is-in'); // 重播进场动画
|
||||
}
|
||||
/* 首页小卡 / 四个入口 → 详情页。入口带 data-pt,进去后滚到对应那张卡并闪一下。
|
||||
每次进来都回到今天那一条(上次可能停在回看的某天)。 */
|
||||
function openTips(key) {
|
||||
const wk = TIPS && TIPS[Math.max(4, Math.min(40, state.week || 0))];
|
||||
if (wk) showTip(wk, Math.max(0, Math.min(6, state.day || 0)), Math.max(0, Math.min(6, state.day || 0)));
|
||||
openPanel('detailTips');
|
||||
const body = $('#detailTips .detail-body');
|
||||
body.scrollTop = 0;
|
||||
const c = key && $('#ptGrid .pt-card[data-pt="' + key + '"]');
|
||||
if (c) setTimeout(() => {
|
||||
body.scrollTo({ top: c.offsetTop - 16, behavior: 'smooth' });
|
||||
c.classList.remove('is-hit'); void c.offsetWidth; c.classList.add('is-hit');
|
||||
}, 400); // 等详情页滑入(.38s)再滚
|
||||
}
|
||||
/* 四张小卡压成横滑后正文只露 3 行,点一下展开全文、再点收起 */
|
||||
(function () {
|
||||
const m = $('#ptMini'), ch = $('#ptChips');
|
||||
if (m) {
|
||||
m.addEventListener('click', () => openTips());
|
||||
m.addEventListener('keydown', e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openTips(); } });
|
||||
}
|
||||
if (ch) ch.addEventListener('click', e => { const b = e.target.closest('.pt-chip'); if (b) openTips(b.dataset.pt); });
|
||||
const g = $('#ptGrid');
|
||||
if (g) g.addEventListener('click', e => { const c = e.target.closest('.pt-card'); if (c) c.classList.toggle('is-open'); });
|
||||
})();
|
||||
function revealTipsGrid() {
|
||||
const g = $('#ptGrid');
|
||||
|
||||
Reference in New Issue
Block a user