import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-tab1',
  templateUrl: './tab1.page.html',
  styleUrls: ['./tab1.page.scss'],
})
export class Tab1Page implements OnInit {
  isListening = false;
  currentLocation = '正在定位...';
  
  features = [
    { 
      title: '病虫害急救', 
      icon: 'bug', 
      path: '/pest-control',
      animation: 'pest-animation'
    },
    { 
      title: '水肥计算器', 
      icon: 'water', 
      path: '/fertilizer-calculator',
      animation: 'water-animation'
    },
    { 
      title: '市场行情', 
      icon: 'trending-up', 
      path: '/market',
      animation: ''
    },
    { 
      title: '专家预约', 
      icon: 'people', 
      path: '/experts',
      animation: ''
    },
    // 新增两个功能入口
    
  ];
  
  newsList = [
    {
      title: '周口市小麦赤霉病预警',
      summary: '近期多雨天气导致赤霉病高发，请及时防治...',
      image: 'assets/images/wheat-disease.jpg',
      date: '5月12日',
      views: '1.2k'
    },
    {
      title: '夏季玉米种植技术要点',
      summary: '掌握这5个关键点，提高玉米产量30%...',
      image: 'assets/images/corn-planting.jpg',
      date: '5月10日',
      views: '856'
    }
  ];

  constructor(private router: Router) {}

  ngOnInit() {
    this.simulateLocation();
  }

  simulateLocation() {
    setTimeout(() => {
      this.currentLocation = '河南周口';
    }, 1500);
  }

  startVoiceInput() {
    this.isListening = true;
    console.log('开始语音输入...');
  }

  stopVoiceInput() {
    this.isListening = false;
    console.log('结束语音输入...');
  }

  navigateTo(path: string) {
    this.router.navigate([path]);
  }

  openWeatherAlert() {
    console.log('打开天气预警详情');
  }
}