import { Component } from '@angular/core';
import { NavController } from '@ionic/angular';
import Parse from "parse";

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
 
  results:Parse.Object[] = []
  segment = 'tang';  
  slides = [  
    { image: 'https://img.zcool.cn/community/01121d5ddd149ba80120686b38a76d.jpg@1280w_1l_2o_100sh.jpg' },  
    { image: 'https://img.zcool.cn/community/013a7f5ca6e2f5a801214168f3b8af.jpg@1280w_1l_2o_100sh.jpg' },  
    { image: 'https://img.zcool.cn/community/01898e5ca6e2eaa801208f8b58ffb4.jpg@1280w_1l_2o_100sh.jpg' }  
  ];  
  currentIndex = 0;  
  
  ngOnInit() {  
    setInterval(() => {  
      this.nextSlide();  
    }, 3000); // 每3秒切换一次图片  
  }  
  
  nextSlide() {  
    this.currentIndex = (this.currentIndex + 1) % this.slides.length;  
  }  
  
  search(event: any) {  
    console.log('Searching for:', event.detail.value);  
    if(event?.detail?.value){
      this.loadShigeList(event?.detail?.value)
    }
  }  
  filteredAuthors: any[] = [];  
  
 
  async loadShigeList(search:string){
    let query = new Parse.Query("Shige");
    query.select("title");
    query.contains("title",search);
    
    query.limit(7);
    this.results = await query.find();
  }

 

  constructor(private navController: NavController) {}
  goToDetailPage(item: Parse.Object) {
    this.results = []
    this.navController.navigateForward('/detail/' + item.id);
  }

}

