孕期小知识:首页四张卡去掉文字,改成图标+标题四个入口;点进详情页 #detailTips 看四张卡全文(滚到对应卡并高亮)(v26100131)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
50
js/app.js
50
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26100130';
|
||||
var VER = '26100131';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -3784,11 +3784,13 @@
|
||||
$('#ptWhen').textContent = '本周第 ' + (today + 1) + ' 天';
|
||||
$('#ptFloat').textContent = size.emoji;
|
||||
$('#ptBabyIco').textContent = size.emoji;
|
||||
/* 2026-10-01 用户反馈「四张小卡文字太多」:卡上只露一句重点,点开再看全文(全文存 data-full) */
|
||||
setTipCard('#ptBaby', '像' + size.name + '那么大', '像' + size.name + '那么大。' + (wk.baby || ''));
|
||||
setTipCard('#ptMom', tipGist(wk.mom), wk.mom);
|
||||
setTipCard('#ptEat', tipGist(wk.eat), wk.eat);
|
||||
setTipCard('#ptCare', tipGist(wk.care), wk.care);
|
||||
/* 四张卡全文只在详情页 #detailTips;首页那排入口只有图标 + 标题 */
|
||||
$('#ptBaby').textContent = '像' + size.name + '那么大。' + (wk.baby || '');
|
||||
$('#ptMom').textContent = wk.mom || '';
|
||||
$('#ptEat').textContent = wk.eat || '';
|
||||
$('#ptCare').textContent = wk.care || '';
|
||||
$('#ptChipBaby').textContent = size.emoji;
|
||||
$('#ptDtTitle').textContent = '孕 ' + state.week + ' 周 · 这一周';
|
||||
/* 一周 7 个圆点:以前可回看,今天实心,以后锁着 */
|
||||
const box = $('#ptDays');
|
||||
box.textContent = '';
|
||||
@@ -3826,31 +3828,21 @@
|
||||
const body = $('#ptBody');
|
||||
body.classList.remove('is-in'); void body.offsetWidth; body.classList.add('is-in'); // 重播进场动画
|
||||
}
|
||||
/* 一句重点 = 全文的第一个分句;太短(如「从这周末起」)就再带上下一句 */
|
||||
function tipGist(txt) {
|
||||
const parts = String(txt || '').split(/[,。;!]/).filter(Boolean);
|
||||
let g = parts[0] || '';
|
||||
if (g.length < 7 && parts[1]) g += ',' + parts[1];
|
||||
return g;
|
||||
/* 首页四个入口 → 详情页,滚到对应那张卡并闪一下 */
|
||||
function openTips(key) {
|
||||
openPanel('detailTips');
|
||||
const body = $('#detailTips .detail-body');
|
||||
body.scrollTop = 0;
|
||||
$('#ptGrid').classList.add('is-shown');
|
||||
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); // 等详情页滑入再滚
|
||||
}
|
||||
function setTipCard(sel, gist, full) {
|
||||
const p = $(sel);
|
||||
if (!p) return;
|
||||
p.dataset.gist = gist || '';
|
||||
p.dataset.full = full || '';
|
||||
const open = p.closest('.pt-card').classList.contains('is-open');
|
||||
p.textContent = open ? p.dataset.full : p.dataset.gist;
|
||||
}
|
||||
/* 四张小卡只露一句重点,点一下展开全文、再点收回一句 */
|
||||
(function () {
|
||||
const g = $('#ptGrid');
|
||||
if (g) g.addEventListener('click', e => {
|
||||
const c = e.target.closest('.pt-card');
|
||||
if (!c) return;
|
||||
const open = c.classList.toggle('is-open');
|
||||
const p = $('p', c);
|
||||
if (p && p.dataset.full) p.textContent = open ? p.dataset.full : p.dataset.gist;
|
||||
});
|
||||
const ch = $('#ptChips');
|
||||
if (ch) ch.addEventListener('click', e => { const b = e.target.closest('.pt-chip'); if (b) openTips(b.dataset.pt); });
|
||||
})();
|
||||
function revealTipsGrid() {
|
||||
const g = $('#ptGrid');
|
||||
|
||||
Reference in New Issue
Block a user