孕期计算器新增 10 个(孕周/产检时间表/增重范围/生育津贴/育儿补贴/个税/月子花费/身高/血型/出生后手续),共用 topic/_shared/calc.*,配转发图(v26110299)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
85
topic/_shared/calc.css
Normal file
85
topic/_shared/calc.css
Normal file
@@ -0,0 +1,85 @@
|
||||
/* 孕期计算器共用样式(11-04 新增 10 个计算器共用;预产期计算器 yuchanqi-js 是同款,自带一份没改)。
|
||||
页面在 :root 里改 --c / --cbg / --c2 换主题色。 */
|
||||
:root{--c:#E25C7A;--c2:#FF8FA8;--cbg:#FFEEF2;--h:#1F2329;--t:#4E5969;--m:#86909C;--line:#F1E9EB}
|
||||
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
|
||||
html,body{height:100%;overflow:hidden;background:#fff;color:var(--t);font:15px/1.7 -apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif}
|
||||
#scroll{position:fixed;inset:0;overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior:none;padding-bottom:calc(28px + env(safe-area-inset-bottom))}
|
||||
button,input,select{font:inherit;border:0;background:none;color:inherit}
|
||||
button{cursor:pointer}
|
||||
.num{font-variant-numeric:tabular-nums}
|
||||
.bar{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:4px;height:48px;padding:0 8px;padding-top:env(safe-area-inset-top);border-bottom:1px solid transparent;transition:background .2s,border-color .2s}
|
||||
.bar.on{background:#fff;border-bottom-color:var(--line)}
|
||||
.bar .back{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;color:var(--h)}
|
||||
.bar .back svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
|
||||
.bar .t{font-size:15px;font-weight:700;color:var(--h)}
|
||||
.hd{margin-top:-48px;padding:60px 20px 6px;background:linear-gradient(180deg,var(--cbg),#fff)}
|
||||
.hd p{font-size:12.5px;font-weight:700;color:var(--c);letter-spacing:1px}
|
||||
.hd h1{margin-top:4px;font-size:25px;font-weight:900;line-height:1.3;color:var(--h)}
|
||||
.hd span{display:block;margin-top:4px;font-size:14px;color:var(--m)}
|
||||
.calc{margin:12px 16px 0;padding:16px;border-radius:20px;background:#fff;box-shadow:0 10px 30px -18px var(--c);border:1px solid var(--line)}
|
||||
.res{padding:16px;border-radius:16px;background:linear-gradient(135deg,var(--c2),var(--c));color:#fff}
|
||||
.res .empty{padding:14px 0;text-align:center;font-size:14px;opacity:.9}
|
||||
.res small{font-size:12.5px;opacity:.92}
|
||||
.res .big{display:block;margin-top:2px;font-size:30px;font-weight:900;line-height:1.25}
|
||||
.res .big u{text-decoration:none;font-size:16px;font-weight:700;margin-left:3px}
|
||||
.res .row{display:flex;gap:10px;margin-top:12px}
|
||||
.res .row div{flex:1;min-width:0;padding:8px 10px;border-radius:12px;background:rgba(255,255,255,.18)}
|
||||
.res .row b{display:block;font-size:17px;font-weight:900;line-height:1.35}
|
||||
.res .row div:nth-child(3) b{font-size:16px}
|
||||
.res .pg{position:relative;height:6px;margin-top:12px;border-radius:99px;background:rgba(255,255,255,.3);overflow:hidden}
|
||||
.res .pg i{position:absolute;left:0;top:0;bottom:0;border-radius:99px;background:#fff}
|
||||
.res .note{display:block;margin-top:8px;font-size:12.5px;line-height:1.6;opacity:.95}
|
||||
.tabs{display:flex;gap:6px;margin-top:16px;padding:4px;border-radius:12px;background:#F6F3F4}
|
||||
.tabs button{flex:1;height:34px;border-radius:9px;font-size:14px;font-weight:700;color:var(--m)}
|
||||
.tabs button.on{background:#fff;color:var(--c);box-shadow:0 2px 6px rgba(0,0,0,.08)}
|
||||
.fld{margin-top:14px}
|
||||
.lb{display:block;font-size:13.5px;font-weight:700;color:var(--h)}
|
||||
.lb small{margin-left:6px;font-weight:400;color:var(--m)}
|
||||
.in{display:block;width:100%;height:46px;margin-top:6px;padding:0 14px;border-radius:12px;background:#F7F5F6;font-size:16px;color:var(--h)}
|
||||
.inw{position:relative}
|
||||
.inw .in{padding-right:52px}
|
||||
.inw em{position:absolute;right:14px;top:50%;margin-top:3px;transform:translateY(-50%);font-style:normal;font-size:14px;color:var(--m)}
|
||||
.two{display:flex;gap:10px}.two>*{flex:1;min-width:0}
|
||||
.stp{display:flex;align-items:center;gap:10px;margin-top:6px}
|
||||
.stp button{width:42px;height:42px;border-radius:12px;background:#F7F5F6;font-size:20px;font-weight:700;color:var(--c)}
|
||||
.stp b{flex:1;text-align:center;font-size:18px;color:var(--h)}
|
||||
.seg{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
|
||||
.seg button{flex:1;min-width:calc(33% - 6px);height:42px;padding:0 6px;border-radius:12px;background:#F7F5F6;font-size:14px;font-weight:700;color:var(--t);white-space:nowrap}
|
||||
.seg.s2 button{min-width:calc(50% - 4px)}.seg.s4 button{min-width:calc(25% - 6px)}
|
||||
.seg button.on{background:var(--cbg);color:var(--c);box-shadow:inset 0 0 0 1.5px var(--c)}
|
||||
.hint{display:block;margin-top:5px;font-size:12px;color:var(--m);line-height:1.55}
|
||||
.hide{display:none!important}
|
||||
.sec{margin:26px 20px 0}
|
||||
.sec h2{font-size:18px;font-weight:900;color:var(--h)}
|
||||
.sec .lead{margin-top:2px;font-size:13px;color:var(--m)}
|
||||
.tl{list-style:none;margin-top:12px}
|
||||
.tl li{position:relative;display:flex;gap:12px;padding:0 0 16px 0}
|
||||
.tl li::before{content:"";position:absolute;left:7px;top:18px;bottom:0;width:2px;background:var(--line)}
|
||||
.tl li:last-child::before{display:none}
|
||||
.tl .d{flex:none;width:16px;height:16px;margin-top:3px;border-radius:50%;border:3px solid var(--cbg);background:#fff;box-shadow:inset 0 0 0 1px var(--line)}
|
||||
.tl li.done .d{border-color:var(--c);background:var(--c);box-shadow:none}
|
||||
.tl li.now .d{border-color:var(--c);box-shadow:0 0 0 4px var(--cbg)}
|
||||
.tl li.done .m{opacity:.6}
|
||||
.tl .m{flex:1;min-width:0}
|
||||
.tl .m b{font-size:15px;color:var(--h)}
|
||||
.tl .m b em{margin-left:6px;padding:0 6px;border-radius:99px;background:var(--cbg);color:var(--c);font-size:11px;font-style:normal;font-weight:800;white-space:nowrap}
|
||||
.tl .m span{display:block;font-size:13px;color:var(--m)}
|
||||
.tl .m span i{font-style:normal;font-weight:700;color:var(--t)}
|
||||
.cards{display:flex;flex-direction:column;gap:10px;margin-top:12px}
|
||||
.cd{position:relative;padding:14px;border-radius:16px;background:#FAF8F9;border:1px solid var(--line)}
|
||||
.cd.best{background:var(--cbg);border-color:var(--c)}
|
||||
.cd .k{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
|
||||
.cd .k b{font-size:15.5px;color:var(--h)}
|
||||
.cd .k strong{font-size:19px;font-weight:900;color:var(--c);white-space:nowrap}
|
||||
.cd p{margin-top:4px;font-size:13px;color:var(--t);line-height:1.6}
|
||||
.cd small{display:block;margin-top:4px;font-size:12px;color:var(--m)}
|
||||
.cd .tg{position:absolute;right:12px;top:-9px;padding:0 8px;border-radius:99px;background:var(--c);color:#fff;font-size:11px;font-weight:800;line-height:18px}
|
||||
.tbl{width:100%;margin-top:12px;border-collapse:collapse;font-size:13.5px}
|
||||
.tbl th,.tbl td{padding:9px 6px;border-bottom:1px solid var(--line);text-align:left}
|
||||
.tbl th{font-size:12.5px;color:var(--m);font-weight:700}
|
||||
.tbl td b{color:var(--h)}
|
||||
.tbl tr.on td{background:var(--cbg)}
|
||||
.tbl tr.on td:first-child{box-shadow:inset 3px 0 0 var(--c)}
|
||||
.tip{margin:18px 20px 0;padding:12px 14px;border-radius:14px;background:#FAF7F5;font-size:13px;line-height:1.7;color:var(--t)}
|
||||
.tip b{color:var(--h)}
|
||||
.foot{margin:14px 20px 0;font-size:12px;color:var(--m);text-align:center;line-height:1.6}
|
||||
54
topic/_shared/calc.js
Normal file
54
topic/_shared/calc.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 孕期计算器共用小工具(11-04 新增 10 个计算器用):返回 / 顶栏 / 禁回弹 / 北京时间日期 / 记住上次填的值。
|
||||
页面:<script src="../_shared/calc.js"></script> 之后用 window.CK。 */
|
||||
(function (g) {
|
||||
'use strict';
|
||||
var $ = function (s) { return document.querySelector(s); };
|
||||
var DAY = 864e5;
|
||||
function today() { var n = new Date(Date.now() + 288e5); return Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate()); }
|
||||
function parse(v) { var m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(v || ''); return m ? Date.UTC(+m[1], m[2] - 1, +m[3]) : NaN; }
|
||||
function fmt(t) { var d = new Date(t); return d.getUTCFullYear() + '-' + ('0' + (d.getUTCMonth() + 1)).slice(-2) + '-' + ('0' + d.getUTCDate()).slice(-2); }
|
||||
function cn(t, y) { var d = new Date(t); return (y ? d.getUTCFullYear() + ' 年 ' : '') + (d.getUTCMonth() + 1) + ' 月 ' + d.getUTCDate() + ' 日'; }
|
||||
function wd(t) { return '周' + '日一二三四五六'.charAt(new Date(t).getUTCDay()); }
|
||||
function addMonths(t, n) { var d = new Date(t), y = d.getUTCFullYear(), m = d.getUTCMonth() + n, day = d.getUTCDate(), last = new Date(Date.UTC(y, m + 1, 0)).getUTCDate(); return Date.UTC(y, m, Math.min(day, last)); }
|
||||
function money(n) { n = Math.round(n); return n >= 1e4 ? (Math.round(n / 100) / 100).toFixed(n >= 1e5 ? 1 : 2).replace(/\.?0+$/, '') + ' 万' : n.toLocaleString('zh-CN'); }
|
||||
function esc(s) { return String(s == null ? '' : s).replace(/[&<>"]/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); }
|
||||
/* 本机记的孕期(首页同款键):{w 孕周, pp 产后};没有返回 null */
|
||||
function preg() { try { var x = JSON.parse(localStorage.getItem('mmbox.gcwk.v1') || 'null'); return x && x.w ? x : null; } catch (e) { return null; } }
|
||||
/* 预产期计算器填过的值 → 预产期时间戳(多个计算器共用,用户不用重复填) */
|
||||
function savedDue() {
|
||||
try {
|
||||
var s = JSON.parse(localStorage.getItem('mmbox.edd.calc') || 'null'); if (!s) return NaN;
|
||||
if (s.m === 'ivf') { var t = parse(s.tr); return isNaN(t) ? NaN : t + (+s.emb === 3 ? 263 : 261) * DAY; }
|
||||
var l = parse(s.lmp); return isNaN(l) ? NaN : l + (280 + (+s.cy || 28) - 28) * DAY;
|
||||
} catch (e) { return NaN; }
|
||||
}
|
||||
function store(key, def) {
|
||||
var st = {}; Object.keys(def).forEach(function (k) { st[k] = def[k]; });
|
||||
try { var sv = JSON.parse(localStorage.getItem(key) || 'null'); if (sv) Object.keys(def).forEach(function (k) { if (sv[k] != null) st[k] = sv[k]; }); } catch (e) {}
|
||||
st.save = function () { var o = {}; Object.keys(def).forEach(function (k) { o[k] = st[k]; }); try { localStorage.setItem(key, JSON.stringify(o)); } catch (e) {} };
|
||||
return st;
|
||||
}
|
||||
/* 分段按钮:<div class="seg" data-k="xx"><button data-v>…;点了写 st[k] 回调 */
|
||||
function seg(el, st, k, cb) {
|
||||
function ui() { [].forEach.call(el.children, function (b) { b.classList.toggle('on', String(b.dataset.v) === String(st[k])); }); }
|
||||
el.addEventListener('click', function (e) { var b = e.target.closest('button'); if (!b) return; st[k] = isNaN(+b.dataset.v) || b.dataset.v === '' ? b.dataset.v : +b.dataset.v; ui(); cb(); });
|
||||
ui(); return ui;
|
||||
}
|
||||
function shell() {
|
||||
var sc = $('#scroll');
|
||||
$('#back').addEventListener('click', function () {
|
||||
if (document.referrer && document.referrer.indexOf(location.host) >= 0 && history.length > 1) history.back();
|
||||
else location.href = '../jisuan/' + location.search + location.hash;
|
||||
});
|
||||
sc.addEventListener('scroll', function () { $('#bar').classList.toggle('on', sc.scrollTop > 8); }, { passive: true });
|
||||
/* 禁止下拉回弹:固定外壳 + 容器滚动 + 到顶/到底时拦 touchmove */
|
||||
var y0 = 0;
|
||||
sc.addEventListener('touchstart', function (e) { y0 = e.touches[0].clientY; }, { passive: true });
|
||||
sc.addEventListener('touchmove', function (e) {
|
||||
var dy = e.touches[0].clientY - y0;
|
||||
if ((sc.scrollTop <= 0 && dy > 0) || (sc.scrollTop + sc.clientHeight >= sc.scrollHeight - 1 && dy < 0)) e.preventDefault();
|
||||
}, { passive: false });
|
||||
document.addEventListener('touchmove', function (e) { if (!sc.contains(e.target)) e.preventDefault(); }, { passive: false });
|
||||
}
|
||||
g.CK = { $: $, DAY: DAY, today: today, parse: parse, fmt: fmt, cn: cn, wd: wd, addMonths: addMonths, money: money, esc: esc, preg: preg, savedDue: savedDue, store: store, seg: seg, shell: shell };
|
||||
})(window);
|
||||
@@ -57,7 +57,7 @@
|
||||
'.tc-more{display:block;width:100%;margin-top:6px;height:40px;border:0;border-radius:99px;background:#F7F8FA;color:#4E5969;font-size:13px;font-weight:600}';
|
||||
var SLUG = (location.pathname.match(/\/topic\/([^\/]+)\//) || [])[1] || '';
|
||||
/* 11-04 微信转发图:每个专题一张 assets/share/t/<slug>.jpg(核心词大字 + logo),见 js/share-card.js */
|
||||
if (SLUG) (function () { var s = document.createElement('script'); s.src = '../../js/share-card.js?v=26110298'; s.onload = function () { window.mbShare('../../assets/share/t/' + SLUG + '.jpg'); }; document.head.appendChild(s); })();
|
||||
if (SLUG) (function () { var s = document.createElement('script'); s.src = '../../js/share-card.js?v=26110299'; s.onload = function () { window.mbShare('../../assets/share/t/' + SLUG + '.jpg'); }; document.head.appendChild(s); })();
|
||||
var SK = 'mmbox.tp.v1', UK = (function () { var m = ((location.hash || '') + '&' + (location.search || '')).match(/[#?&]openid=([^&]*)/); return m ? decodeURIComponent(m[1]) : '_guest'; })();
|
||||
function loadMe() { try { var a = JSON.parse(localStorage.getItem(SK) || '{}') || {}; var m = a[UK] || {}; m.cm = m.cm || {}; m.lk = m.lk || {}; return { a: a, m: m }; } catch (e) { return { a: {}, m: { cm: {}, lk: {} } }; } }
|
||||
function saveMe(st) { try { st.a[UK] = st.m; localStorage.setItem(SK, JSON.stringify(st.a)); } catch (e) {} }
|
||||
@@ -70,7 +70,7 @@
|
||||
function getJSON(u) { return fetch(u, { cache: 'no-cache' }).then(function (r) { if (!r.ok) throw r.status; return r.json(); }); }
|
||||
|
||||
function related(box) {
|
||||
getJSON('../_shared/idx.json?v=26110298').then(function (idx) {
|
||||
getJSON('../_shared/idx.json?v=26110299').then(function (idx) {
|
||||
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 rest = idx.filter(function (x) { return x[0] !== SLUG; });
|
||||
@@ -177,7 +177,7 @@
|
||||
}
|
||||
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 () {});
|
||||
getJSON('../_shared/cm/' + SLUG + '.json?v=26110298').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
|
||||
getJSON('../_shared/cm/' + SLUG + '.json?v=26110299').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
|
||||
}
|
||||
|
||||
function extras(el) {
|
||||
|
||||
Reference in New Issue
Block a user