影音导航
图片工具
生成器
计算器
中文
English
体型计算器
计算BMI、体脂率和理想体重,提供健康建议
基本信息
性别
👨
男性
👩
女性
年龄
测量单位
公制
英制
身体数据
身高 (厘米)
体重 (公斤)
腰围 (厘米) - 可选
臀围 (厘米) - 可选
📊 计算体型指标
22.1
正常体重
身体质量指数 (BMI)
BMI分类标准
偏瘦
< 18.5
正常
18.5 - 23.9
超重
24.0 - 27.9
肥胖
≥ 28.0
健康建议
class BodyShapeCalculator extends BaseCalculator { constructor() { super({ name: 'body-shape-calculator', displayName: '体型计算器', description: '计算BMI、体脂率和理想体重' }); } calculate(inputs) { const { gender, age, height, weight, waist, hip, unit } = inputs; // 转换单位到公制 let heightCm = height; let weightKg = weight; let waistCm = waist; let hipCm = hip; if (unit === 'imperial') { heightCm = height * 2.54; // 英寸转厘米 weightKg = weight * 0.453592; // 磅转公斤 waistCm = waist * 2.54; hipCm = hip * 2.54; } const heightM = heightCm / 100; // 计算BMI const bmi = weightKg / (heightM * heightM); // 计算理想体重范围 const idealWeightRange = this.calculateIdealWeight(heightM, gender); // 计算基础代谢率 (BMR) const bmr = this.calculateBMR(weightKg, heightCm, age, gender); // 计算体脂率估算 const bodyFatPercentage = this.estimateBodyFat(bmi, age, gender); // 计算腰臀比 let waistHipRatio = null; if (waistCm && hipCm) { waistHipRatio = waistCm / hipCm; } // BMI分类 const bmiCategory = this.getBMICategory(bmi); // 体型分析 const bodyShape = this.analyzeBodyShape(waistHipRatio, gender); return { bmi: bmi, bmiCategory: bmiCategory, idealWeightRange: idealWeightRange, bmr: bmr, bodyFatPercentage: bodyFatPercentage, waistHipRatio: waistHipRatio, bodyShape: bodyShape, healthRisk: this.assessHealthRisk(bmi, waistHipRatio, age), recommendations: this.generateRecommendations(bmi, bmiCategory, age, gender) }; } calculateIdealWeight(heightM, gender) { // 使用修正的BMI方法计算理想体重范围 const minBMI = 18.5; const maxBMI = 23.9; return { min: minBMI * heightM * heightM, max: maxBMI * heightM * heightM, optimal: 21.7 * heightM * heightM // 最佳BMI值 }; } calculateBMR(weight, height, age, gender) { // 使用Mifflin-St Jeor方程 if (gender === 'male') { return 10 * weight + 6.25 * height - 5 * age + 5; } else { return 10 * weight + 6.25 * height - 5 * age - 161; } } estimateBodyFat(bmi, age, gender) { // 基于BMI和年龄的体脂率估算公式 let bodyFat; if (gender === 'male') { bodyFat = 1.20 * bmi + 0.23 * age - 16.2; } else { bodyFat = 1.20 * bmi + 0.23 * age - 5.4; } return Math.max(0, Math.min(50, bodyFat)); // 限制在合理范围内 } getBMICategory(bmi) { if (bmi < 18.5) return { name: '偏瘦', class: 'underweight', risk: '营养不良风险' }; if (bmi < 24) return { name: '正常体重', class: 'normal', risk: '健康范围' }; if (bmi < 28) return { name: '超重', class: 'overweight', risk: '轻度健康风险' }; return { name: '肥胖', class: 'obese', risk: '高健康风险' }; } analyzeBodyShape(waistHipRatio, gender) { if (!waistHipRatio) return null; const shapes = { male: { apple: waistHipRatio > 0.9, pear: waistHipRatio < 0.85, normal: waistHipRatio >= 0.85 && waistHipRatio <= 0.9 }, female: { apple: waistHipRatio > 0.8, pear: waistHipRatio < 0.75, hourglass: waistHipRatio >= 0.75 && waistHipRatio <= 0.8 } }; const genderShapes = shapes[gender]; if (genderShapes.apple) return { type: '苹果型', description: '腰部脂肪较多' }; if (genderShapes.pear) return { type: '梨型', description: '臀部相对较宽' }; if (gender === 'female' && genderShapes.hourglass) return { type: '沙漏型', description: '腰臀比例协调' }; if (gender === 'male' && genderShapes.normal) return { type: '正常型', description: '体型比例正常' }; return { type: '其他', description: '体型特征不明显' }; } assessHealthRisk(bmi, waistHipRatio, age) { let riskLevel = 0; let risks = []; // BMI风险评估 if (bmi < 18.5) { riskLevel += 1; risks.push('体重不足可能导致营养不良'); } else if (bmi >= 28) { riskLevel += 3; risks.push('肥胖增加心血管疾病风险'); } else if (bmi >= 24) { riskLevel += 1; risks.push('超重可能影响健康'); } // 腰臀比风险评估 if (waistHipRatio) { if (waistHipRatio > 0.9) { riskLevel += 2; risks.push('腹部脂肪过多增加代谢疾病风险'); } } // 年龄风险评估 if (age > 40) { riskLevel += 1; risks.push('年龄增长需要更加注意健康管理'); } const levels = ['低', '中等', '较高', '高']; return { level: levels[Math.min(riskLevel, 3)], risks: risks }; } generateRecommendations(bmi, bmiCategory, age, gender) { const recommendations = []; // 基于BMI的建议 if (bmiCategory.class === 'underweight') { recommendations.push('增加营养摄入,选择高蛋白、高热量的健康食物'); recommendations.push('进行适量的力量训练,增加肌肉量'); recommendations.push('咨询营养师制定增重计划'); } else if (bmiCategory.class === 'overweight' || bmiCategory.class === 'obese') { recommendations.push('控制热量摄入,选择低脂、高纤维食物'); recommendations.push('增加有氧运动,每周至少150分钟中等强度运动'); recommendations.push('建立健康的饮食习惯,避免高糖高脂食物'); } else { recommendations.push('保持当前的健康体重'); recommendations.push('继续均衡饮食和规律运动'); } // 通用健康建议 recommendations.push('每天保证充足的睡眠(7-9小时)'); recommendations.push('多喝水,每天至少8杯水'); recommendations.push('定期进行健康检查'); // 年龄相关建议 if (age > 40) { recommendations.push('增加钙质和维生素D的摄入'); recommendations.push('注意骨密度检查'); } return recommendations; } } class BodyShapeCalculatorUI { constructor() { this.calculator = new BodyShapeCalculator(); this.currentGender = 'male'; this.currentUnit = 'metric'; this.init(); } init() { this.bindEvents(); this.updateUnitLabels(); } bindEvents() { // 性别选择 document.querySelectorAll('.gender-btn').forEach(btn => { btn.addEventListener('click', () => this.selectGender(btn)); }); // 单位选择 document.querySelectorAll('.unit-btn').forEach(btn => { btn.addEventListener('click', () => this.selectUnit(btn)); }); // 计算按钮 document.getElementById('calculateBtn').addEventListener('click', () => { this.calculateBodyShape(); }); } selectGender(btn) { document.querySelectorAll('.gender-btn').forEach(b => b.classList.remove('active')); btn.classList.add('active'); this.currentGender = btn.dataset.gender; } selectUnit(btn) { document.querySelectorAll('.unit-btn').forEach(b => b.classList.remove('active')); btn.classList.add('active'); this.currentUnit = btn.dataset.unit; this.updateUnitLabels(); } updateUnitLabels() { const heightLabel = document.getElementById('heightLabel'); const weightLabel = document.getElementById('weightLabel'); const heightInput = document.getElementById('height'); const weightInput = document.getElementById('weight'); if (this.currentUnit === 'metric') { heightLabel.textContent = '身高 (厘米)'; weightLabel.textContent = '体重 (公斤)'; heightInput.placeholder = '例如: 170'; weightInput.placeholder = '例如: 65'; heightInput.value = heightInput.value || '170'; weightInput.value = weightInput.value || '65'; } else { heightLabel.textContent = '身高 (英寸)'; weightLabel.textContent = '体重 (磅)'; heightInput.placeholder = '例如: 67'; weightInput.placeholder = '例如: 143'; heightInput.value = heightInput.value || '67'; weightInput.value = weightInput.value || '143'; } } collectInputs() { return { gender: this.currentGender, age: parseFloat(document.getElementById('age').value), height: parseFloat(document.getElementById('height').value), weight: parseFloat(document.getElementById('weight').value), waist: parseFloat(document.getElementById('waist').value) || null, hip: parseFloat(document.getElementById('hip').value) || null, unit: this.currentUnit }; } async calculateBodyShape() { const calculateBtn = document.getElementById('calculateBtn'); const originalText = calculateBtn.textContent; try { calculateBtn.disabled = true; calculateBtn.innerHTML = '🔄 计算中...'; const inputs = this.collectInputs(); const result = this.calculator.calculate(inputs); this.displayResult(result); } catch (error) { this.showError(error.message); } finally { calculateBtn.disabled = false; calculateBtn.innerHTML = originalText; } } displayResult(result) { const resultSection = document.getElementById('resultSection'); const bmiValue = document.getElementById('bmiValue'); const bmiCategory = document.getElementById('bmiCategory'); const resultGrid = document.getElementById('resultGrid'); const recommendationsList = document.getElementById('recommendationsList'); // 显示BMI bmiValue.textContent = this.formatNumber(result.bmi, 1); bmiCategory.textContent = result.bmiCategory.name; bmiCategory.className = `bmi-category bmi-${result.bmiCategory.class}`; // 显示详细结果 let resultHTML = `
理想体重范围
${this.formatNumber(result.idealWeightRange.min, 1)} - ${this.formatNumber(result.idealWeightRange.max, 1)}
公斤
基础代谢率
${this.formatNumber(result.bmr, 0)}
卡路里/天
体脂率估算
${this.formatNumber(result.bodyFatPercentage, 1)}
%
`; if (result.waistHipRatio) { resultHTML += `
腰臀比
${this.formatNumber(result.waistHipRatio, 2)}
比值
`; } if (result.bodyShape) { resultHTML += `
体型分析
${result.bodyShape.type}
${result.bodyShape.description}
`; } resultHTML += `
健康风险
${result.healthRisk.level}
风险等级
`; resultGrid.innerHTML = resultHTML; // 显示健康建议 recommendationsList.innerHTML = result.recommendations.map(rec => `
${rec}
` ).join(''); resultSection.style.display = 'block'; resultSection.scrollIntoView({ behavior: 'smooth', block: 'center' }); } formatNumber(number, decimals = 2) { if (isNaN(number)) return 'N/A'; return Number(number).toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: decimals }); } showError(message) { alert('计算错误:' + message); } } // 初始化 document.addEventListener('DOMContentLoaded', () => { new BodyShapeCalculatorUI(); });