- 默认输入取身高 178cm、体重 177 斤(88.5kg)、15 岁、男性 - BMI 分成人与中国青少年两套判定:15 岁男性按超重 24.6 / 肥胖 26.4,不套用成人 24 / 28 - 基础代谢按年龄取公式:18 岁以下用 Schofield 青少年公式,18 岁及以上用 Mifflin-St Jeor - 每日总消耗按活动系数 PAL 1.4 / 1.6 / 1.8 / 2.0 计算 - 减脂档按 400–500 kcal 缺口,摄入下限设为 2000 kcal 并做自动保护 - 三大营养素按蛋白质 1.4–1.6 g/kg、脂肪约占总热量 27%、碳水补足余量给出克数与占比 - 另给出膳食纤维、饮水量,以及钙、铁、锌、碘、维生素 A/D/E/B 族/C、镁、钾、钠的每日需要量 - 给出早餐 / 午餐 / 加餐 / 晚餐的热量与三大营养素分配
323 lines
14 KiB
HTML
323 lines
14 KiB
HTML
<!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{
|
||
--accent:#2563eb; --accent2:#0ea5e9;
|
||
--text:#1e293b; --muted:#64748b; --line:#e2e8f0;
|
||
--ok:#16a34a; --warn:#d97706; --bad:#dc2626;
|
||
}
|
||
*{box-sizing:border-box;}
|
||
body{margin:0;padding:24px 16px 60px;color:var(--text);
|
||
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
|
||
background:linear-gradient(160deg,#eef2ff,#f8fafc 40%,#ecfeff);}
|
||
.wrap{max-width:920px;margin:0 auto;}
|
||
header{text-align:center;margin-bottom:22px;}
|
||
h1{font-size:26px;margin:0 0 8px;letter-spacing:.5px;}
|
||
header p{margin:0;color:var(--muted);font-size:14px;}
|
||
.card{background:#fff;border:1px solid var(--line);border-radius:16px;padding:20px;margin-bottom:18px;
|
||
box-shadow:0 8px 24px rgba(15,23,42,.06);}
|
||
.card h2{font-size:16px;margin:0 0 14px;display:flex;align-items:center;gap:8px;}
|
||
.card h2::before{content:"";width:4px;height:16px;border-radius:2px;background:linear-gradient(var(--accent),var(--accent2));}
|
||
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px;}
|
||
label{display:block;font-size:13px;color:var(--muted);margin-bottom:6px;}
|
||
input,select{width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:10px;
|
||
font-size:15px;background:#f8fafc;color:var(--text);}
|
||
input:focus,select:focus{outline:none;border-color:var(--accent);background:#fff;}
|
||
.actions{margin-top:18px;display:flex;gap:12px;flex-wrap:wrap;}
|
||
button{border:none;border-radius:10px;padding:12px 22px;font-size:15px;cursor:pointer;font-weight:600;}
|
||
.primary{background:linear-gradient(135deg,var(--accent),var(--accent2));color:#fff;}
|
||
.ghost{background:#f1f5f9;color:var(--text);}
|
||
button:hover{filter:brightness(1.05);}
|
||
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;}
|
||
.kpi{background:#f8fafc;border:1px solid var(--line);border-radius:12px;padding:14px;}
|
||
.kpi .v{font-size:22px;font-weight:700;}
|
||
.kpi .l{font-size:12px;color:var(--muted);margin-top:4px;}
|
||
.badge{display:inline-block;padding:3px 10px;border-radius:99px;font-size:12px;font-weight:600;}
|
||
.b-ok{background:#dcfce7;color:var(--ok);}
|
||
.b-warn{background:#fef3c7;color:var(--warn);}
|
||
.b-bad{background:#fee2e2;color:var(--bad);}
|
||
table{width:100%;border-collapse:collapse;font-size:14px;}
|
||
th,td{padding:9px 12px;text-align:left;border-bottom:1px solid var(--line);}
|
||
th{color:var(--muted);font-weight:600;font-size:13px;background:#f8fafc;}
|
||
td.num{font-variant-numeric:tabular-nums;font-weight:600;}
|
||
.note{font-size:13px;color:var(--muted);line-height:1.7;margin-top:10px;}
|
||
.formula{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;color:var(--muted);}
|
||
.hidden{display:none;}
|
||
footer{text-align:center;font-size:12px;color:var(--muted);line-height:1.8;margin-top:22px;}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="wrap">
|
||
<header>
|
||
<h1>每日热量与营养素需求计算器</h1>
|
||
<p>BMI · 基础代谢 BMR · 每日总消耗 TDEE · 三大营养素 · 七大营养素每日需要量</p>
|
||
</header>
|
||
|
||
<section class="card">
|
||
<h2>输入你的资料</h2>
|
||
<div class="grid">
|
||
<div>
|
||
<label>身高(cm)</label>
|
||
<input id="height" type="number" value="178" min="80" max="230" step="0.5">
|
||
</div>
|
||
<div>
|
||
<label>体重</label>
|
||
<input id="weight" type="number" value="177" min="10" max="400" step="0.1">
|
||
</div>
|
||
<div>
|
||
<label>体重单位</label>
|
||
<select id="unit">
|
||
<option value="jin" selected>斤</option>
|
||
<option value="kg">公斤(kg)</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label>年龄(岁)</label>
|
||
<input id="age" type="number" value="15" min="6" max="100" step="1">
|
||
</div>
|
||
<div>
|
||
<label>性别</label>
|
||
<select id="sex">
|
||
<option value="male" selected>男</option>
|
||
<option value="female">女</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label>活动水平(PAL)</label>
|
||
<select id="pal">
|
||
<option value="1.4">久坐 · 1.4(几乎不运动)</option>
|
||
<option value="1.6" selected>轻度 · 1.6(每周 1–3 次 / 有体育课)</option>
|
||
<option value="1.8">中度 · 1.8(每周 3–5 次)</option>
|
||
<option value="2.0">高强度 · 2.0(几乎每天训练)</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label>目标</label>
|
||
<select id="goal">
|
||
<option value="cut" selected>减脂</option>
|
||
<option value="maintain">维持体重</option>
|
||
<option value="bulk">增肌 / 增重</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="actions">
|
||
<button class="primary" onclick="compute()">开始计算</button>
|
||
<button class="ghost" onclick="resetAll()">恢复默认</button>
|
||
</div>
|
||
</section>
|
||
|
||
<div id="results" class="hidden">
|
||
<section class="card">
|
||
<h2>身体与代谢指标</h2>
|
||
<div class="kpis">
|
||
<div class="kpi"><div class="v" id="k-bmi">–</div><div class="l">BMI <span id="k-bmi-badge" class="badge b-warn">–</span></div></div>
|
||
<div class="kpi"><div class="v" id="k-bmr">–</div><div class="l">基础代谢 BMR(kcal)</div></div>
|
||
<div class="kpi"><div class="v" id="k-tdee">–</div><div class="l">每日总消耗 TDEE(kcal)</div></div>
|
||
<div class="kpi"><div class="v" id="k-target">–</div><div class="l">建议每日摄入(kcal)</div></div>
|
||
</div>
|
||
<p class="note" id="bmi-ref"></p>
|
||
<p class="note formula" id="formula-note"></p>
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>三大营养素与膳食纤维、饮水(每日)</h2>
|
||
<table>
|
||
<thead><tr><th>营养素</th><th>每日需要量</th><th>占总热量</th></tr></thead>
|
||
<tbody id="macro-body"></tbody>
|
||
</table>
|
||
<p class="note">蛋白质按体重计算;脂肪控制在总热量的 25–30%;碳水化合物补足剩余热量;优先选择全谷、杂豆、薯类。</p>
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>维生素与矿物质(每日需要量)</h2>
|
||
<table>
|
||
<thead><tr><th>营养素</th><th>每日需要量</th><th>主要食物来源</th></tr></thead>
|
||
<tbody id="micro-body"></tbody>
|
||
</table>
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>三餐与加餐分配建议</h2>
|
||
<table>
|
||
<thead><tr><th>餐次</th><th>热量(kcal)</th><th>蛋白质(g)</th><th>碳水化合物(g)</th></tr></thead>
|
||
<tbody id="meal-body"></tbody>
|
||
</table>
|
||
<p class="note">示例吃法:每餐一份蛋白(肉 / 蛋 / 奶 / 豆)+ 一份主食(一半粗粮)+ 两大把蔬菜;先吃菜和蛋白、后吃主食。</p>
|
||
</section>
|
||
|
||
<section class="card">
|
||
<h2>提醒</h2>
|
||
<p class="note" id="warn-note"></p>
|
||
</section>
|
||
</div>
|
||
|
||
<footer>
|
||
本工具为估算参考,公式误差约 ±10%;青少年 BMI 判定请以《WS/T 586-2018 学龄儿童青少年超重与肥胖筛查》原表为准。<br>
|
||
未成年人减重请先咨询医生或营养师,不要使用极端节食、代餐或减肥药。
|
||
</footer>
|
||
</div>
|
||
|
||
<script>
|
||
const $ = id => document.getElementById(id);
|
||
|
||
function bmrOf(sex, weightKg, heightCm, age){
|
||
if(age < 18){
|
||
// Schofield 公式(10–18 岁)
|
||
return sex === 'male'
|
||
? 17.686 * weightKg + 658.2
|
||
: 13.384 * weightKg + 692.6;
|
||
}
|
||
// Mifflin-St Jeor 公式
|
||
return sex === 'male'
|
||
? 10 * weightKg + 6.25 * heightCm - 5 * age + 5
|
||
: 10 * weightKg + 6.25 * heightCm - 5 * age - 161;
|
||
}
|
||
|
||
function judgeBmi(bmi, age, sex){
|
||
if(age >= 18){
|
||
if(bmi < 18.5) return { t:'偏瘦', c:'b-warn' };
|
||
if(bmi < 24) return { t:'正常', c:'b-ok' };
|
||
if(bmi < 28) return { t:'超重', c:'b-warn' };
|
||
return { t:'肥胖', c:'b-bad' };
|
||
}
|
||
// 青少年:中国标准只筛查超重与肥胖
|
||
if(bmi >= 26.4) return { t:'肥胖', c:'b-bad' };
|
||
if(bmi >= 24.6) return { t:'超重', c:'b-warn' };
|
||
return { t:'未达超重', c:'b-ok' };
|
||
}
|
||
|
||
function microList(age, sex){
|
||
const teen = age < 18, m = sex === 'male';
|
||
return [
|
||
['钙','mg', teen ? 1000 : 800, '牛奶 300–500 ml、豆制品、小鱼小虾'],
|
||
['铁','mg', teen ? (m ? 16 : 18) : (m ? 12 : 20), '红肉、动物肝脏、动物血'],
|
||
['锌','mg', teen ? (m ? 11.5 : 8.5) : (m ? 12.5 : 7.5), '牛肉、牡蛎、坚果、蛋黄'],
|
||
['碘','μg', 120, '加碘盐、海带、紫菜'],
|
||
['维生素 A','μg RAE', teen ? (m ? 820 : 630) : (m ? 800 : 700), '胡萝卜、南瓜、肝脏、鸡蛋'],
|
||
['维生素 D','μg', 10, '晒太阳约 20 分钟;食物中含量很少'],
|
||
['维生素 E','mg', 14, '坚果、植物油'],
|
||
['维生素 B1','mg', teen ? (m ? 1.6 : 1.3) : (m ? 1.4 : 1.2), '全谷物、猪肉、豆类'],
|
||
['维生素 B2','mg', teen ? (m ? 1.5 : 1.2) : (m ? 1.4 : 1.2), '牛奶、鸡蛋、肝脏'],
|
||
['烟酸','mg NE', m ? 15 : 12, '肉类、鱼、花生'],
|
||
['维生素 B6','mg', 1.4, '肉、鱼、香蕉'],
|
||
['维生素 B12','μg', 2.4, '肉、蛋、奶'],
|
||
['维生素 C','mg', 100, '青椒、猕猴桃、橙子、西兰花'],
|
||
['镁','mg', teen ? (m ? 320 : 300) : (m ? 330 : 280), '坚果、全谷、深绿蔬菜'],
|
||
['钾','mg', 2000, '香蕉、土豆、菠菜、豆类'],
|
||
['钠','mg', '< 2000', '越少越好(相当于盐 < 5 g)']
|
||
];
|
||
}
|
||
|
||
function compute(){
|
||
const sex = $('sex').value;
|
||
const age = Number($('age').value);
|
||
const heightCm = Number($('height').value);
|
||
let weightKg = Number($('weight').value);
|
||
if($('unit').value === 'jin') weightKg = weightKg / 2;
|
||
const pal = Number($('pal').value);
|
||
const goal = $('goal').value;
|
||
|
||
if(!heightCm || !weightKg || !age){
|
||
alert('请把身高、体重、年龄填写完整。');
|
||
return;
|
||
}
|
||
|
||
const heightM = heightCm / 100;
|
||
const bmi = weightKg / (heightM * heightM);
|
||
const bmr = bmrOf(sex, weightKg, heightCm, age);
|
||
const tdee = bmr * pal;
|
||
|
||
let target, clamped = false;
|
||
if(goal === 'cut'){
|
||
const floor = age < 18 ? 2000 : (sex === 'male' ? 1500 : 1200);
|
||
target = tdee - 450;
|
||
if(target < floor){ target = floor; clamped = true; }
|
||
}else if(goal === 'bulk'){
|
||
target = tdee + 300;
|
||
}else{
|
||
target = tdee;
|
||
}
|
||
|
||
// 三大营养素
|
||
const teen = age < 18;
|
||
const pLowPerKg = teen ? 1.4 : 1.2, pHighPerKg = 1.6;
|
||
const pLow = pLowPerKg * weightKg, pHigh = pHighPerKg * weightKg;
|
||
const pMid = (pLow + pHigh) / 2;
|
||
const fatMid = 0.27 * target / 9, fatLow = 0.25 * target / 9, fatHigh = 0.30 * target / 9;
|
||
const carbMid = Math.max(0, (target - pMid * 4 - fatMid * 9) / 4);
|
||
const pPct = Math.round(pMid * 4 / target * 100);
|
||
const cPct = Math.round(carbMid * 4 / target * 100);
|
||
const fatPct = 100 - pPct - cPct;
|
||
const fiberLow = teen ? 25 : 25, fiberHigh = teen ? 30 : 30;
|
||
const water = teen ? '1500–2000 ml' : (sex === 'male' ? '1700–2000 ml' : '1500–1800 ml');
|
||
|
||
// 渲染
|
||
const j = judgeBmi(bmi, age, sex);
|
||
$('k-bmi').textContent = bmi.toFixed(1);
|
||
const badge = $('k-bmi-badge');
|
||
badge.textContent = j.t;
|
||
badge.className = 'badge ' + j.c;
|
||
$('k-bmr').textContent = Math.round(bmr);
|
||
$('k-tdee').textContent = Math.round(tdee);
|
||
$('k-target').textContent = Math.round(target);
|
||
|
||
$('bmi-ref').textContent = age >= 18
|
||
? '判定标准:中国成人标准 —— 正常 18.5–23.9,超重 24.0–27.9,肥胖 ≥ 28.0。'
|
||
: '青少年参考界值(15 岁男:超重 ≥ 24.6、肥胖 ≥ 26.4),其他年龄与性别请对照 WS/T 586-2018 原表判定。';
|
||
|
||
$('formula-note').textContent = age < 18
|
||
? 'BMR 采用 Schofield 青少年公式(10–18 岁);TDEE = BMR × PAL。'
|
||
: 'BMR 采用 Mifflin-St Jeor 公式;TDEE = BMR × PAL。';
|
||
|
||
$('macro-body').innerHTML = `
|
||
<tr><td>蛋白质</td><td class="num">${Math.round(pLow)}–${Math.round(pHigh)} g</td><td>${pPct}%</td></tr>
|
||
<tr><td>脂肪</td><td class="num">${Math.round(fatLow)}–${Math.round(fatHigh)} g</td><td>${fatPct}%</td></tr>
|
||
<tr><td>碳水化合物</td><td class="num">${Math.round(carbMid)} g</td><td>${cPct}%</td></tr>
|
||
<tr><td>膳食纤维</td><td class="num">${fiberLow}–${fiberHigh} g</td><td>—</td></tr>
|
||
<tr><td>饮水</td><td class="num">${water}</td><td>—</td></tr>`;
|
||
|
||
$('micro-body').innerHTML = microList(age, sex)
|
||
.map(r => `<tr><td>${r[0]}</td><td class="num">${r[2]} ${r[1]}</td><td>${r[3]}</td></tr>`).join('');
|
||
|
||
const meals = [['早餐', .25], ['午餐', .35], ['加餐', .10], ['晚餐', .30]];
|
||
$('meal-body').innerHTML = meals.map(m => `
|
||
<tr><td>${m[0]}</td><td class="num">${Math.round(target * m[1])}</td>
|
||
<td class="num">${Math.round(pMid * m[1])}</td><td class="num">${Math.round(carbMid * m[1])}</td></tr>`).join('');
|
||
|
||
let warn = '';
|
||
if(goal === 'cut'){
|
||
warn += '减脂建议每天制造 400–500 kcal 缺口,每周降 0.5–1 kg 为宜;'
|
||
+ '摄入不要长期低于基础代谢。';
|
||
if(clamped) warn += ' 按缺口计算后低于安全下限,已自动调整为下限值。';
|
||
}
|
||
if(age < 18){
|
||
warn += ' 你仍处于生长发育期,热量摄入不应低于 2000 kcal,蛋白质与钙、铁尤其不能省;'
|
||
+ ' 建议先由家长陪同到青少年营养门诊做一次评估,再开始减重计划。';
|
||
}
|
||
warn += ' 出现以下情况请就医:体重短期骤增、合并高血压 / 糖尿病 / 脂肪肝 / 睡眠呼吸暂停。';
|
||
$('warn-note').textContent = warn.trim();
|
||
|
||
$('results').classList.remove('hidden');
|
||
$('results').scrollIntoView({behavior:'smooth', block:'start'});
|
||
}
|
||
|
||
function resetAll(){
|
||
$('height').value = 178;
|
||
$('weight').value = 177;
|
||
$('unit').value = 'jin';
|
||
$('age').value = 15;
|
||
$('sex').value = 'male';
|
||
$('pal').value = '1.6';
|
||
$('goal').value = 'cut';
|
||
compute();
|
||
}
|
||
|
||
window.addEventListener('DOMContentLoaded', compute);
|
||
</script>
|
||
</body>
|
||
</html>
|