新增每日营养需求计算器,并按我自己的情况确定摄入方案

我提供并确认的个人参数:
- 性别女、年龄16岁、身高165 cm、体重55 kg
- 日常活动:每天约1万步(上学 + 课间走动)
- 目标:维持体重(BMI 正常,不刻意增重或减重)

我据此做出的决策:
- 热量按维持水平给出,TDEE = BMR × PAL
- 蛋白质按 1.2~1.6 g/kg 体重
- 脂肪占总能量 25%~28%,碳水占 55%~60%
- 膳食纤维 25~30 g,饮水 1.2~1.6 L
- 青春期女生以钙 1000 mg、铁 18 mg 为重点
- 输出 BMI、BMR、TDEE,以及每日蛋白质、脂肪、碳水与重点矿物质建议量
This commit is contained in:
2026-09-24 02:45:07 +00:00
parent 5d82fc40b1
commit 1fe148eee7
+280
View File
@@ -0,0 +1,280 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>每日营养需求计算器</title>
<style>
:root{
--bg:#f4f6f4; --card:#ffffff; --ink:#1f2a24; --muted:#6b7a70;
--line:#e3e8e3; --accent:#2f8f5b; --accent-soft:#e8f4ec;
--warn:#b8791a; --warn-soft:#fdf4e3; --blue:#3a6ea5; --blue-soft:#eaf1f8;
--rose:#b04a5a; --rose-soft:#fbedef;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);line-height:1.5;padding:26px 16px 70px;
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;}
.wrap{max-width:980px;margin:0 auto}
header h1{font-size:22px;margin:0 0 6px;letter-spacing:-.01em}
header p{margin:0 0 22px;color:var(--muted);font-size:14px}
.layout{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start}
@media(max-width:780px){.layout{grid-template-columns:1fr}}
.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:18px 18px 20px;margin-bottom:16px}
.card h2{font-size:14px;margin:0 0 16px;letter-spacing:.03em;color:var(--ink)}
.card h2 .n{display:inline-block;width:20px;height:20px;line-height:20px;text-align:center;border-radius:6px;background:var(--accent-soft);color:var(--accent);font-size:12px;margin-right:7px;font-weight:700}
.field{margin-bottom:14px}
.field>label{display:block;font-size:13px;color:var(--muted);margin-bottom:6px}
.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}
input,select{width:100%;padding:9px 11px;border:1px solid var(--line);border-radius:9px;font-size:15px;background:#fbfcfb;color:var(--ink);font-family:inherit}
input:focus,select:focus{outline:none;border-color:var(--accent);background:#fff}
.seg{display:flex;gap:5px;background:#f1f4f1;padding:4px;border-radius:10px}
.seg button{flex:1;border:0;background:transparent;padding:8px 4px;border-radius:7px;font-size:13.5px;color:var(--muted);cursor:pointer;font-family:inherit;transition:.15s}
.seg button.active{background:#fff;color:var(--ink);box-shadow:0 1px 3px rgba(0,0,0,.07);font-weight:600}
.hint{font-size:12px;color:var(--muted);margin-top:6px;line-height:1.45}
.hero{background:var(--accent-soft);border-radius:12px;padding:15px 16px;margin-bottom:14px}
.hero .cap{font-size:13px;color:#3c6b52;margin-bottom:2px}
.big{font-size:38px;font-weight:700;letter-spacing:-.02em;line-height:1.15}
.big span{font-size:15px;font-weight:500;color:#5c7a68;margin-left:5px}
.hero .sub{font-size:12.5px;color:#5c7a68;margin-top:4px}
.row{display:flex;justify-content:space-between;align-items:baseline;padding:9px 0;border-bottom:1px dashed var(--line);font-size:14px}
.row:last-child{border-bottom:0}
.row .k{color:var(--muted)}
.row .v{font-weight:600}
.row .v small{font-weight:400;color:var(--muted);font-size:12px}
.badge{display:inline-block;padding:2px 9px;border-radius:20px;font-size:12px;font-weight:600;margin-left:8px}
.b-warn{background:var(--warn-soft);color:var(--warn)}
.b-ok{background:var(--accent-soft);color:var(--accent)}
.b-over{background:var(--rose-soft);color:var(--rose)}
.macros{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-top:12px}
.macro{background:#f8faf8;border:1px solid var(--line);border-radius:10px;padding:10px 8px;text-align:center}
.macro .t{font-size:12px;color:var(--muted)}
.macro .g{font-size:19px;font-weight:700;margin:2px 0 1px}
.macro .p{font-size:11px;color:var(--muted)}
.note{background:var(--blue-soft);border-radius:10px;padding:11px 13px;font-size:12.5px;color:#31506f;margin-top:14px;line-height:1.55}
details{margin-top:6px}
summary{cursor:pointer;font-size:13px;color:var(--accent);font-weight:600;list-style:none}
summary::-webkit-details-marker{display:none}
summary:before{content:"\25B8 ";font-size:11px}
details[open] summary:before{content:"\25BE "}
details .body{font-size:13px;color:#4a564e;padding:10px 2px 2px;line-height:1.65}
details .body code{background:#f1f4f1;padding:1px 5px;border-radius:5px;font-size:12.5px}
.foot{font-size:12px;color:var(--muted);text-align:center;margin-top:22px;line-height:1.7}
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>每日营养需求计算器</h1>
<p>按年龄与性别选择基础代谢公式,结合每天步数估算维持热量,并换算蛋白质、脂肪、碳水与重点矿物质需求。</p>
</header>
<div class="layout">
<!-- 输入 -->
<section class="card">
<h2><span class="n">1</span>基本信息</h2>
<div class="field">
<label>性别</label>
<div class="seg" id="sex">
<button type="button" data-val="male">男</button>
<button type="button" data-val="female" class="active">女</button>
</div>
</div>
<div class="field two">
<div><label>年龄(岁)</label><input type="number" id="age" value="16" min="6" max="100" step="1"></div>
<div><label>身高(cm)</label><input type="number" id="height" value="165" min="100" max="230" step="0.5"></div>
</div>
<div class="field"><label>体重(kg)</label><input type="number" id="weight" value="55" min="20" max="250" step="0.1"></div>
<h2 style="margin-top:22px"><span class="n">2</span>日常活动量</h2>
<div class="field"><label>平均每天步数</label><input type="number" id="steps" value="10000" min="0" max="50000" step="500"></div>
<div class="field">
<label>活动系数 PAL</label>
<select id="pal">
<option value="1.4">久坐 · 几乎不运动</option>
<option value="1.5">轻度活动 · 每天约 5000 步</option>
<option value="1.6" selected>上学 / 中度活动 · 每天约 1 万步</option>
<option value="1.75">高强度 · 1 万步以上或每周运动 4~5 次</option>
<option value="1.9">极高 · 体力劳动 / 高强度训练</option>
</select>
<div class="hint">每天 1 万步约合 6~8 公里、1.5 小时步行;学生日常叠加课间走动,取 1.6 较为稳妥。</div>
</div>
</section>
<!-- 结果 -->
<section class="card">
<h2><span class="n">3</span>每日需求</h2>
<div class="hero">
<div class="cap">每日维持热量</div>
<div class="big" id="tdeeOut">&mdash;<span>kcal / 天</span></div>
<div class="sub" id="goalSub">&mdash;</div>
</div>
<div class="row"><span class="k">BMI<span class="badge" id="bmiBadge">&mdash;</span></span><span class="v" id="bmiOut">&mdash;</span></div>
<div class="row"><span class="k">基础代谢 BMR</span><span class="v" id="bmrOut">&mdash;</span></div>
<div class="row"><span class="k">活动系数 PAL</span><span class="v" id="palOut">&mdash;</span></div>
<div class="row"><span class="k">蛋白质建议</span><span class="v" id="proteinOut">&mdash;</span></div>
<div class="macros">
<div class="macro"><div class="t">蛋白质</div><div class="g" id="mProtein">&mdash;</div><div class="p">克 / 天</div></div>
<div class="macro"><div class="t">脂肪</div><div class="g" id="mFat">&mdash;</div><div class="p">克 / 天</div></div>
<div class="macro"><div class="t">碳水</div><div class="g" id="mCarb">&mdash;</div><div class="p">克 / 天</div></div>
</div>
<div class="note" id="microNote">&mdash;</div>
<details style="margin-top:14px">
<summary>算法说明</summary>
<div class="body">
<b>① 基础代谢 BMR</b><br>
儿童青少年(&le;18 岁)用 Schofield 公式:<br>
<code>女 10–18 岁:BMR = 13.384&times;体重 + 692.6</code><br>
<code>男 10–18 岁:BMR = 17.686&times;体重 + 658.2</code><br>
成年(&gt;18 岁)用 Mifflin-St Jeor 公式:<br>
<code>女:BMR = 10&times;体重 + 6.25&times;身高 &minus; 5&times;年龄 &minus; 161</code><br>
<code>男:BMR = 10&times;体重 + 6.25&times;身高 &minus; 5&times;年龄 + 5</code><br><br>
<b>② 维持热量 TDEE</b><br>
<code>TDEE = BMR &times; PAL</code>。每天 1 万步 &asymp; 6~8 公里,取 PAL 1.6。手机 / 手环显示的「运动消耗」普遍偏高,未直接采信。<br><br>
<b>③ 三大营养素</b><br>
蛋白质按 1.3 g/kg(区间 1.2~1.6 g/kg);脂肪占总热量约 27%;剩余热量分配给碳水。<br><br>
<b>④ 重点矿物质与水</b><br>
钙、铁、锌、维生素 D 与膳食纤维按中国居民膳食营养素参考摄入量(DRIs)给出,青春期女生以钙、铁为重点。<br><br>
公式终归是估算,个体差异约 &plusmn;10%。可按结果吃 2~3 周,再按体重走势微调。
</div>
</details>
</section>
</div>
<div class="foot">
本工具为通用营养学估算,不构成医疗或营养处方。<br>
如有月经不规律、明显偏食、生长发育异常等情况,请咨询临床营养科或注册营养师。
</div>
</div>
<script>
(function(){
"use strict";
var $ = function(id){ return document.getElementById(id); };
function segVal(id){
var b = document.querySelector("#" + id + " button.active");
return b ? b.dataset.val : "";
}
function num(id){ var v = parseFloat($(id).value); return isFinite(v) ? v : NaN; }
function r0(x){ return Math.round(x); }
function r1(x){ return Math.round(x * 10) / 10; }
function bmrOf(s){
if (s.age <= 18) {
return s.sex === "male"
? 17.686 * s.weight + 658.2
: 13.384 * s.weight + 692.6;
}
return s.sex === "male"
? 10 * s.weight + 6.25 * s.height - 5 * s.age + 5
: 10 * s.weight + 6.25 * s.height - 5 * s.age - 161;
}
function bmiInfo(bmi){
if (bmi < 18.5) return { text: "偏瘦", cls: "b-warn" };
if (bmi < 24) return { text: "正常", cls: "b-ok" };
if (bmi < 28) return { text: "超重", cls: "b-warn" };
return { text: "肥胖", cls: "b-over" };
}
function microsOf(s){
var ca, fe, zn;
if (s.age <= 17) {
ca = 1000;
fe = s.sex === "female" ? 18 : 16;
zn = 9;
} else if (s.age <= 49) {
ca = 800;
fe = s.sex === "female" ? 20 : 12;
zn = s.sex === "female" ? 7.5 : 12.5;
} else {
ca = 1000;
fe = 12;
zn = s.sex === "female" ? 7.5 : 12.5;
}
var vitD = 10;
var fiber = 25;
var water = s.age <= 17 ? 1500 : (s.sex === "female" ? 1500 : 1700);
return { ca: ca, fe: fe, zn: zn, vitD: vitD, fiber: fiber, water: water };
}
function render(){
var s = {
sex: segVal("sex"),
age: num("age"),
height: num("height"),
weight: num("weight"),
steps: num("steps"),
pal: parseFloat($("pal").value)
};
var ok = isFinite(s.age) && isFinite(s.height) && isFinite(s.weight)
&& s.age > 0 && s.height > 0 && s.weight > 0;
if (!ok) {
$("tdeeOut").innerHTML = "&mdash;<span>kcal / 天</span>";
$("goalSub").textContent = "请先填写年龄、身高和体重";
["bmiOut","bmrOut","palOut","proteinOut","mProtein","mFat","mCarb"]
.forEach(function(id){ $(id).textContent = "\u2014"; });
$("bmiBadge").className = "badge";
$("bmiBadge").textContent = "\u2014";
$("microNote").textContent = "\u2014";
return;
}
var bmr = bmrOf(s);
var tdee = bmr * s.pal;
var bmi = s.weight / Math.pow(s.height / 100, 2);
$("tdeeOut").innerHTML = r0(tdee) + "<span>kcal / 天</span>";
$("goalSub").textContent = "维持体重所需热量(基础代谢 " + r0(bmr) + " kcal \u00D7 PAL " + s.pal + ")";
var bi = bmiInfo(bmi);
$("bmiOut").textContent = r1(bmi);
$("bmiBadge").className = "badge " + bi.cls;
$("bmiBadge").textContent = bi.text;
$("bmrOut").innerHTML = r0(bmr) + " <small>kcal</small>";
$("palOut").textContent = s.pal;
$("proteinOut").innerHTML = r0(1.2 * s.weight) + " ~ " + r0(1.6 * s.weight) + " <small>g</small>";
var pGram = r0(1.3 * s.weight);
var pKcal = pGram * 4;
var fKcal = tdee * 0.27;
var fGram = r0(fKcal / 9);
var cGram = Math.max(0, r0((tdee - pKcal - fKcal) / 4));
$("mProtein").textContent = pGram;
$("mFat").textContent = fGram;
$("mCarb").textContent = cGram;
var mi = microsOf(s);
$("microNote").innerHTML =
"重点矿物质与膳食纤维:钙 <b>" + mi.ca + " mg</b>、铁 <b>" + mi.fe + " mg</b>、锌 <b>" + mi.zn +
" mg</b>、维生素 D <b>" + mi.vitD + " \u03BCg</b>、膳食纤维 <b>" + mi.fiber +
"~30 g</b>、饮水约 <b>" + mi.water + " ml</b>。青春期女生以钙、铁为重点,红肉配维生素 C 可提高铁吸收。";
}
document.querySelectorAll(".seg").forEach(function(seg){
seg.addEventListener("click", function(e){
var b = e.target.closest("button");
if (!b) return;
seg.querySelectorAll("button").forEach(function(x){ x.classList.remove("active"); });
b.classList.add("active");
render();
});
});
["age","height","weight","steps","pal"].forEach(function(id){
var el = $(id);
el.addEventListener("input", render);
el.addEventListener("change", render);
});
render();
})();
</script>
</body>
</html>