v26110266 预览:广场去掉篇数/话题数;孕期百问列表改版(热问大卡+分类彩签+答案摘要,人数×3.6);测一测列表按参考图改宫格卡
Co-Authored-By: AI 助手
This commit is contained in:
51
js/app.js
51
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110265';
|
||||
var VER = '26110266';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -5509,6 +5509,10 @@
|
||||
return out.slice(0, n);
|
||||
}
|
||||
window.__mbQaPick = qaPick; window.__mbQaBand = qaBand;
|
||||
/* 11-03 用户:「孕期百问观看人数有点少」→ 单条「N 人看过」= 总人数 × heat × 3.6(约 12 万~64 万,仍低于百宝箱入口「孕期百问 93.6 万人看过」)。模拟数,AGENTS.md 12b,12-31 复核 */
|
||||
const QA_K = 3.6;
|
||||
const qaViews = h => ((window.__mbPulse && window.__mbPulse.total && +window.__mbPulse.total.value) || 1510000) * (+h || 0) * QA_K;
|
||||
window.__mbQaViews = qaViews;
|
||||
const MS_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"/><path d="M12 19.5a2.6 2.6 0 01-2.6-2.6c0-1.6 1.3-2.5 2-3.6.3 1 .9 1.6 1.6 1.9.9.4 1.6 1.2 1.6 2.1A2.6 2.6 0 0112 19.5z" fill="#FFD36B"/></svg>';
|
||||
const MS_FIRE_W = '<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="#FFE07A"/></svg>';
|
||||
function msHeat() {
|
||||
@@ -5579,14 +5583,17 @@
|
||||
⚠️ band 必须在用它的标题之前声明(11-02 曾写反 → const 暂时性死区报错,「查看全部」点了没反应) */
|
||||
const band = (state.postpartum || state.pregEmpty) ? 0 : qaBand(state.week);
|
||||
$('#qaTitle').textContent = '其他孕妈也在搜';
|
||||
$('#qaHeroW').textContent = band ? '孕 ' + state.week + ' 周' : '大家都在问';
|
||||
$('#qaHeroT').textContent = '妈妈们最常问的问题';
|
||||
$('#qaHeroD').textContent = bank.length + ' 个问题 · 点开看答案';
|
||||
/* 11-02 用户二改:不要「正在看」和热度条,每条只显示「N 人看过」(= 「此刻」总人数 × heat,同首页;模拟数,AGENTS.md 12b);
|
||||
前 10 名像微博热搜挂小标:第 1 爆、2~7 热、8~10 新,其余不挂(11-03 用户:不要「沸」,用「热」) */
|
||||
/* 11-03 用户:「孕期百问列表太素、看的人少,做得有设计感一点」→
|
||||
Banner 加头像叠 + 「N 万孕妈在这找答案」;前 3 条做成「本周热问」大卡(渐变名次 + 答案摘要);其余为卡片行:问题 + 分类彩签 + 火苗人数 + 一行答案摘要 */
|
||||
const tot = (window.__mbPulse && window.__mbPulse.total && +window.__mbPulse.total.value) || 1510000;
|
||||
const QA_BD = i => i < 1 ? ['爆', 'bao'] : i < 7 ? ['热', 're'] : i < 10 ? ['新', 'xin'] : null;
|
||||
const wan = n => n >= 1e4 ? (Math.round(n / 1e3) / 10) + '万' : String(Math.round(n));
|
||||
$('#qaHeroW').textContent = band ? '孕 ' + state.week + ' 周' : '大家都在问';
|
||||
$('#qaHeroT').textContent = '孕妈最常问的问题';
|
||||
const s0 = ((state.week || 1) * 5) % AVA_TOP.length;
|
||||
$('#qaHeroD').innerHTML = '<span class="qa-avs">' + [0, 1, 2, 3, 4].map(i => avaImg(AVA_TOP[(s0 + i * 2) % AVA_TOP.length])).join('') + '</span>' + wan(tot * 0.62) + ' 孕妈在这找答案';
|
||||
const QA_BD = i => i < 1 ? ['爆', 'bao'] : i < 7 ? ['热', 're'] : i < 10 ? ['新', 'xin'] : null;
|
||||
const QA_EM = { 身体: '🤰', 准备: '📋', 产检: '🩺', 宝宝: '👶', 生活: '🏠', 营养: '🥗', 职场: '💼', 花钱: '💰', 心情: '💗', 趣味: '🎈', 补剂: '💊', 专题: '📌' };
|
||||
const QA_TC = { 身体: 'c1', 准备: 'c2', 产检: 'c3', 宝宝: 'c4', 生活: 'c5', 营养: 'c6', 职场: 'c2', 花钱: 'c6', 心情: 'c1', 趣味: 'c4', 补剂: 'c3', 专题: 'c5' };
|
||||
$('#qaTopic').classList.add('hide');
|
||||
const inBand = x => !!(band && x.st && x.st.indexOf(band) >= 0);
|
||||
const order = bank.filter(x => x.href === QA_FIXED)
|
||||
@@ -5600,28 +5607,32 @@
|
||||
['全部'].concat(cats).forEach(c => {
|
||||
const b = document.createElement('button');
|
||||
b.type = 'button'; b.className = 'qa-cat'; b.dataset.cat = c;
|
||||
b.textContent = c === '__st' ? '孕 ' + state.week + ' 周' : c;
|
||||
const sm = document.createElement('small'); sm.textContent = c === '全部' ? bank.length : c === '__st' ? bank.filter(inBand).length : bank.filter(x => x.tag === c).length;
|
||||
b.appendChild(sm);
|
||||
b.textContent = c === '__st' ? '⏳ 孕 ' + state.week + ' 周' : c === '全部' ? '✨ 全部' : (QA_EM[c] ? QA_EM[c] + ' ' : '') + c;
|
||||
b.addEventListener('click', () => qaFilter(c));
|
||||
cb.appendChild(b);
|
||||
});
|
||||
const L = $('#qaList');
|
||||
L.textContent = '';
|
||||
const sec = (t, d) => { const h = document.createElement('div'); h.className = 'qa-sec'; h.innerHTML = '<b>' + t + '</b><small>' + d + '</small>'; L.appendChild(h); };
|
||||
const snip = a => (a || '').replace(/\s+/g, ' ').trim();
|
||||
order.forEach((x, i) => {
|
||||
if (i === 0) sec('🔥 本周热问', '看的人最多的 3 个问题');
|
||||
if (i === 3) sec('全部问题', '点开就有答案');
|
||||
const it = document.createElement('div');
|
||||
it.className = 'qa-it' + (i < 6 ? ' top' : '');
|
||||
it.className = 'qa-it' + (i < 3 ? ' t3 r' + (i + 1) : '');
|
||||
it.dataset.cat = x.tag || '';
|
||||
if (inBand(x)) it.dataset.st = '1';
|
||||
const h = document.createElement('button'); h.type = 'button'; h.className = 'qa-q';
|
||||
const no = document.createElement('i'); no.className = 'qa-no'; no.textContent = i + 1;
|
||||
const no = document.createElement('i'); no.className = 'qa-no'; no.textContent = i < 9 ? '0' + (i + 1) : i + 1;
|
||||
const t = document.createElement('span'); t.className = 'qa-m';
|
||||
const tq = document.createElement('span'); tq.className = 'qa-tx'; tq.textContent = x.q; t.appendChild(tq);
|
||||
if (+x.heat) {
|
||||
const st = document.createElement('span'); st.className = 'qa-st';
|
||||
st.textContent = wan(tot * +x.heat) + ' 人看过';
|
||||
t.appendChild(st);
|
||||
}
|
||||
const mt = document.createElement('span'); mt.className = 'qa-mt';
|
||||
if (x.tag) mt.insertAdjacentHTML('beforeend', '<em class="qa-tg ' + (QA_TC[x.tag] || 'c5') + '">' + x.tag + '</em>');
|
||||
if (+x.heat) mt.insertAdjacentHTML('beforeend', '<span class="qa-st">' + MS_FIRE + '<b>' + wan(qaViews(x.heat)) + '</b>人看过</span>');
|
||||
t.appendChild(mt);
|
||||
const sn = snip(x.a);
|
||||
if (sn) { const p = document.createElement('span'); p.className = 'qa-sn'; p.textContent = sn; t.appendChild(p); }
|
||||
else if (x.href) { const p = document.createElement('span'); p.className = 'qa-sn go'; p.textContent = '点开看专题,一次讲清楚 ›'; t.appendChild(p); }
|
||||
const bd = QA_BD(i), g = document.createElement('span');
|
||||
if (bd) { g.className = 'qa-bd ' + bd[1]; g.textContent = bd[0]; }
|
||||
const ch = document.createElement('i'); ch.className = 'qa-ch'; ch.textContent = '›';
|
||||
@@ -5638,8 +5649,9 @@
|
||||
const body = $('#detailQA .detail-body');
|
||||
body.scrollTop = 0;
|
||||
const fi = focus != null ? order.indexOf(bank[focus]) : -1;
|
||||
if (fi >= 0 && L.children[fi] && !bank[focus].href) {
|
||||
const c = L.children[fi];
|
||||
const its = L.querySelectorAll('.qa-it');
|
||||
if (fi >= 0 && its[fi] && !bank[focus].href) {
|
||||
const c = its[fi];
|
||||
c.classList.add('open');
|
||||
setTimeout(() => {
|
||||
body.scrollTo({ top: Math.max(0, c.getBoundingClientRect().top - body.getBoundingClientRect().top + body.scrollTop - 12), behavior: 'smooth' });
|
||||
@@ -5650,6 +5662,7 @@
|
||||
function qaFilter(c) {
|
||||
$$('#qaCats .qa-cat').forEach(b => b.classList.toggle('on', b.dataset.cat === c));
|
||||
$$('#qaList .qa-it').forEach(it => it.classList.toggle('hide', c === '__st' ? it.dataset.st !== '1' : c !== '全部' && it.dataset.cat !== c));
|
||||
const L = $('#qaList'); if (L) L.classList.toggle('flt', c !== '全部'); /* 筛选时不分「本周热问 / 全部问题」两段 */
|
||||
}
|
||||
(function () {
|
||||
const all = $('#msAll'); if (all) all.addEventListener('click', () => loadQA().then(() => openQA())); /* 11-02 合并版里原模块可能没渲染过,先确保问题库到手 */
|
||||
|
||||
@@ -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=26110265'; fs.onload = fs.onerror = init; document.body.appendChild(fs); }
|
||||
else { var fs = document.createElement('script'); fs.src = 'guangchang/feed.js?v=26110266'; fs.onload = fs.onerror = init; document.body.appendChild(fs); }
|
||||
})();
|
||||
|
||||
@@ -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=26110265';
|
||||
var l = document.createElement('link'); l.rel = 'stylesheet'; l.href = 'js/gch/v4.css?v=26110266';
|
||||
document.head.appendChild(l);
|
||||
var s = document.createElement('script'); s.src = 'js/gch/v4.js?v=26110265';
|
||||
var s = document.createElement('script'); s.src = 'js/gch/v4.js?v=26110266';
|
||||
s.onload = function () { if (sec.querySelector('.g4-foot')) merge(); else sec.addEventListener('gc4-ready', merge, { once: true }); }; /* v4 要先拉 feed.js 才渲染 */
|
||||
document.body.appendChild(s);
|
||||
|
||||
|
||||
@@ -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 = '26110265';
|
||||
var V = '26110266';
|
||||
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');
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
var skip = ['topic/huafei/', 'topic/ceshi/', 'topic/duiyou/', 'topic/zhichang/'];
|
||||
var all = window.__mbQaPick ? window.__mbQaPick(QA, wk, 40) : QA;
|
||||
all.filter(function (x) { return x.href && skip.indexOf(x.href) < 0; }).slice(0, 2).forEach(function (x) {
|
||||
out.qa.push({ q: x.q, href: x.href + location.search + location.hash, n: total() * (+x.heat || .03), u: '人看过' });
|
||||
out.qa.push({ q: x.q, href: x.href + location.search + location.hash, n: window.__mbQaViews ? window.__mbQaViews(+x.heat || .03) : total() * (+x.heat || .03), u: '人看过' /* 11-03 同百问列表页口径 */ });
|
||||
});
|
||||
}
|
||||
var cl = CALC.filter(function (x) { return !(x.gate && wk && wk < x.gate); });
|
||||
|
||||
Reference in New Issue
Block a user