v26110258 预览:首页「此刻」换成测一测 · 科普 · 计算器(js/kit.js,?kit=0 看回此刻)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-03 13:37:34 +00:00
parent ec23742458
commit d41d16fa56
13 changed files with 154 additions and 20 deletions

BIN
assets/img/kit/jisuan.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
assets/img/kit/kepu.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -367,8 +367,8 @@ mark{background:linear-gradient(transparent 62%,var(--c20) 0);color:inherit;padd
</div> </div>
<div class="toast" id="toast"></div> <div class="toast" id="toast"></div>
<script src="meta.js?v=26110257"></script> <script src="meta.js?v=26110258"></script>
<script src="tests.js?v=26110257"></script> <script src="tests.js?v=26110258"></script>
<script> <script>
(function () { (function () {
'use strict'; 'use strict';

View File

@@ -666,10 +666,10 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
<div id="sheet" role="dialog" aria-modal="true"><i class="sg"></i><div class="sbd" id="sbd"></div></div> <div id="sheet" role="dialog" aria-modal="true"><i class="sg"></i><div class="sbd" id="sbd"></div></div>
<div class="toast" id="toast"></div> <div class="toast" id="toast"></div>
<script src="topics.js?v=26110257"></script> <script src="topics.js?v=26110258"></script>
<script src="data.js?v=26110257"></script> <script src="data.js?v=26110258"></script>
<script src="feed.js?v=26110257"></script> <script src="feed.js?v=26110258"></script>
<script src="ceshi/meta.js?v=26110257"></script> <script src="ceshi/meta.js?v=26110258"></script>
<script> <script>
(function () { (function () {
'use strict'; 'use strict';
@@ -735,7 +735,7 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:poin
var CMD = null, CMERR = false; var CMD = null, CMERR = false;
/* 头像编码:数字 = av/NNNN.webp(旧代码头像);'av:c012' = av/c012.webp(卡通/可爱卡通);'/…' = 站内绝对路径(内置头像库 /_bridge/avatars/);其余 = assets/img/mom/xxx.jpg */ /* 头像编码:数字 = av/NNNN.webp(旧代码头像);'av:c012' = av/c012.webp(卡通/可爱卡通);'/…' = 站内绝对路径(内置头像库 /_bridge/avatars/);其余 = assets/img/mom/xxx.jpg */
var avP = function (a) { return typeof a === 'number' ? 'av/' + ('000' + a).slice(-4) + '.webp' : a.indexOf('av:') === 0 ? 'av/' + a.slice(3) + '.webp' : a.charAt(0) === '/' ? a : '../assets/img/mom/' + a + '.jpg'; }; var avP = function (a) { return typeof a === 'number' ? 'av/' + ('000' + a).slice(-4) + '.webp' : a.indexOf('av:') === 0 ? 'av/' + a.slice(3) + '.webp' : a.charAt(0) === '/' ? a : '../assets/img/mom/' + a + '.jpg'; };
fetch('cm.json?v=26110257').then(function (r) { return r.json(); }).then(function (j) { fetch('cm.json?v=26110258').then(function (r) { return r.json(); }).then(function (j) {
CMD = j; if (openId && NBY[openId]) { renderComments(NBY[openId]); syncBar(NBY[openId]); } CMD = j; if (openId && NBY[openId]) { renderComments(NBY[openId]); syncBar(NBY[openId]); }
}).catch(function () { CMERR = true; if (openId && NBY[openId]) renderComments(NBY[openId]); }); }).catch(function () { CMERR = true; if (openId && NBY[openId]) renderComments(NBY[openId]); });
function commentsOf(n) { function commentsOf(n) {

View File

@@ -105,7 +105,7 @@ main{padding:6px 16px 0}
</div> </div>
<div class="wb"><button type="button" id="write"><svg class="ic" viewBox="0 0 24 24"><path d="M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg>写新的故事</button></div> <div class="wb"><button type="button" id="write"><svg class="ic" viewBox="0 0 24 24"><path d="M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"/></svg>写新的故事</button></div>
<script src="../topics.js?v=26110257"></script> <script src="../topics.js?v=26110258"></script>
<script> <script>
(function () { (function () {
'use strict'; 'use strict';

View File

@@ -7,7 +7,7 @@
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<title>兜爸心选 · 孕育陪伴</title> <title>兜爸心选 · 孕育陪伴</title>
<!-- V:26110257 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 --> <!-- V:26110258 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
<link rel="stylesheet" href="mama-box.css"> <link rel="stylesheet" href="mama-box.css">
<link rel="stylesheet" href="night.css"> <link rel="stylesheet" href="night.css">
<!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) --> <!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) -->
@@ -527,6 +527,8 @@
<span class="we-go" id="weGo"></span> <span class="we-go" id="weGo"></span>
</button> </button>
</div> </div>
<!-- 11-03 测一测 · 科普 · 计算器(替代上面的「此刻」,js/kit.js;?kit=0 看回此刻) -->
<div class="kit hide" id="kit" role="region" aria-label="测一测、科普、计算器"></div>
</section> </section>
<!-- 孕妈广场(2026-11-01 第一版,占位内容)。用户原话:「在这个模块下边加一个广场,放一些话题,有跟家庭里的,也有宝妈经验的…… <!-- 孕妈广场(2026-11-01 第一版,占位内容)。用户原话:「在这个模块下边加一个广场,放一些话题,有跟家庭里的,也有宝妈经验的……
@@ -2519,15 +2521,16 @@
<script src="/_bridge/avatar-picker.js?v=26101105"></script> <script src="/_bridge/avatar-picker.js?v=26101105"></script>
<script src="/_bridge/hand-icons.js?v=26101202"></script> <script src="/_bridge/hand-icons.js?v=26101202"></script>
<script src="js/zodiac-art.js"></script> <script src="js/zodiac-art.js"></script>
<script src="guangchang/topics.js?v=26110257"></script> <script src="guangchang/topics.js?v=26110258"></script>
<script src="js/app.js"></script> <script src="js/app.js"></script>
<script src="js/kit.js?v=26110258"></script>
<script> <script>
/* 11-02 首页「孕妈广场」效果稿:地址带 ?gcv=1~6 时,把 #gcHome 换成 demo/gch/vN.css + vN.js 的版式并滚到这一块。 /* 11-02 首页「孕妈广场」效果稿:地址带 ?gcv=1~6 时,把 #gcHome 换成 demo/gch/vN.css + vN.js 的版式并滚到这一块。
11-02 用户:「用第一版,放到预览页面上」;后改定彩色卡 → 不带参数也默认用 V6 合并版(广场卡堆 + 其他妈妈也在搜 + 测一测第 4 版彩色卡),不滚动、不显示效果稿角标 */ 11-02 用户:「用第一版,放到预览页面上」;后改定彩色卡 → 不带参数也默认用 V6 合并版(广场卡堆 + 其他妈妈也在搜 + 测一测第 4 版彩色卡),不滚动、不显示效果稿角标 */
(function () { (function () {
var m = location.search.match(/[?&]gcv=([1-6])(?:&|$)/); var m = location.search.match(/[?&]gcv=([1-6])(?:&|$)/);
if (!m) window.__gcDefault = 1; if (!m) window.__gcDefault = 1;
var n = m ? m[1] : '6', l = document.createElement('link'), s = document.createElement('script'), q = m ? Date.now() : 'v=26110257'; var n = m ? m[1] : '6', l = document.createElement('link'), s = document.createElement('script'), q = m ? Date.now() : 'v=26110258';
var dir = n === '4' || n === '6' ? 'js/gch/' : 'demo/gch/'; /* 11-03 上正式:定稿 V6(含它套的 V4)并进 js/gch/,其余效果稿仍在 demo/ */ var dir = n === '4' || n === '6' ? 'js/gch/' : 'demo/gch/'; /* 11-03 上正式:定稿 V6(含它套的 V4)并进 js/gch/,其余效果稿仍在 demo/ */
l.rel = 'stylesheet'; l.href = dir + 'v' + n + '.css?' + q; l.rel = 'stylesheet'; l.href = dir + 'v' + n + '.css?' + q;
s.src = dir + 'v' + n + '.js?' + q; s.src = dir + 'v' + n + '.js?' + q;
@@ -2536,7 +2539,7 @@
/* 11-02 品牌露出(用户定 4 处都要):默认加载,?brand=0 可关掉对比;11-03 已并进 js/gch/ */ /* 11-02 品牌露出(用户定 4 处都要):默认加载,?brand=0 可关掉对比;11-03 已并进 js/gch/ */
if (!/[?&]brand=0/.test(location.search)) { if (!/[?&]brand=0/.test(location.search)) {
var bl = document.createElement('link'), bs = document.createElement('script'); var bl = document.createElement('link'), bs = document.createElement('script');
bl.rel = 'stylesheet'; bl.href = 'js/gch/brand.css?v=26110257'; bs.src = 'js/gch/brand.js?v=26110257'; bl.rel = 'stylesheet'; bl.href = 'js/gch/brand.css?v=26110258'; bs.src = 'js/gch/brand.js?v=26110258';
document.head.appendChild(bl); document.body.appendChild(bs); document.head.appendChild(bl); document.body.appendChild(bs);
} }
})(); })();
@@ -2547,7 +2550,7 @@
<script src="js/hero-fx.js"></script> <script src="js/hero-fx.js"></script>
<!-- 2026-10-05 首页头图:宝宝时不时动一动小手小脚(独立文件,删掉这一行即下线) --> <!-- 2026-10-05 首页头图:宝宝时不时动一动小手小脚(独立文件,删掉这一行即下线) -->
<script src="js/baby-limbs.js?v=26101201"></script> <script src="js/baby-limbs.js?v=26101201"></script>
<script src="js/coach.js?v=26101211"></script> <script src="js/coach.js?v=26110258"></script>
<script src="js/birth-flow.js?v=26110201"></script> <script src="js/birth-flow.js?v=26110201"></script>
<!-- 禁止下拉回弹(2026-10-11 统一规则,与孕期体重同一段):竖向拖动时从手指下往上找还能朝该方向滚的容器,找不到才拦;横滑、双指、可滚列表不受影响 --> <!-- 禁止下拉回弹(2026-10-11 统一规则,与孕期体重同一段):竖向拖动时从手指下往上找还能朝该方向滚的容器,找不到才拦;横滑、双指、可滚列表不受影响 -->

View File

@@ -3,7 +3,7 @@
(function () { (function () {
'use strict'; 'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26110257'; var VER = '26110258';
const $ = (s, c) => (c || document).querySelector(s); const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));

View File

@@ -39,7 +39,8 @@
const STEPS = [ const STEPS = [
{ sel: '.hero-pane', t: '这是你的孕周', d: '孕几周、离见面还有几天、宝宝现在有多大,每天打开都会更新。' }, { sel: '.hero-pane', t: '这是你的孕周', d: '孕几周、离见面还有几天、宝宝现在有多大,每天打开都会更新。' },
{ sel: '.tool-dock', t: '常用孕育工具', d: '数胎动、孕检日历、体重这些常用工具都在这里,点卡片直接进。' }, { sel: '.tool-dock', t: '常用孕育工具', d: '数胎动、孕检日历、体重这些常用工具都在这里,点卡片直接进。' },
{ sel: '#pulse', t: '此刻', d: '看看和你同一周的妈妈们今天都在做什么。' }, /* 11-03「此刻」换成测一测 · 科普 · 计算器(js/kit.js);?kit=0 时 #kit 不显示,自动跳过 */
{ sel: '#kit', t: '测一测 · 科普 · 计算器', d: '按你的孕周,每天推荐一个小测试、一篇科普和实用计算器。' },
{ sel: '.tab-fab', t: '记一下', d: '想记点什么、找更多工具,点中间这颗按钮。' }, { sel: '.tab-fab', t: '记一下', d: '想记点什么、找更多工具,点中间这颗按钮。' },
{ sel: '.tabbar [data-tab="me"]', t: '我的', d: '孕期档案、头像、兜豆和兑换记录都在这里。' } { sel: '.tabbar [data-tab="me"]', t: '我的', d: '孕期档案、头像、兜豆和兑换记录都在这里。' }
]; ];

View File

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

View File

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

40
js/kit.css Normal file
View File

@@ -0,0 +1,40 @@
/* 11-03 测一测 · 科普 · 计算器(替代「此刻」,见 js/kit.js) */
html.has-kit #pulse{display:none!important}
.kit{margin:16px 0 0;padding:14px 0 2px;border-top:1px dashed rgba(220,160,140,.45)}
.kit.hide{display:none}
.kit-hd{display:flex;align-items:center;justify-content:space-between;margin:0 0 10px}
.kit-hd b{font-size:16px;font-weight:900;color:#2A1E1E;letter-spacing:.3px}
.kit-hd b em{font-style:normal;color:#F4593C}
.kit-sw{display:inline-flex;align-items:center;gap:3px;height:26px;padding:0 10px;border:0;border-radius:99px;background:#FFF1EA;color:#D9583B;font:inherit;font-size:12px;font-weight:700;cursor:pointer}
.kit-sw svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.kit-sw:active svg{transform:rotate(180deg);transition:transform .3s}
.kit-g{display:grid;grid-template-columns:1fr 1.18fr;gap:10px}
.kit-g.flip>*{animation:kitIn .42s cubic-bezier(.3,1.3,.5,1) both}
.kit-g.flip>.kit-col{animation-delay:.06s}
@keyframes kitIn{from{opacity:0;transform:translateY(8px) scale(.97)}}
.kit-k{display:inline-block;height:18px;padding:0 7px;border-radius:6px;font-size:10.5px;font-weight:800;line-height:18px;letter-spacing:.5px;color:#fff}
.kit-qz{position:relative;display:flex;flex-direction:column;align-items:flex-start;min-height:178px;padding:12px 12px 12px;border-radius:18px;overflow:hidden;text-decoration:none;
background:linear-gradient(160deg,#F1ECFF,#E4DBFF);box-shadow:inset 0 0 0 1px rgba(255,255,255,.7)}
.kit-qz .kit-k{background:#7C5CFC}
.kit-qt{position:relative;z-index:1;margin-top:8px;font-size:14.5px;font-weight:900;line-height:1.35;color:#2A1E1E;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.kit-qz small{position:relative;z-index:1;margin-top:5px;font-size:11px;font-weight:700;color:#7C5CFC}
.kit-go{position:relative;z-index:1;margin-top:auto;height:26px;padding:0 11px;border-radius:99px;display:inline-flex;align-items:center;background:#7C5CFC;color:#fff;font-size:12px;font-weight:800;box-shadow:0 4px 10px -4px rgba(124,92,252,.7)}
.kit-go::after{content:"›";margin-left:3px;font-size:14px}
.kit-qz img{position:absolute;right:-10px;bottom:-8px;width:84px;height:84px;object-fit:cover;border-radius:50%;opacity:.95;box-shadow:0 0 0 4px rgba(255,255,255,.55)}
.kit-col{display:flex;flex-direction:column;gap:10px;min-width:0}
.kit-r{flex:1;display:flex;align-items:center;gap:9px;min-height:84px;padding:10px 10px 10px 8px;border-radius:16px;text-decoration:none;min-width:0}
.kit-r.kp{background:linear-gradient(150deg,#E6F6F0,#D8F0EA)}
.kit-r.js{background:linear-gradient(150deg,#FFF1E6,#FDE8D4)}
.kit-r img{flex:none;width:52px;height:52px;border-radius:14px;object-fit:cover}
.kit-rt{display:flex;flex-direction:column;align-items:flex-start;min-width:0}
.kit-r.kp .kit-k{background:#2E9B78}
.kit-r.js .kit-k{background:#F07A2E}
.kit-rt b{margin-top:4px;font-size:13px;font-weight:800;line-height:1.35;color:#2A1E1E;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.kit-rt small{margin-top:2px;font-size:10.5px;font-weight:700;color:#A3958D}
.kit a:active{transform:scale(.97);transition:transform .12s}
html.night .kit{border-color:rgba(255,255,255,.1)}
html.night .kit-hd b,html.night .kit-qt,html.night .kit-rt b{color:#F1E6EE}
html.night .kit-qz{background:linear-gradient(160deg,#3A3150,#2F2842)}
html.night .kit-r.kp{background:linear-gradient(150deg,#22392F,#1E332B)}
html.night .kit-r.js{background:linear-gradient(150deg,#3E2E22,#36281E)}
html.night .kit-sw{background:rgba(255,255,255,.08);color:#F2A08A}

90
js/kit.js Normal file
View File

@@ -0,0 +1,90 @@
/* 11-03 用户:「把此刻那个板块改成测一测、科普、还有计算器,你看一下怎么设计替代此刻的模块」(先在预览改)
→ 位置不变(「我的孕期工具」卡底部,原 #pulse 处),版式:左边一张大的「测一测」+ 右边上下两条「科普」「计算器」,内容按孕周换:
· 测一测:广场测一测 30 个里挑孕期能测的,按孕周段分池,每天轮换一个(北京日期);
· 科普:问题库 hot.json 按孕周段(同「其他孕妈也在搜」qaPick),跳过下面列表已经露出的前 6 条和测试 / 计算器题;
· 计算器:生娃计算器(topic/huafei)、产假天数计算器(topic/zhichang),孕 29 周起产假排前面。
右上「换一换」三格一起换下一组。人数同首页口径:测一测 = 测一测页的 gcTested;科普 / 计算器 = 「此刻」总人数 × heat(模拟数,AGENTS.md 12b)。
原「此刻」#pulse 只是藏起来(kit.css),JS 照跑(别的地方要用它的总人数);地址带 ?kit=0 可看回旧版对比。 */
(function () {
if (/[?&]kit=0(?:&|$)/.test(location.search)) return;
var box = document.getElementById('kit');
if (!box) return;
var V = '26110258';
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');
function esc(t) { return String(t == null ? '' : t).replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); }
function href(h) { return h + location.search + location.hash; }
function testURL(id) { var q = new URLSearchParams(location.search); q.set('id', id); return 'guangchang/ceshi/?' + q.toString() + location.hash; }
function wan(n) { return n >= 1e4 ? (Math.round(n / 1e3) / 10) + '万' : String(Math.round(n)); }
function total() { var p = window.__mbPulse; return (p && p.total && +p.total.value) || 1510000; }
var day = Math.floor((Date.now() + 288e5) / 864e5), shift = 0;
/* 测一测:按孕周段分池(段同 qaBand:1 ≤8 / 2 ≤13 / 3 ≤20 / 4 ≤28 / 5 ≤36 / 6 37+;0 = 没孕周 / 产后) */
var QZ_POOL = {
0: ['t11', 't14', 't13', 't16', 't18', 't23', 't03', 't22'],
1: ['t17', 't01', 't25', 't24', 't02', 't11'],
2: ['t17', 't01', 't25', 't24', 't02', 't11'],
3: ['t24', 't25', 't01', 't17', 't21', 't02'],
4: ['t24', 't21', 't25', 't01', 't02', 't17'],
5: ['t05', 't21', 't02', 't24', 't03', 't25'],
6: ['t05', 't03', 't02', 't06', 't21', 't25']
};
var CALC = [
{ t: '生娃要花多少钱?一键算清', s: '产检 · 分娩 · 月子 · 第一年', h: 'topic/huafei/', heat: .118 },
{ t: '产假能休多少天?算一算', s: '按地区和生产情况算', h: 'topic/zhichang/', heat: .062 }
];
var QA = null;
fetch('assets/data/qa/hot.json?v=' + V).then(function (r) { return r.ok ? r.json() : []; }).catch(function () { return []; })
.then(function (a) { QA = Array.isArray(a) ? a : []; render(); });
if (!window.GC_TESTS_META) {
var s = document.createElement('script'); s.src = 'guangchang/ceshi/meta.js?v=' + V; s.onload = s.onerror = render; document.body.appendChild(s);
}
function band() {
var p = window.__mbPreg || {};
if (p.postpartum || !p.week) return 0;
return window.__mbQaBand ? window.__mbQaBand(p.week) : 0;
}
function pickQz(b) {
var meta = window.GC_TESTS_META || [], pool = (QZ_POOL[b] || QZ_POOL[0]).map(function (id) { return meta.filter(function (x) { return x.id === id; })[0]; }).filter(Boolean);
return pool.length ? pool[(day + shift) % pool.length] : null;
}
function pickKp(b) {
if (!QA || !QA.length) return null;
var w = (window.__mbPreg || {}).week, skip = ['topic/huafei/', 'topic/ceshi/', 'topic/duiyou/', 'topic/zhichang/'];
var shown = window.__mbQaPick ? window.__mbQaPick(QA, b ? w : 0, 6) : [];
var all = window.__mbQaPick ? window.__mbQaPick(QA, b ? w : 0, 30) : QA;
var l = all.filter(function (x) { return x.href && skip.indexOf(x.href) < 0 && shown.indexOf(x) < 0; });
return l.length ? l[shift % l.length] : null;
}
function render() {
var b = band(), qz = pickQz(b), kp = pickKp(b);
var cl = b >= 5 ? [CALC[1], CALC[0]] : CALC, ca = cl[shift % cl.length];
var p = window.__mbPreg || {}, wk = p.week && !p.postpartum ? '孕 ' + p.week + ' 周' : '';
var h = '<div class="kit-hd"><b>' + (wk ? '<em>' + wk + '</em> · ' : '') + '今天看点什么</b>' +
'<button type="button" class="kit-sw" aria-label="换一组"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 12a8 8 0 0113.7-5.6L20 8.5M20 4v4.5h-4.5M20 12a8 8 0 01-13.7 5.6L4 15.5M4 20v-4.5h4.5"/></svg>换一换</button></div>';
h += '<div class="kit-g">';
if (qz) {
var n = window.gcTestedText ? window.gcTestedText(qz.id) : '';
h += '<a class="kit-qz" href="' + esc(testURL(qz.id)) + '"><span class="kit-k">测一测</span><b class="kit-qt">' + esc(qz.title) + '</b>' +
'<small>' + esc(n || (qz.n + ' 道题')) + '</small><span class="kit-go">去测一测</span>' +
'<img src="guangchang/ceshi/img/' + qz.id + '_s.webp" alt="" loading="lazy" decoding="async"></a>';
}
h += '<div class="kit-col">';
if (kp) h += '<a class="kit-r kp" href="' + esc(href(kp.href)) + '"><img src="assets/img/kit/kepu.webp" alt="" loading="lazy"><span class="kit-rt"><span class="kit-k">科普</span><b>' + esc(kp.q) + '</b>' +
'<small>' + wan(total() * (+kp.heat || .03)) + '人看过</small></span></a>';
h += '<a class="kit-r js" href="' + esc(href(ca.h)) + '"><img src="assets/img/kit/jisuan.webp" alt="" loading="lazy"><span class="kit-rt"><span class="kit-k">计算器</span><b>' + esc(ca.t) + '</b>' +
'<small>' + wan(total() * ca.heat) + '人算过</small></span></a>';
h += '</div></div>';
box.innerHTML = h;
box.classList.remove('hide');
}
box.addEventListener('click', function (e) {
if (!e.target.closest('.kit-sw')) return;
shift++; render();
var g = box.querySelector('.kit-g'); if (g) { g.classList.remove('flip'); void g.offsetWidth; g.classList.add('flip'); }
});
window.addEventListener('mb-preg', render);
render();
})();

View File

@@ -68,7 +68,7 @@
function getJSON(u) { return fetch(u, { cache: 'no-cache' }).then(function (r) { if (!r.ok) throw r.status; return r.json(); }); } function getJSON(u) { return fetch(u, { cache: 'no-cache' }).then(function (r) { if (!r.ok) throw r.status; return r.json(); }); }
function related(box) { function related(box) {
getJSON('../_shared/idx.json?v=26110257').then(function (idx) { getJSON('../_shared/idx.json?v=26110258').then(function (idx) {
var me = null; idx.forEach(function (x) { if (x[0] === SLUG) me = x; }); var me = null; idx.forEach(function (x) { if (x[0] === SLUG) me = x; });
var tag = me ? me[2] : '', h = 0; for (var i = 0; i < SLUG.length; i++) h = (h * 31 + SLUG.charCodeAt(i)) >>> 0; var tag = me ? me[2] : '', h = 0; for (var i = 0; i < SLUG.length; i++) h = (h * 31 + SLUG.charCodeAt(i)) >>> 0;
var rest = idx.filter(function (x) { return x[0] !== SLUG; }); var rest = idx.filter(function (x) { return x[0] !== SLUG; });
@@ -175,7 +175,7 @@
} }
fetch(API + '/comments?kind=topic&target=' + encodeURIComponent(SLUG) + (OID ? '&openid=' + encodeURIComponent(OID) : '')) fetch(API + '/comments?kind=topic&target=' + encodeURIComponent(SLUG) + (OID ? '&openid=' + encodeURIComponent(OID) : ''))
.then(function (r) { return r.json(); }).then(function (j) { if (j && j.code === 200) { RC = j.result; paint(); } }).catch(function () {}); .then(function (r) { return r.json(); }).then(function (j) { if (j && j.code === 200) { RC = j.result; paint(); } }).catch(function () {});
getJSON('../_shared/cm/' + SLUG + '.json?v=26110257').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); }); getJSON('../_shared/cm/' + SLUG + '.json?v=26110258').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
} }
function extras(el) { function extras(el) {