feat(此刻): 收进孕育工具卡底部做轻量条,删「她们在聊」和全站今日三项 (v26100109)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
66
js/app.js
66
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26100108';
|
||||
var VER = '26100109';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -3105,7 +3105,8 @@
|
||||
· 今日三项可点:kick / weight 复用首页工具卡的跳转(MINI_APP_MAP),game 去消消乐。
|
||||
· 2026-10-01 A+B 改版:已建档时带 ?week= 拉,接口多给 peer → 卡片换成「和你一样孕 N 周的妈妈们」:
|
||||
同周人数 + 她们今天在做(百分比条,右侧对比「你今天还没数 ›」可直达)+ 今天别忘了(产检倒数 / 本周盲盒)
|
||||
+ 她们在聊(气泡)+ 同周动态。此时全站统计两块让位。无 peer(访客 / real 模式)→ 原版式。 */
|
||||
+ 同周动态。无 peer(访客 / real 模式)→ 一行总人数 + 动态。
|
||||
· 同日再改:收进孕育工具卡底部做轻量条,删「她们在聊」和全站「今日三项」小卡(见 index.html #pulse 注释)。 */
|
||||
const PULSE_ICO = {
|
||||
kick: '<svg viewBox="0 0 24 24"><ellipse cx="10" cy="15" rx="5" ry="6.5" fill="currentColor"/><circle cx="16.5" cy="6" r="2" fill="currentColor"/><circle cx="12.5" cy="4.6" r="1.6" fill="currentColor"/><circle cx="19.4" cy="9.6" r="1.6" fill="currentColor"/></svg>',
|
||||
weight: '<svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="5" fill="none" stroke="currentColor" stroke-width="2.2"/><path d="M8 10a4 4 0 018 0z" fill="currentColor"/><path d="M12 10l1.6-2.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
|
||||
@@ -3157,7 +3158,7 @@
|
||||
(function pulseCard() {
|
||||
const sec = $('#pulse');
|
||||
if (!sec) return;
|
||||
let seen = false, last = null, feed = [], fi = 0, ticking = null, peerMode = false, loadedWk = null;
|
||||
let seen = false, last = null, feed = [], fi = 0, ticking = null, peerMode = false, loadedWk = null, shownN = 0;
|
||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
||||
const tapMini = k => { const b = $('.mini-card[data-mini="' + k + '"]'); if (b) b.click(); };
|
||||
const TODAY_GO = {
|
||||
@@ -3183,7 +3184,7 @@
|
||||
const t = midnight(new Date()), d = new Date(t.getFullYear(), +m[1] - 1, +m[2]);
|
||||
if (d < t - 86400000 * 60) d.setFullYear(d.getFullYear() + 1);
|
||||
const n = Math.round((d - t) / 86400000);
|
||||
if (n >= 0 && n <= 14) out.push({ k: 'cal', t: n === 0 ? '今天产检' : n === 1 ? '明天产检' : '距下次产检 <b>' + n + '</b> 天' });
|
||||
if (n >= 0 && n <= 14) out.push({ k: 'cal', t: n === 0 ? '今天产检' : n === 1 ? '明天产检' : '产检还有 <b>' + n + '</b> 天' });
|
||||
}
|
||||
}
|
||||
if (BB && BB.enabled && !BB.notYet && !BB.needProfile && !BB.ended) {
|
||||
@@ -3214,28 +3215,29 @@
|
||||
tr.style.transform = '';
|
||||
}, 600);
|
||||
}
|
||||
function paintPeer(p) {
|
||||
$('#plTitle').textContent = '和你一样孕 ' + p.week + ' 周的妈妈们';
|
||||
/* 头像叠:同周版按孕周换一组,全站版固定一组;只在换组时重画 */
|
||||
function paintAvs(seed) {
|
||||
const avs = $('#ppAvs');
|
||||
if (!avs.firstChild) avs.innerHTML = [3, 11, 7, 14, 1].map(x => '<i>' + momAva(x + p.week) + '</i>').join('');
|
||||
if (seen) tweenNum($('#ppCount'), p.count, 1600);
|
||||
$('#ppDue').textContent = state.due ? '宝宝们都会在 ' + (state.due.getMonth() + 1) + ' 月前后出生' : '';
|
||||
if (avs.dataset.seed === String(seed)) return;
|
||||
avs.dataset.seed = seed;
|
||||
avs.innerHTML = [3, 11, 7].map(x => '<i>' + momAva(x + seed) + '</i>').join('');
|
||||
}
|
||||
function paintPeer(p) {
|
||||
paintAvs(p.week);
|
||||
$('#plTitle').innerHTML = '<b data-n="' + p.count + '">0</b> 位孕 ' + p.week + ' 周妈妈和你同一周';
|
||||
$('#ppDoing').innerHTML = (p.doing || []).map(d => {
|
||||
const me = SELF_TXT[d.key] ? selfDone(d.key) : null;
|
||||
const meH = me == null ? '' : me
|
||||
? '<span class="pp-me ok">' + SELF_TXT[d.key][1] + ' ✓</span>'
|
||||
: '<button class="pp-me todo" type="button" data-go="' + d.key + '">' + SELF_TXT[d.key][0] + ' ›</button>';
|
||||
return '<div class="pp-do k-' + esc(d.key) + '"><div class="pp-dl"><span class="pp-dt">她们 <b>' + (+d.pct || 0) + '%</b> ' +
|
||||
esc(d.label) + '</span>' + meH + '</div><div class="pp-bar"><i style="width:' + Math.min(100, +d.pct || 0) + '%"></i></div></div>';
|
||||
return '<div class="pp-do k-' + esc(d.key) + '"><span class="pp-dt">她们 <b>' + (+d.pct || 0) + '%</b> ' + esc(d.label) + '</span>' +
|
||||
'<span class="pp-bar"><i style="width:' + Math.min(100, +d.pct || 0) + '%"></i></span>' + meH + '</div>';
|
||||
}).join('');
|
||||
$('#ppDoing').classList.toggle('hide', !(p.doing || []).length);
|
||||
const td = todos();
|
||||
$('#plTodo').classList.toggle('hide', !td.length);
|
||||
$('#plTodoList').innerHTML = td.map(x => '<button class="tdo-chip' + (x.hot ? ' hot' : '') + '" type="button" data-go="' + x.k + '">' +
|
||||
pulseIco(x.k, 'tdo-ico') + '<span>' + x.t + '</span><i>›</i></button>').join('');
|
||||
const tk = p.talk || [];
|
||||
$('#ppTalk').classList.toggle('hide', !tk.length);
|
||||
$('#ppTalkList').innerHTML = tk.map((x, i) => '<div class="pp-bub' + (i % 2 ? ' r' : '') + '"><span class="pb-ava">' + momAva(strSeed(x.text)) +
|
||||
'</span><span class="pb-t">' + esc(x.text) + '</span><em>' + fmtN(x.n) + ' 人在聊</em></div>').join('');
|
||||
}
|
||||
function paint() {
|
||||
const r = last;
|
||||
@@ -3243,25 +3245,23 @@
|
||||
sec.classList.remove('hide');
|
||||
peerMode = !!r.peer;
|
||||
sec.classList.toggle('is-peer', peerMode);
|
||||
$('#plPeer').classList.toggle('hide', !peerMode);
|
||||
if (peerMode) paintPeer(r.peer);
|
||||
else $('#plTitle').textContent = '孕妈们在做什么';
|
||||
const tot = $('#plTotal');
|
||||
tot.classList.toggle('hide', !r.total || peerMode);
|
||||
if (r.total) {
|
||||
$('#plPre').textContent = r.total.prefix || '';
|
||||
$('#plSuf').textContent = r.total.suffix || '';
|
||||
if (seen) tweenNum($('#plNum'), r.total.value, 1800);
|
||||
else {
|
||||
/* 全站版(访客 / real 模式):只留一行总人数 + 滚动动态 */
|
||||
paintAvs(0);
|
||||
$('#ppDoing').classList.add('hide');
|
||||
$('#plTodo').classList.add('hide');
|
||||
const t = r.total;
|
||||
/* 前缀「已有」省掉:一行放得下「10,037 位妈妈在这里迎接宝宝」,带上就会折出一个孤零零的「宝宝」 */
|
||||
$('#plTitle').innerHTML = t ? '<b data-n="' + t.value + '">0</b> ' + esc(t.suffix) : '孕妈们在做什么';
|
||||
}
|
||||
const td = $('#plToday'), items = peerMode ? [] : (r.today || []);
|
||||
td.classList.toggle('hide', !items.length);
|
||||
const keys = items.map(x => x.key).join(',');
|
||||
if (td.dataset.keys !== keys) {
|
||||
td.dataset.keys = keys;
|
||||
td.innerHTML = items.map(x => '<button class="pl-stat k-' + x.key + '" type="button" data-k="' + x.key + '">' +
|
||||
pulseIco(x.key, 'ps-ico') + '<b>0</b><span>' + esc(x.label) + '</span><i class="go">›</i></button>').join('');
|
||||
/* 标题每次重画会重建 <b>:从上次显示到的数接着涨,不要每分钟从 0 重数 */
|
||||
const nb = $('#plTitle b');
|
||||
if (nb) {
|
||||
nb.dataset.v = shownN;
|
||||
nb.textContent = fmtN(shownN);
|
||||
if (seen) { tweenNum(nb, +nb.dataset.n || 0, 1600); shownN = +nb.dataset.n || 0; }
|
||||
}
|
||||
if (seen) items.forEach(x => tweenNum(td.querySelector('[data-k="' + x.key + '"] b'), x.value, 1600));
|
||||
const nf = (peerMode ? r.peer.feed : r.feed) || [];
|
||||
const fe = $('#plFeed');
|
||||
fe.classList.toggle('hide', !nf.length);
|
||||
@@ -3279,8 +3279,8 @@
|
||||
}
|
||||
}
|
||||
sec.addEventListener('click', e => {
|
||||
const b = e.target.closest('.pl-stat,[data-go]');
|
||||
const k = b && (b.dataset.k || b.dataset.go);
|
||||
const b = e.target.closest('[data-go]');
|
||||
const k = b && b.dataset.go;
|
||||
if (k && TODAY_GO[k]) { haptic(); TODAY_GO[k](); }
|
||||
});
|
||||
const myWeek = () => (state.pregEmpty === false && !state.postpartum && state.week >= 4) ? state.week : null;
|
||||
|
||||
Reference in New Issue
Block a user