v26110267 预览:首页头图倒计时翻牌;百宝箱入口人数改几十万带小数;30 个测试开始页按参考图精简居中;产假计算器模式(calc=1)计算器置顶

Co-Authored-By: AI 助手
This commit is contained in:
deploy
2026-11-03 22:26:34 +00:00
parent a536e81e01
commit aabe4f9b38
14 changed files with 211 additions and 138 deletions

View File

@@ -3,7 +3,7 @@
(function () {
'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26110266';
var VER = '26110267';
const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
@@ -1832,6 +1832,9 @@
$('#heroSize').textContent = o.size || '';
$('#heroWeekU').textContent = o.unit == null ? '周' : o.unit;
$('.hero-pane').classList.toggle('is-born', !!o.born);
/* 11-03 用户:「首页头图小孩左边做成倒计时的感觉」→ 孕期且有天数时换成翻页数字牌 + 时分秒走字(js/hero-cd.js),其余状态照旧 */
window.__mbHeroLeft = o.left > 0 ? o.left : 0;
if (window.__mbHeroCd) window.__mbHeroCd(window.__mbHeroLeft);
bar.style.width = '0%';
requestAnimationFrame(() => requestAnimationFrame(() => { bar.style.width = Math.max(0, Math.min(100, o.pct || 0)) + '%'; }));
}
@@ -2095,6 +2098,7 @@
const sz = babySize(week);
setHero({
due: left > 0 ? '距离见面还有 <b>' + left + '</b> 天' : '宝宝随时会来见你',
left: left,
emoji: sz.emoji, hi: window.handIcons && (handIcons.week(week) || {}).id, size: '像' + sz.name.replace(/^一[个颗根只串把粒条棵颗]/, ''), pct: pct
});
}

View File

@@ -231,5 +231,5 @@
}
/* feed.js 首页默认不加载(index.html 只引了 topics.js),这里按需拉一次 */
if (window.GC_FEED) init();
else { var fs = document.createElement('script'); fs.src = 'guangchang/feed.js?v=26110266'; fs.onload = fs.onerror = init; document.body.appendChild(fs); }
else { var fs = document.createElement('script'); fs.src = 'guangchang/feed.js?v=26110267'; fs.onload = fs.onerror = init; document.body.appendChild(fs); }
})();

View File

@@ -6,9 +6,9 @@
(function () {
var sec = document.getElementById('gcHome');
if (!sec) return;
var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/gch/v4.css?v=26110266';
var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/gch/v4.css?v=26110267';
document.head.appendChild(l);
var s = document.createElement('script'); s.src = 'js/gch/v4.js?v=26110266';
var s = document.createElement('script'); s.src = 'js/gch/v4.js?v=26110267';
s.onload = function () { if (sec.querySelector('.g4-foot')) merge(); else sec.addEventListener('gc4-ready', merge, { once: true }); }; /* v4 要先拉 feed.js 才渲染 */
document.body.appendChild(s);

36
js/hero-cd.css Normal file
View File

@@ -0,0 +1,36 @@
/* 首页头图倒计时(11-03,见 js/hero-cd.js)。只在 .hero-pane.cd 时生效;关掉(未填预产期 / 已出生)就是原来的样子。
竖向:小标 18 → 数字牌 46 → 时分秒 20 → 孕周一行 20 → 进度条 16,加间距后和旧版总高一样,下面「我的孕期工具」卡不会被顶下去。 */
.hi-cd{display:none}
.hero-pane.cd{margin-top:2px}
.hero-pane.cd .hi-due{display:none}
.hero-pane.cd .hi-cd{display:flex;flex-direction:column;align-items:flex-start}
.cd-lb{display:inline-flex;align-items:center;gap:5px;height:18px;font-size:12.5px;font-weight:700;color:#fff;letter-spacing:.5px;white-space:nowrap}
.cd-lb svg{width:12px;height:12px;color:#FFD9C7;animation:hiBeat 1.6s ease-in-out infinite}
.cd-row{display:flex;align-items:flex-end;gap:6px;margin-top:5px}
.cd-d{display:flex;gap:4px}
/* 一位一块牌:上半亮、下半略暗,中间一道翻页缝 + 两侧小铆点,像机场翻牌钟 */
.cd-d i{position:relative;display:block;width:34px;height:46px;border-radius:9px;font-style:normal;
background:linear-gradient(180deg,rgba(255,255,255,.34) 0 50%,rgba(255,255,255,.22) 50% 100%);
border:1px solid rgba(255,255,255,.45);box-shadow:0 6px 14px -6px rgba(120,30,10,.45),inset 0 1px 0 rgba(255,255,255,.4);
-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);overflow:hidden;perspective:200px}
.cd-d i::before{content:"";position:absolute;left:0;right:0;top:50%;height:1px;background:rgba(150,60,35,.28);z-index:2}
.cd-d i::after{content:"";position:absolute;left:-2px;right:-2px;top:calc(50% - 2px);height:4px;z-index:2;
background:radial-gradient(circle at 2px 2px,rgba(150,60,35,.35) 1.5px,transparent 2px) left/4px 4px no-repeat,radial-gradient(circle at 2px 2px,rgba(150,60,35,.35) 1.5px,transparent 2px) right/4px 4px no-repeat}
.cd-d span{display:block;font-size:34px;font-weight:900;line-height:46px;text-align:center;color:#fff;font-variant-numeric:tabular-nums;
text-shadow:0 2px 0 rgba(140,50,28,.3),0 4px 10px rgba(120,30,10,.22)}
.cd-d i.flip span{animation:cdFlip .55s cubic-bezier(.3,.7,.4,1)}
@keyframes cdFlip{0%{transform:rotateX(-90deg);opacity:.2}60%{transform:rotateX(12deg);opacity:1}100%{transform:none}}
.cd-row em{margin-bottom:3px;font-style:normal;font-size:17px;font-weight:800;color:#FFE6BF}
/* 时分秒:小毛玻璃格 + 汉字单位 */
.cd-tk{display:flex;align-items:center;gap:2px;margin-top:6px;height:20px;white-space:nowrap}
.cd-tk b{min-width:22px;height:20px;padding:0 3px;border-radius:5px;background:rgba(110,35,18,.24);color:#fff;font-size:12.5px;font-weight:800;line-height:20px;text-align:center;font-variant-numeric:tabular-nums;text-shadow:none}
.cd-tk i{margin:0 3px 0 1px;font-style:normal;font-size:11px;font-weight:700;color:#FFE6BF}
/* 孕周退成一行小字「孕 26 周 +6天」,不再和倒计时抢主角 */
.hero-pane.cd .hi-week{height:20px;margin-top:5px;align-items:center}
.hero-pane.cd .hi-week::before{content:"孕";margin-right:3px;font-size:13px;font-weight:800;color:#FFE6BF}
.hero-pane.cd .hi-week b{font-size:17px;line-height:20px;letter-spacing:0;text-shadow:0 1px 3px rgba(120,30,10,.28)}
.hero-pane.cd .hi-unit{flex-direction:row;align-items:center;margin:0 0 0 3px}
.hero-pane.cd .hi-unit em{font-size:13px}
.hero-pane.cd .hi-unit span{margin:0 0 0 5px;padding:0 6px;font-size:10.5px;line-height:16px}
.hero-pane.cd .hi-prog{margin-top:5px}
@media (prefers-reduced-motion:reduce){.cd-d i.flip span,.cd-lb svg{animation:none}}

41
js/hero-cd.js Normal file
View File

@@ -0,0 +1,41 @@
/* 首页头图倒计时(11-03 用户:「头图小孩左边改成倒计时那种感觉」)
· 天数做成翻页数字牌(每位一块毛玻璃牌,中间一道翻页缝),变化时逐位翻一下;
· 下面一行「时 分 秒」每秒走字 = 到今天 24:00 还剩多少 —— 和天数合起来就是「到预产期那天结束」,跟别处的「还有 N 天」对得上;
· 数据只认 app.js setHero 传进来的天数(window.__mbHeroLeft),0 = 不开倒计时(未填预产期 / 已出生 / 已到预产期),整块隐藏、回到旧样式。 */
(function () {
var box = document.getElementById('heroCd'), pane = box && box.closest('.hero-pane');
if (!box) return;
var cur = '', timer = 0;
var p2 = function (n) { return (n < 10 ? '0' : '') + n; };
box.innerHTML =
'<span class="cd-lb"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 21s-8-5-8-11a4.5 4.5 0 018-2.8A4.5 4.5 0 0120 10c0 6-8 11-8 11z" fill="currentColor"/></svg>距离和宝宝见面还有</span>' +
'<div class="cd-row"><span class="cd-d" id="heroCdD"></span><em>天</em></div>' +
'<div class="cd-tk"><b id="heroCdH">--</b><i>时</i><b id="heroCdM">--</b><i>分</i><b id="heroCdS">--</b><i>秒</i></div>';
var D = document.getElementById('heroCdD'), H = document.getElementById('heroCdH'), M = document.getElementById('heroCdM'), S = document.getElementById('heroCdS');
function tick() {
var n = new Date(), e = new Date(n.getFullYear(), n.getMonth(), n.getDate() + 1), r = Math.max(0, Math.floor((e - n) / 1000));
H.textContent = p2(Math.floor(r / 3600)); M.textContent = p2(Math.floor(r / 60) % 60); S.textContent = p2(r % 60);
}
function setDays(v) {
var s = String(v), old = cur; cur = s;
if (D.children.length !== s.length) D.innerHTML = s.split('').map(function () { return '<i><span></span></i>'; }).join('');
s.split('').forEach(function (ch, k) {
var c = D.children[k], sp = c.firstChild;
if (sp.textContent === ch) return;
sp.textContent = ch;
if (old) { c.classList.remove('flip'); void c.offsetWidth; c.classList.add('flip'); }
});
}
window.__mbHeroCd = function (left) {
left = +left || 0;
var on = left > 0;
pane && pane.classList.toggle('cd', on);
if (!on) { clearInterval(timer); timer = 0; cur = ''; return; }
setDays(left);
tick();
if (!timer) timer = setInterval(tick, 1000);
};
/* 停在后台时不走字,回前台立刻补一次 */
document.addEventListener('visibilitychange', function () { if (!document.hidden && timer) tick(); });
if (window.__mbHeroLeft != null) window.__mbHeroCd(window.__mbHeroLeft);
})();

View File

@@ -9,7 +9,7 @@
if (/[?&]kit=0(?:&|$)/.test(location.search)) return;
var box = document.getElementById('kit'), sec = document.getElementById('kitHome');
if (!box || !sec) return;
var V = '26110266';
var V = '26110267';
var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/kit.css?v=' + V; document.head.appendChild(l);
document.documentElement.classList.add('has-kit');
@@ -21,6 +21,8 @@
var s = q.toString(); return (s ? '?' + s : '') + location.hash;
}
function wan(n) { return n >= 1e6 ? Math.round(n / 1e4) + '万' : n >= 1e4 ? (Math.round(n / 1e3) / 10) + '万' : String(Math.round(n)); } /* 百万以上取整,卡片窄放得下 */
/* 入口专用:万为单位、必带一位小数,碰上整数(如 68.0)挪 0.3,避免看着像凑的整数 */
function wanX(n) { var v = Math.round(n / 1e3) / 10; if (v % 1 === 0) v = +(v + .3).toFixed(1); return v.toFixed(1) + '万'; }
function total() { var p = window.__mbPulse; return (p && p.total && +p.total.value) || 1510000; }
var FIRE = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12.6 2.5c.4 3-1.6 4.6-3 6.2C8 10.4 7 12 7 14.3A5 5 0 0012 19.5a5 5 0 005-5.2c0-2-1-3.6-1.9-4.6-.2 1.3-.9 2.2-1.9 2.6.6-3.4-.2-7-.6-9.8z" fill="currentColor"/></svg>';
@@ -38,11 +40,13 @@
'<div class="kit-lh"><b>大家都在用</b><span class="kit-wk"></span></div><div class="ms-list kit-list"></div>';
sec.classList.remove('hide');
function setCnt(k, t) { var e = box.querySelector('.e-' + k + ' em'); if (e) e.firstChild.nodeValue = t; }
function setNum(k, n) { var e = box.querySelector('.e-' + k + ' .kit-n i'); if (e && n) e.textContent = wan(n); }
/* 人数口径:测过 = 30 个测试 gcTested 之和(同广场「累计 N 万人次参与」);看过 = 「此刻」总人数 × 0.62;算过 = 4 个计算器 heat 之和 × 总人数(同 topic/jisuan) */
function setNum(k, n) { var e = box.querySelector('.e-' + k + ' .kit-n i'); if (e && n) e.textContent = wanX(n); }
/* 人数口径(11-03 改):测过 = 30 个测试 gcTested 之和 × .456;看过 = 「此刻」总人数 × .574;算过 = 4 个计算器 heat 之和 × 总人数(同 topic/jisuan) */
function nums() {
if (window.GC_TESTS_META && window.gcTested) { setNum('qz', window.GC_TESTS_META.reduce(function (a, x) { return a + window.gcTested(x.id); }, 0)); setCnt('qz', window.GC_TESTS_META.length + ' 个测试'); }
setNum('qa', total() * .62);
/* 11-03 用户:「三个入口的人数太大,几十万就行,要有零有整」→ 系数压到几十万(测过 ≈68 万 / 看过 ≈87 万 / 算过 ≈50 万),且一律带一位小数(wanX)。
仍不小于下面列表里单条的最大值(单个测试 ≤12 万、单条百问 ≤64 万、单个计算器 ≤18 万),口径不打架。模拟数,12-31 复核 */
if (window.GC_TESTS_META && window.gcTested) { setNum('qz', window.GC_TESTS_META.reduce(function (a, x) { return a + window.gcTested(x.id); }, 0) * .456); setCnt('qz', window.GC_TESTS_META.length + ' 个测试'); }
setNum('qa', total() * .574);
setNum('js', total() * CALC.reduce(function (a, x) { return a + x.heat; }, 0));
if (QA && QA.length) setCnt('qa', QA.length + ' 个问题');
}
@@ -63,7 +67,7 @@
{ q: '生娃到底要花多少钱?一键算清', h: 'topic/huafei/', heat: .118 },
{ q: '孕期该长多少斤?按身高体重算', h: '/yunqi-tizhong/', heat: .083 },
{ q: '胎儿现在多重?填 B 超数估一估', h: '/taier-guzhong/', heat: .071, gate: 15 },
{ q: '产假能休多少天?哪天回去上班', h: 'topic/zhichang/', heat: .062 }
{ q: '产假能休多少天?哪天回去上班', h: 'topic/zhichang/', heat: .062, cm: 1 } /* cm:带 calc=1,进去第一屏就是计算器(11-03) */
];
var QA = null, day = Math.floor((Date.now() + 288e5) / 864e5);
function band() { var p = window.__mbPreg || {}; return p.postpartum || !p.week ? 0 : (window.__mbQaBand ? window.__mbQaBand(p.week) : 0); }
@@ -83,7 +87,7 @@
}
var cl = CALC.filter(function (x) { return !(x.gate && wk && wk < x.gate); });
if (b >= 5) cl = [cl[cl.length - 1]].concat(cl.slice(0, -1)); /* 孕 29 周起产假排前 */
cl.slice(0, 2).forEach(function (x) { out.js.push({ q: x.q, href: x.h + location.search + location.hash, n: total() * x.heat, u: '人算过' }); });
cl.slice(0, 2).forEach(function (x) { out.js.push({ q: x.q, href: x.h + (x.cm ? (location.search ? location.search + '&' : '?') + 'calc=1' : location.search) + location.hash, n: total() * x.heat, u: '人算过' }); });
var r = [];
for (var k = 0; k < 2; k++) ['qz', 'qa', 'js'].forEach(function (c) { if (out[c][k]) r.push(Object.assign({ c: c }, out[c][k])); });
return { r: r, wk: wk };