|
@@ -0,0 +1,47 @@
|
|
|
+import { Component } from '@angular/core';
|
|
|
+import {IonItem,IonInput, IonCardTitle, IonAvatar, IonCardContent, IonIcon, IonButtons, IonFooter, IonButton, IonCard, IonHeader, IonToolbar, IonTitle, IonContent, IonCardHeader, IonLabel} from '@ionic/angular/standalone';
|
|
|
+import { ExploreContainerComponent } from '../explore-container/explore-container.component';
|
|
|
+import { CommonModule } from '@angular/common';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-tab3',
|
|
|
+ templateUrl: 'tab3.page.html',
|
|
|
+ styleUrls: ['tab3.page.scss'],
|
|
|
+ standalone: true,
|
|
|
+ imports: [CommonModule,IonInput,IonItem,IonLabel,IonCardContent,IonHeader,IonAvatar,IonCardContent,IonCardHeader,IonCardTitle,IonFooter,IonButtons, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,IonHeader,IonCard,IonButton,IonIcon]
|
|
|
+})
|
|
|
+export class Tab3Page {
|
|
|
+ height: number | null = null;
|
|
|
+ weight: number | null = null;
|
|
|
+ bmi: number | null = null;
|
|
|
+ healthStatus: string = '';
|
|
|
+
|
|
|
+ // 更新身高
|
|
|
+ onHeightInput(event: any) {
|
|
|
+ this.height = parseFloat(event.target.value);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新体重
|
|
|
+ onWeightInput(event: any) {
|
|
|
+ this.weight = parseFloat(event.target.value);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算BMI
|
|
|
+ calculateBMI() {
|
|
|
+ if (this.height !== null && this.weight !== null && this.height > 0 && this.weight > 0) {
|
|
|
+ this.bmi = this.weight / ((this.height / 100) ** 2);
|
|
|
+ if (this.bmi < 18.5) {
|
|
|
+ this.healthStatus = '偏瘦';
|
|
|
+ } else if (this.bmi >= 18.5 && this.bmi < 24.9) {
|
|
|
+ this.healthStatus = '正常';
|
|
|
+ } else if (this.bmi >= 25 && this.bmi < 29.9) {
|
|
|
+ this.healthStatus = '偏重';
|
|
|
+ } else {
|
|
|
+ this.healthStatus = '超重';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.bmi = null;
|
|
|
+ this.healthStatus = '请输入有效的身高和体重。';
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|