import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonButtons, IonIcon, IonButton, IonCard, IonCardHeader, IonCardContent, IonItem, IonLabel, IonInput, IonCardTitle } from '@ionic/angular/standalone';
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
import { Router } from '@angular/router';

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss'],
  standalone: true,
  imports: [
    CommonModule,
    FormsModule,
    IonHeader,
    IonToolbar,
    IonTitle,
    IonButtons,
    IonIcon,
    IonButton,
    IonCard,
    IonCardHeader,
    IonCardContent,
    IonCardTitle,
    IonItem,
    IonLabel,
    IonInput,
    IonContent,
    ExploreContainerComponent
  ],
})
export class Tab1Page {
  // 定义所需的属性
  location: string = '';
  crop: string = '';
  symptom: string = '';
  plantingPlan: string | null = null;
  plantDoctorAdvice: string | null = null;

  constructor(private router: Router) {}

  // 定义获取种植方案的方法
  getPlantingPlan() {
    this.router.navigate(['/tabs/tab4']);
    // 这里可以调用API或服务来获取种植方案
    this.plantingPlan = `在${this.location}种植${this.crop}的最佳方案是...`;
  }

  // 定义获取病虫害处理建议方法
  getPlantDoctorAdvice() {
    this.router.navigate(['/tabs/tab5']);
    // 这里可以调用API来获取病虫害处理建议
    this.plantDoctorAdvice = `对于症状"${this.symptom}"，建议采取以下措施...`;
  }
}