其他妈妈也在搜:首页固定为参考图6问,全部24问+测一测小测试,头像10个 v26103109
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
26
assets/data/qa/hot.json
Normal file
26
assets/data/qa/hot.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[
|
||||||
|
{"q":"生娃计算器,到底要花多少钱?","tag":"花钱","hot":true,"a":"生娃的钱主要分四块:①孕期产检(建档、常规产检、NT、唐筛或无创、大排畸、糖耐等);②分娩住院(顺产比剖宫产便宜,公立比私立便宜,单人间另算);③月子(在家坐月子主要是营养和用品,请月嫂或去月子中心差别很大);④宝宝第一年(奶粉、纸尿裤、衣物、疫苗中的自费部分、玩具和绘本)。各城市、各医院价格差得很多,最准的算法是:问一下建档医院的分娩套餐价,再按自己的月子方式和喂养方式逐项估。别忘了生育保险:参保满足条件的,产检和分娩费用可以报销,还能领生育津贴,提前问清单位人事和当地医保。"},
|
||||||
|
{"q":"测一测你是什么样的妈妈?","tag":"趣味","hot":true,"quiz":true,"a":"5 道小题,30 秒测出你的妈妈类型,看看哪种带娃方式最适合你。"},
|
||||||
|
{"q":"孕期营养影响孩子智商吗?","tag":"营养","hot":true,"a":"孕期营养会影响宝宝大脑发育,但「吃什么就能变聪明」是夸大说法。真正要紧的是别缺:孕早期叶酸关系到神经管发育;碘是甲状腺激素的原料,影响大脑发育,平时吃加碘盐、每周吃一两次海带紫菜即可;DHA 可以通过每周吃两三次鱼虾来补;铁不够会贫血,影响宝宝供氧。做到饮食均衡、体重增长合适、按时产检,就已经给了宝宝大脑最好的营养基础。孩子以后聪不聪明,还和遗传、出生后的陪伴和教育关系很大,不用因为某顿没吃好而焦虑。"},
|
||||||
|
{"q":"叶酸、DHA、铁、钙要不要补?","tag":"补剂","hot":true,"a":"叶酸:要补。备孕前 3 个月到孕早期每天 0.4mg,很多医生会建议吃到整个孕期,有特殊情况医生会调整剂量。铁:孕中晚期需要量大增,先多吃红肉、动物血、肝脏,产检查出贫血再按医生建议吃铁剂。钙:孕中期起每天约需 1000mg,每天 500ml 左右的奶或奶制品加豆制品、绿叶菜,基本能吃够;喝奶少的可以在医生指导下补钙片。DHA:每周吃 2~3 次鱼(优先三文鱼、鳕鱼、沙丁鱼这类低汞鱼)一般就够,吃鱼少的可以考虑补充。补剂不是越多越好,拿不准就带着清单问产检医生。"},
|
||||||
|
{"q":"孕妈产后复工,职场维权指南","tag":"职场","hot":true,"a":"这几条是国家《女职工劳动保护特别规定》写明的:①孕期、产期、哺乳期,单位不能因为怀孕生育降低工资、辞退或单方解除劳动合同;②产假不少于 98 天(产前可休 15 天),难产增加 15 天,多胞胎每多一个增加 15 天,各省还有延长奖励假,以当地规定为准;③产检时间算劳动时间,不能扣工资;④怀孕 7 个月以上,单位不能延长工作时间或安排夜班,并应安排一定休息时间;⑤宝宝 1 岁内,每天有 1 小时哺乳时间。遇到不公平对待,先保留书面证据(通知、聊天记录、工资条),可以向当地劳动监察部门投诉或申请劳动仲裁。"},
|
||||||
|
{"q":"妊娠纹,与体重管理","tag":"专题","hot":true,"href":"topic/wen/","a":"妊娠纹和体重增长快慢关系很大,控制好体重是最省钱的预防办法。点进去看专题:为什么会长、不同阶段抹什么、成分怎么挑。"},
|
||||||
|
{"q":"怀孕后什么时候去医院建档?","tag":"产检","a":"一般在孕 6~8 周做第一次 B 超确认宫内孕、看到胎心胎芽后,就可以着手准备建档,多数医院在孕 12 周左右正式建档,并同时做 NT 检查。热门医院床位紧张,有的需要提前预约,最好早点打电话或在医院公众号上查清楚流程。建档一般要带身份证、医保卡、母子健康手册(或社区开的建册证明)和之前的检查报告。"},
|
||||||
|
{"q":"唐筛、无创、羊穿,该怎么选?","tag":"产检","a":"三者都是查染色体问题,但准确度和风险不同。唐筛是抽血筛查,便宜无创伤,但准确度最低;无创 DNA 也是抽血,准确度明显高于唐筛,费用更高;羊水穿刺是诊断,结果最准,但属于有创操作,有很小的流产风险。一般没有高危因素的妈妈可以先做唐筛或无创;年龄偏大、筛查高风险、有家族史或 B 超发现异常的,医生会建议直接做羊穿。具体按产检医生的建议来。"},
|
||||||
|
{"q":"孕期体重长多少合适?","tag":"身体","a":"看孕前体重来定:孕前偏瘦的,整个孕期可以长得多一些;体重正常的,一般建议长 8~14kg 左右;偏胖或肥胖的要长得更少。孕早期变化不大,孕中晚期每周增长约 0.3~0.5kg 比较合适。长得太快容易出现妊娠期糖尿病、高血压、巨大儿,还更容易长妊娠纹;长得太少又可能影响宝宝发育。可以用首页的「孕期体重」每周记一次,看看自己在不在合理范围。"},
|
||||||
|
{"q":"孕期能喝咖啡、奶茶吗?","tag":"营养","a":"可以少量喝。孕期每天咖啡因建议不超过 200mg,大约是一杯中杯美式。要注意奶茶、浓茶、可乐、巧克力里也有咖啡因,要一起算。奶茶的问题更多在糖分高,喝多了体重和血糖都容易超标,想喝可以选小杯、少糖或无糖,一周偶尔一两次就好。"},
|
||||||
|
{"q":"怀孕了还能养猫、养狗吗?","tag":"生活","a":"大多数情况下可以继续养。养猫主要担心弓形虫:室内长期饲养、只吃猫粮、不外出的猫感染概率很低。孕期尽量让家人铲屎,自己要铲的话戴手套、铲完洗手,每天及时清理猫砂。不要喂生肉,自己也别吃没熟的肉,处理生肉后洗手。可以在孕前或孕早期查一下弓形虫抗体,心里更有底。狗狗要按时打疫苗驱虫,避免被抓伤咬伤。"},
|
||||||
|
{"q":"孕期可以染发、烫发吗?","tag":"生活","a":"建议尽量避开,尤其是孕早期宝宝器官形成的关键阶段。染发烫发剂里的化学成分通过头皮吸收的量很少,目前没有确切证据说明会伤害宝宝,但出于谨慎,孕期能不做就不做。实在需要,等到孕中期后,选择通风好的店,挑选不接触头皮的挑染,缩短停留时间。剪发、普通洗护不受影响。"},
|
||||||
|
{"q":"孕期能坐飞机、出远门吗?","tag":"生活","a":"孕中期(孕 14~27 周)身体最舒服,是出行最合适的时候。孕早期反应大、孕晚期有早产风险,尽量少长途出行。多数航空公司对孕 32 周以上的孕妈有限制,需要医生开具适宜乘机的证明,36 周以上一般不能乘机,具体看航司规定。出行时穿宽松衣服和舒适的鞋,每隔 1 小时起来活动一下,多喝水,带好产检资料。有出血、前置胎盘、早产迹象的要遵医嘱,不要出行。"},
|
||||||
|
{"q":"孕期能运动吗?做什么运动好?","tag":"身体","a":"没有医生明确禁止的话,孕期适当运动对妈妈和宝宝都有好处,能控制体重、减少腰背痛、改善睡眠,也有助于顺产。推荐散步、游泳、孕妇瑜伽、固定单车等低冲击运动,每周累计 150 分钟左右,以运动时还能正常说话为度。避免跳跃、对抗性运动、容易摔倒的运动和仰卧太久。运动中出现出血、腹痛、头晕、胸闷、流液要马上停下并就医。"},
|
||||||
|
{"q":"孕吐什么时候能结束?","tag":"身体","a":"孕吐一般在孕 6 周左右开始,孕 8~10 周最明显,大多数妈妈在孕 12~14 周后逐渐减轻。缓解小办法:少量多餐,别让胃空着;早上起床前先吃几块苏打饼干;避开油腻和气味重的食物;吃点姜味食物或酸味水果。如果吐得什么都吃不下、喝水也吐、尿很少、体重明显下降,可能是妊娠剧吐,要及时去医院补液治疗。"},
|
||||||
|
{"q":"什么时候能感觉到胎动?","tag":"宝宝","a":"第一胎的妈妈一般在孕 18~20 周第一次感觉到胎动,二胎妈妈经验多,可能早到 16 周左右。最开始的胎动很轻,像小鱼吐泡泡或肚子里冒泡。孕 28 周以后要每天留意胎动,可以用首页的「数胎动」记录:如果胎动明显减少、比平时弱很多或突然特别频繁,要及时去医院。"},
|
||||||
|
{"q":"顺产还是剖宫产,怎么选?","tag":"准备","a":"没有医学指征时,一般更推荐顺产:产后恢复快、住院时间短,宝宝经过产道挤压,对呼吸系统也有好处。剖宫产是解决难产和高危情况的重要手段,比如胎位不正、前置胎盘、胎儿窘迫、骨盆过小等,由医生评估决定。害怕疼的话,可以了解一下医院有没有无痛分娩(分娩镇痛)。具体分娩方式要和产检医生一起商量。"},
|
||||||
|
{"q":"待产包要准备些什么?","tag":"准备","a":"建议孕 32~35 周前准备好,放在门口方便拿。证件类:身份证、医保卡、母子健康手册、产检资料。妈妈用品:产褥垫、一次性内裤、哺乳内衣、防溢乳垫、吸管杯、拖鞋、洗漱用品、宽松保暖的衣服。宝宝用品:新生儿纸尿裤、包被、和尚服、口水巾、湿巾,以及出院穿的衣服。医院提供的物品不一样,提前问清楚可以少带很多。首页「待产清单」可以帮你逐项勾选。"},
|
||||||
|
{"q":"生育津贴怎么领?能领多少?","tag":"花钱","a":"生育津贴由生育保险支付,一般条件是:产前单位为你连续缴纳生育保险(职工医保)满一定月数,具体月数各地不同。金额通常是:单位上年度职工月平均工资 ÷ 30 × 产假天数。多数地方由单位统一申请,也有的可以个人在当地医保 App 或线上服务平台申请,需要准备出生医学证明、住院病历等材料。具体条件和流程以当地医保部门为准,可以提前问单位人事。"},
|
||||||
|
{"q":"孕期失眠、睡不好怎么办?","tag":"身体","a":"孕期睡不好很常见,原因有尿频、腿抽筋、胃灼热、肚子大翻身难,还有焦虑。可以试试:睡前 2 小时少喝水;晚饭别太饱,吃完别马上躺下;左侧卧,在两腿之间、肚子下面垫个孕妇枕;白天适当运动,但睡前别剧烈运动;固定作息,睡前少看手机。腿抽筋的话多晒太阳、吃奶制品,产检时问问医生需不需要补钙。长期严重失眠或情绪低落,要告诉医生。"},
|
||||||
|
{"q":"孕期便秘怎么缓解?","tag":"身体","a":"孕激素让肠道蠕动变慢,加上子宫压迫和补铁,孕期便秘很常见。先从生活入手:每天喝够 1500~1700ml 水;多吃蔬菜、水果、粗杂粮、薯类,增加膳食纤维;每天适当散步;养成定时排便的习惯,不要憋。不要自己乱用泻药或开塞露,如果几天都排不出、肚子胀痛或便中带血,要问医生,用孕期安全的药物。"},
|
||||||
|
{"q":"孕期可以同房吗?","tag":"生活","a":"孕期一切正常的话,可以有温和的性生活,一般建议避开孕早期前 3 个月和孕晚期最后 1 个月。注意动作轻柔、避免压迫腹部,选择舒适的体位,最好使用避孕套减少感染。如果有阴道出血、前置胎盘、先兆流产或早产迹象、宫颈机能不全、胎膜早破等情况,要禁止同房,听医生的。同房后出现腹痛、出血、流液要及时就医。"},
|
||||||
|
{"q":"孕期情绪低落、焦虑怎么办?","tag":"心情","a":"孕期激素变化大,再加上身体不舒服和对未来的担心,情绪起伏很正常。试着把担心说出来,和老公、家人或其他孕妈聊聊;每天留点时间做喜欢的事,散步、听音乐、晒太阳;少在网上搜吓人的个例;规律作息,适当运动。如果连续两周以上情绪低落、对什么都提不起兴趣、睡不着或总想哭,甚至有伤害自己的念头,要及时告诉产检医生,寻求专业帮助。"},
|
||||||
|
{"q":"准爸爸孕期能帮上什么忙?","tag":"心情","a":"准爸爸的陪伴对孕妈很重要。可以做这些:尽量陪着去产检,一起了解宝宝的情况;承担家务,特别是铲猫砂、搬重物、做饭;晚上帮她按摩腿脚、垫好孕妇枕;和她一起学分娩和新生儿护理知识,准备待产包;每天和宝宝说说话、讲故事;多听她倾诉,别说「别人都这样」。孕晚期保持电话畅通,提前规划好去医院的路线。"}
|
||||||
|
]
|
||||||
23
index.html
23
index.html
@@ -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:26103108 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
<!-- V:26103109 缓存版本标记:改 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) -->
|
||||||
@@ -405,9 +405,8 @@
|
|||||||
写「明天见」—— 让每天回来看一条,而不是一口气翻完。 -->
|
写「明天见」—— 让每天回来看一条,而不是一口气翻完。 -->
|
||||||
<section class="preg-tips hide" id="pregTips">
|
<section class="preg-tips hide" id="pregTips">
|
||||||
<!-- 2026-10-31 用户定:「孕期小知识」首页这块改成「其他妈妈也在搜」(照用户给的参考图):
|
<!-- 2026-10-31 用户定:「孕期小知识」首页这块改成「其他妈妈也在搜」(照用户给的参考图):
|
||||||
黄色荧光笔大标题 + 一排妈妈头像 + 6 条问题,每条点进去都有内容 ——
|
黄色荧光笔大标题 + 一排 10 个妈妈头像 + 参考图上那 6 个问题(固定,assets/data/qa/hot.json 前 6 条),
|
||||||
妊娠纹专题(孕 12 周起)、今天 / 昨天的小知识、宝宝这周、妈妈身体、吃点什么、这周留心(后几条进 #detailTips)。
|
其余问题在「查看全部」进的 #detailQA 里。渲染在 app.js renderSearch()。 -->
|
||||||
问题按孕周每周自动换(assets/data/preg-tips.json),渲染在 app.js renderTips()。 -->
|
|
||||||
<div class="ms-head">
|
<div class="ms-head">
|
||||||
<h2 class="ms-title"><span>其他妈妈也在搜</span></h2>
|
<h2 class="ms-title"><span>其他妈妈也在搜</span></h2>
|
||||||
<span class="ms-wk" id="msWk"></span>
|
<span class="ms-wk" id="msWk"></span>
|
||||||
@@ -1322,7 +1321,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ================= 其他妈妈也在搜 · 全部问题(2026-10-31)=================
|
<!-- ================= 其他妈妈也在搜 · 全部问题(2026-10-31)=================
|
||||||
首页 #pregTips 只露 6 条,其余在这里:按孕周取 assets/data/qa/<周>.json(孕 4–40 周,每周 18 条问答),
|
首页 #pregTips 只露 6 条,其余在这里:取 assets/data/qa/hot.json(24 条,前 6 条是首页那 6 个),
|
||||||
分类筛选 + 点开看答案;从首页点某一条进来,自动展开并滚到那一条。渲染在 app.js openQA()。 -->
|
分类筛选 + 点开看答案;从首页点某一条进来,自动展开并滚到那一条。渲染在 app.js openQA()。 -->
|
||||||
<section class="detail" id="detailQA">
|
<section class="detail" id="detailQA">
|
||||||
<div class="detail-bar">
|
<div class="detail-bar">
|
||||||
@@ -1376,6 +1375,18 @@
|
|||||||
.qa-it.open .qa-a{display:block}
|
.qa-it.open .qa-a{display:block}
|
||||||
.qa-it.hit{animation:qaHit 1.2s ease}
|
.qa-it.hit{animation:qaHit 1.2s ease}
|
||||||
@keyframes qaHit{0%,40%{box-shadow:0 0 0 2px #F4593C}100%{box-shadow:0 2px 8px rgba(190,120,100,.07)}}
|
@keyframes qaHit{0%,40%{box-shadow:0 0 0 2px #F4593C}100%{box-shadow:0 2px 8px rgba(190,120,100,.07)}}
|
||||||
|
.qa-go{display:inline-block;margin-top:8px;font-weight:700;color:#E0573A;text-decoration:none}
|
||||||
|
.qz-lead{margin:0 0 8px;color:#6E5A57}
|
||||||
|
.qz-h{margin:2px 0 8px;font-weight:700;color:#2F2424}
|
||||||
|
.qz-o{display:block;width:100%;margin:0 0 7px;padding:9px 12px;border:1px solid #F1DDD6;border-radius:12px;background:#fff;font:inherit;font-size:14px;color:#3B2A2A;text-align:left}
|
||||||
|
.qz-o:active{background:#FFEDE6;border-color:#F4593C}
|
||||||
|
.qz-r{display:flex;flex-direction:column;align-items:center;gap:4px;padding:6px 0 2px;text-align:center}
|
||||||
|
.qz-r span{font-size:12px;color:#8A7471}
|
||||||
|
.qz-r b{font-size:20px;font-weight:900;color:#E0573A}
|
||||||
|
.qz-r p{margin:2px 0 6px;font-size:14px;color:#4A3B39}
|
||||||
|
.qz-again{padding:6px 14px;border:0;border-radius:99px;background:#F4593C;color:#fff;font:inherit;font-size:13px;font-weight:700}
|
||||||
|
html.night .qz-o{background:#2F2737;border-color:rgba(255,255,255,.12);color:#EFE3EA}
|
||||||
|
html.night .qz-h{color:#F1E6EE}
|
||||||
.qa-more{display:block;margin:16px auto 4px;padding:8px 16px;border-radius:99px;border:1px solid #F1DDD6;background:#fff;font:inherit;font-size:13px;color:#E0573A}
|
.qa-more{display:block;margin:16px auto 4px;padding:8px 16px;border-radius:99px;border:1px solid #F1DDD6;background:#fff;font:inherit;font-size:13px;color:#E0573A}
|
||||||
html.night .qa-hero b,html.night .qa-tx,html.night .qa-topic b{color:#F1E6EE}
|
html.night .qa-hero b,html.night .qa-tx,html.night .qa-topic b{color:#F1E6EE}
|
||||||
html.night .qa-it,html.night .qa-cat,html.night .qa-more{background:#2F2737;border-color:rgba(255,255,255,.1);box-shadow:none}
|
html.night .qa-it,html.night .qa-cat,html.night .qa-more{background:#2F2737;border-color:rgba(255,255,255,.1);box-shadow:none}
|
||||||
@@ -2202,7 +2213,7 @@
|
|||||||
<!-- 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=26101211"></script>
|
||||||
<script src="js/birth-flow.js?v=26103108"></script>
|
<script src="js/birth-flow.js?v=26103109"></script>
|
||||||
|
|
||||||
<!-- 禁止下拉回弹(2026-10-11 统一规则,与孕期体重同一段):竖向拖动时从手指下往上找还能朝该方向滚的容器,找不到才拦;横滑、双指、可滚列表不受影响 -->
|
<!-- 禁止下拉回弹(2026-10-11 统一规则,与孕期体重同一段):竖向拖动时从手指下往上找还能朝该方向滚的容器,找不到才拦;横滑、双指、可滚列表不受影响 -->
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
118
js/app.js
118
js/app.js
@@ -3,7 +3,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||||
var VER = '26103108';
|
var VER = '26103109';
|
||||||
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));
|
||||||
|
|
||||||
@@ -5057,77 +5057,106 @@
|
|||||||
sec.classList.remove('hide');
|
sec.classList.remove('hide');
|
||||||
revealTipsGrid();
|
revealTipsGrid();
|
||||||
}
|
}
|
||||||
/* 2026-10-31 首页「其他妈妈也在搜」:问题库 assets/data/qa/<周>.json(孕 4–40 周,每周 18 条问答),
|
/* 2026-10-31 首页「其他妈妈也在搜」(用户给了参考图,定了问题):问题库 assets/data/qa/hot.json,共 24 条,
|
||||||
首页只露 6 条(孕 12 周起第一条是妊娠纹专题),点任意一条 / 「查看全部」进 #detailQA 看答案和其余问题。
|
前 6 条就是参考图上那 6 个问题,首页只露这 6 条;点任意一条 / 「查看全部」进 #detailQA 看答案和其余问题。
|
||||||
问题库没加载到时退回 6 条本周小知识入口(落点 #detailTips),首页不空。 */
|
条目字段:q 问题 / a 答案 / tag 分类 / hot 热 / href 有专题页的直接跳 / quiz 答案区是「测一测」小测试。
|
||||||
|
问题库没加载到时退回 5 条本周小知识入口(落点 #detailTips),首页不空。 */
|
||||||
let QA = null, qaLoading = null;
|
let QA = null, qaLoading = null;
|
||||||
/* 按周拆成小文件 assets/data/qa/<周>.json(每份约 6KB),只拉当前孕周;孕周变了再拉新的一份 */
|
|
||||||
function loadQA() {
|
function loadQA() {
|
||||||
const w = qaWeek();
|
if (QA) return Promise.resolve(QA);
|
||||||
if (QA && QA[w]) return Promise.resolve(QA);
|
if (!qaLoading) qaLoading = fetch('assets/data/qa/hot.json?v=' + VER).then(r => (r.ok ? r.json() : [])).catch(() => [])
|
||||||
if (!qaLoading || qaLoading.w !== w) {
|
.then(a => (QA = Array.isArray(a) ? a : []));
|
||||||
qaLoading = fetch('assets/data/qa/' + w + '.json?v=' + VER).then(r => (r.ok ? r.json() : [])).catch(() => [])
|
|
||||||
.then(a => { QA = QA || {}; QA[w] = Array.isArray(a) ? a : []; return QA; });
|
|
||||||
qaLoading.w = w;
|
|
||||||
}
|
|
||||||
return qaLoading;
|
return qaLoading;
|
||||||
}
|
}
|
||||||
const QA_CATS = ['产检', '身体', '饮食', '补剂', '宝宝', '生活', '心情', '准备'];
|
const qaHref = h => h + location.search + location.hash;
|
||||||
let qaCat = '全部';
|
|
||||||
function qaWeek() { return Math.max(4, Math.min(40, state.week || 0)); }
|
|
||||||
function renderSearch(wk, today, size) {
|
function renderSearch(wk, today, size) {
|
||||||
const W = state.week, L = $('#msList');
|
const W = state.week, L = $('#msList');
|
||||||
if (!L) return;
|
if (!L) return;
|
||||||
if (!QA || !QA[qaWeek()]) { loadQA().then(q => { if (q[qaWeek()] && q[qaWeek()].length) renderSearch(wk, today, size); }); }
|
if (!QA) loadQA().then(q => { if (q.length) renderSearch(wk, today, size); });
|
||||||
$('#msWk').textContent = '孕 ' + W + ' 周';
|
$('#msWk').textContent = '孕 ' + W + ' 周';
|
||||||
$('#msCnt').textContent = '孕 ' + W + ' 周的妈妈都在看';
|
$('#msCnt').textContent = '孕 ' + W + ' 周的妈妈都在看';
|
||||||
const pool = AVA_TOP.concat(AVA_FEED), s0 = (W * 7) % pool.length;
|
const pool = AVA_TOP.concat(AVA_FEED), s0 = (W * 7) % pool.length;
|
||||||
$('#msAvs').innerHTML = [0, 1, 2, 3, 4, 5, 6, 7].map(i => avaImg(pool[(s0 + i * 3) % pool.length])).join('');
|
$('#msAvs').innerHTML = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(i => avaImg(pool[(s0 + i * 3) % pool.length])).join('');
|
||||||
const bank = (QA && QA[qaWeek()]) || [];
|
const bank = QA || [];
|
||||||
const items = [];
|
let items;
|
||||||
if (W >= 12) items.push({ q: '妊娠纹怎么防?现在该抹什么', tag: '专题', cls: 'hot', href: 'topic/wen/' + location.search + location.hash });
|
|
||||||
if (bank.length) {
|
if (bank.length) {
|
||||||
bank.slice(0, 6 - items.length).forEach((x, i) => items.push({ q: x.q, tag: x.hot ? '热' : '', cls: 'hot', qa: i }));
|
items = bank.slice(0, 6).map((x, i) => ({ q: x.q, href: x.href ? qaHref(x.href) : '', qa: i }));
|
||||||
} else {
|
} else {
|
||||||
const q = t => /[??吗呢]$/.test(t) ? t : t + (/怎么办|什么|多少|怎么|几/.test(t) ? '?' : '');
|
const q = t => /[??吗呢]$/.test(t) ? t : t + (/怎么办|什么|多少|怎么|几/.test(t) ? '?' : '');
|
||||||
const d0 = wk.days[today];
|
const d0 = wk.days[today];
|
||||||
if (d0 && d0.t) items.push({ q: q(d0.t), tag: '今日', cls: 'new', pt: '' });
|
items = [];
|
||||||
items.push({ q: '孕' + W + '周,宝宝长多大了?', tag: '热', cls: 'hot', pt: 'baby' });
|
if (d0 && d0.t) items.push({ q: q(d0.t), pt: '' });
|
||||||
|
items.push({ q: '孕' + W + '周,宝宝长多大了?', pt: 'baby' });
|
||||||
items.push({ q: '这周身体会有哪些变化?', pt: 'mom' });
|
items.push({ q: '这周身体会有哪些变化?', pt: 'mom' });
|
||||||
items.push({ q: '孕' + W + '周吃什么对宝宝好?', pt: 'eat' });
|
items.push({ q: '孕' + W + '周吃什么对宝宝好?', pt: 'eat' });
|
||||||
items.push({ q: '这周产检和生活要留心什么?', pt: 'care' });
|
items.push({ q: '这周产检和生活要留心什么?', pt: 'care' });
|
||||||
}
|
}
|
||||||
L.textContent = '';
|
L.textContent = '';
|
||||||
items.slice(0, 6).forEach((it, i) => {
|
items.forEach((it, i) => {
|
||||||
const el = document.createElement(it.href ? 'a' : 'button');
|
const el = document.createElement(it.href ? 'a' : 'button');
|
||||||
el.className = 'ms-it ripple';
|
el.className = 'ms-it ripple';
|
||||||
if (it.href) el.href = it.href;
|
if (it.href) el.href = it.href;
|
||||||
else { el.type = 'button'; el.addEventListener('click', () => (it.qa != null ? openQA(it.qa) : openTips(it.pt))); }
|
else { el.type = 'button'; el.addEventListener('click', () => (it.qa != null ? openQA(it.qa) : openTips(it.pt))); }
|
||||||
const no = document.createElement('i'); no.className = 'ms-no'; no.textContent = i + 1;
|
const no = document.createElement('i'); no.className = 'ms-no'; no.textContent = i + 1;
|
||||||
const t = document.createElement('span'); t.className = 'ms-q'; t.textContent = it.q;
|
const t = document.createElement('span'); t.className = 'ms-q'; t.textContent = it.q;
|
||||||
el.appendChild(no); el.appendChild(t);
|
const go = document.createElement('i'); go.className = 'ms-go'; go.textContent = '›';
|
||||||
if (it.tag) { const g = document.createElement('span'); g.className = 'ms-tag' + (it.cls ? ' ' + it.cls : ''); g.textContent = it.tag; el.appendChild(g); }
|
el.appendChild(no); el.appendChild(t); el.appendChild(go);
|
||||||
const go = document.createElement('i'); go.className = 'ms-go'; go.textContent = '›'; el.appendChild(go);
|
|
||||||
L.appendChild(el);
|
L.appendChild(el);
|
||||||
});
|
});
|
||||||
const all = $('#msAll');
|
const all = $('#msAll');
|
||||||
if (all) {
|
if (all) {
|
||||||
const n = bank.length + (W >= 12 ? 1 : 0);
|
all.classList.toggle('hide', bank.length <= 6);
|
||||||
all.classList.toggle('hide', !bank.length);
|
all.textContent = '查看全部 ' + bank.length + ' 个问题 ›';
|
||||||
all.textContent = '查看全部 ' + n + ' 个问题 ›';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* 全部问题页:focus = 从首页点的那条在本周问题库里的下标(展开 + 滚到它);不传 = 从「查看全部」进来 */
|
/* 「测一测你是什么样的妈妈」:5 题,每个选项记一种类型,选得最多的就是结果。纯娱乐,不存数据 */
|
||||||
|
const QUIZ = [
|
||||||
|
['宝宝哭了,你的第一反应是?', ['马上抱起来哄', '先看看是饿了还是尿了', '等一等,看他能不能自己安静', '先拍下来发家庭群']],
|
||||||
|
['准备待产包,你会怎么做?', ['早早列清单,反复核对', '对照医院和过来人的清单买', '想到什么买什么', '和姐妹们一起逛一起买']],
|
||||||
|
['孕期刷手机,你最常看?', ['宝宝发育和护理知识', '好物测评和攻略', '搞笑视频,放松一下', '晒孕照、看别人的孕期日记']],
|
||||||
|
['宝宝以后上什么兴趣班?', ['从小做好规划', '先了解每种的利弊再定', '他喜欢什么就学什么', '和朋友家孩子一起报']],
|
||||||
|
['理想的周末是?', ['在家布置婴儿房', '去听一场孕妈课堂', '睡到自然醒', '约朋友吃饭拍照']],
|
||||||
|
];
|
||||||
|
const QUIZ_R = [
|
||||||
|
['暖心守护型妈妈', '你的爱藏在每一个细节里,宝宝一有动静你就在身边。记得也照顾好自己,累了就让家人搭把手。'],
|
||||||
|
['理性学习型妈妈', '你相信知识带来的安全感,凡事先了解清楚再行动。别被信息淹没,抓大放小,相信自己的判断。'],
|
||||||
|
['松弛自在型妈妈', '你心态稳、不焦虑,这份松弛感会传递给宝宝。孕期的产检和关键时间点,记得设个提醒。'],
|
||||||
|
['热情分享型妈妈', '你乐于分享,身边总有一群好姐妹。多和过来人交流,但遇到问题以医生的意见为准。'],
|
||||||
|
];
|
||||||
|
function buildQuiz(box) {
|
||||||
|
box.textContent = '';
|
||||||
|
const pick = [];
|
||||||
|
const draw = () => {
|
||||||
|
box.textContent = '';
|
||||||
|
const i = pick.length;
|
||||||
|
if (i >= QUIZ.length) {
|
||||||
|
const cnt = [0, 0, 0, 0]; pick.forEach(k => cnt[k]++);
|
||||||
|
const r = QUIZ_R[cnt.indexOf(Math.max.apply(null, cnt))];
|
||||||
|
box.innerHTML = '<div class="qz-r"><span>你是</span><b></b><p></p><button type="button" class="qz-again">再测一次</button></div>';
|
||||||
|
box.querySelector('b').textContent = r[0]; box.querySelector('p').textContent = r[1];
|
||||||
|
box.querySelector('.qz-again').addEventListener('click', () => { pick.length = 0; draw(); });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const h = document.createElement('div'); h.className = 'qz-h'; h.textContent = (i + 1) + ' / ' + QUIZ.length + ' ' + QUIZ[i][0];
|
||||||
|
box.appendChild(h);
|
||||||
|
QUIZ[i][1].forEach((o, k) => {
|
||||||
|
const b = document.createElement('button'); b.type = 'button'; b.className = 'qz-o'; b.textContent = o;
|
||||||
|
b.addEventListener('click', () => { haptic(); pick.push(k); draw(); });
|
||||||
|
box.appendChild(b);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
/* 全部问题页:focus = 从首页点的那条的下标(展开 + 滚到它);不传 = 从「查看全部」进来 */
|
||||||
function openQA(focus) {
|
function openQA(focus) {
|
||||||
const W = state.week, bank = (QA && QA[qaWeek()]) || [];
|
const bank = QA || [];
|
||||||
if (!bank.length) { openTips(); return; }
|
if (!bank.length) { openTips(); return; }
|
||||||
$('#qaTitle').textContent = '孕 ' + W + ' 周 · 其他妈妈也在搜';
|
$('#qaTitle').textContent = '其他妈妈也在搜';
|
||||||
$('#qaHeroT').textContent = '孕 ' + W + ' 周,妈妈们最常问的 ' + bank.length + ' 个问题';
|
$('#qaHeroT').textContent = '妈妈们最常问的 ' + bank.length + ' 个问题';
|
||||||
$('#qaHeroD').textContent = '点开问题看答案,每周按孕周自动更新';
|
$('#qaHeroD').textContent = '点开问题看答案';
|
||||||
const tp = $('#qaTopic');
|
$('#qaTopic').classList.add('hide');
|
||||||
tp.classList.toggle('hide', !(W >= 12));
|
const cats = [];
|
||||||
tp.setAttribute('href', 'topic/wen/' + location.search + location.hash);
|
bank.forEach(x => { if (x.tag && cats.indexOf(x.tag) < 0) cats.push(x.tag); });
|
||||||
const cats = QA_CATS.filter(c => bank.some(x => x.tag === c));
|
|
||||||
const cb = $('#qaCats');
|
const cb = $('#qaCats');
|
||||||
cb.textContent = '';
|
cb.textContent = '';
|
||||||
['全部'].concat(cats).forEach(c => {
|
['全部'].concat(cats).forEach(c => {
|
||||||
@@ -5143,15 +5172,18 @@
|
|||||||
L.textContent = '';
|
L.textContent = '';
|
||||||
bank.forEach((x, i) => {
|
bank.forEach((x, i) => {
|
||||||
const it = document.createElement('div');
|
const it = document.createElement('div');
|
||||||
it.className = 'qa-it' + (i < 3 ? ' top' : '');
|
it.className = 'qa-it' + (i < 6 ? ' top' : '');
|
||||||
it.dataset.cat = x.tag || '';
|
it.dataset.cat = x.tag || '';
|
||||||
const h = document.createElement('button'); h.type = 'button'; h.className = 'qa-q';
|
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 + 1;
|
||||||
const t = document.createElement('span'); t.className = 'qa-tx'; t.textContent = x.q;
|
const t = document.createElement('span'); t.className = 'qa-tx'; t.textContent = x.q;
|
||||||
const g = document.createElement('span'); g.className = 'qa-tag' + (x.hot ? ' hot' : ''); g.textContent = x.hot ? '热' : (x.tag || '');
|
const g = document.createElement('span'); g.className = 'qa-tag' + (x.hot ? ' hot' : ''); g.textContent = x.tag || '';
|
||||||
const ch = document.createElement('i'); ch.className = 'qa-ch'; ch.textContent = '›';
|
const ch = document.createElement('i'); ch.className = 'qa-ch'; ch.textContent = '›';
|
||||||
h.appendChild(no); h.appendChild(t); if (g.textContent) h.appendChild(g); h.appendChild(ch);
|
h.appendChild(no); h.appendChild(t); if (g.textContent) h.appendChild(g); h.appendChild(ch);
|
||||||
const a = document.createElement('div'); a.className = 'qa-a'; a.textContent = x.a || '';
|
const a = document.createElement('div'); a.className = 'qa-a';
|
||||||
|
if (x.quiz) { const p = document.createElement('p'); p.className = 'qz-lead'; p.textContent = x.a || ''; a.appendChild(p); const qz = document.createElement('div'); qz.className = 'qz'; a.appendChild(qz); buildQuiz(qz); }
|
||||||
|
else a.textContent = x.a || '';
|
||||||
|
if (x.href) { const go = document.createElement('a'); go.className = 'qa-go'; go.href = qaHref(x.href); go.textContent = '进专题页看完整内容 ›'; a.appendChild(go); }
|
||||||
h.addEventListener('click', () => { it.classList.toggle('open'); haptic(); });
|
h.addEventListener('click', () => { it.classList.toggle('open'); haptic(); });
|
||||||
it.appendChild(h); it.appendChild(a);
|
it.appendChild(h); it.appendChild(a);
|
||||||
L.appendChild(it);
|
L.appendChild(it);
|
||||||
@@ -5170,10 +5202,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function qaFilter(c) {
|
function qaFilter(c) {
|
||||||
qaCat = c;
|
|
||||||
$$('#qaCats .qa-cat').forEach(b => b.classList.toggle('on', b.dataset.cat === c));
|
$$('#qaCats .qa-cat').forEach(b => b.classList.toggle('on', b.dataset.cat === c));
|
||||||
$$('#qaList .qa-it').forEach(it => it.classList.toggle('hide', c !== '全部' && it.dataset.cat !== c));
|
$$('#qaList .qa-it').forEach(it => it.classList.toggle('hide', c !== '全部' && it.dataset.cat !== c));
|
||||||
const tp = $('#qaTopic'); if (tp) tp.style.display = c === '全部' ? '' : 'none';
|
|
||||||
}
|
}
|
||||||
(function () {
|
(function () {
|
||||||
const all = $('#msAll'); if (all) all.addEventListener('click', () => openQA());
|
const all = $('#msAll'); if (all) all.addEventListener('click', () => openQA());
|
||||||
|
|||||||
Reference in New Issue
Block a user