import {Component, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams, Slides} from 'ionic-angular';
import {DetailPage} from "../item/detail/detail";
import {ResultPage} from "../result/result";
import {CreatePage} from "../item/create/create";
import {DesicrPage} from "../item/desicr/desicr";


declare var Swiper;
@IonicPage()
@Component({
  selector: 'page-list',
  templateUrl: 'list.html',
})
export class ListPage {
    @ViewChild('contentSlides') contentSlides :Slides;
    menuList = [
        {name:'草稿箱',id:'1',itemList:[{one:''},{one:''},{one:''},{one:''},]},
        {name:'已发布',id:'2',itemList:[{one:''},{one:''},{one:''},{one:''},]},
        {name:'已过期',id:'3',itemList:[{one:''},{one:''},{one:''},{one:''},]},
    ];
    showOp = false;
    swiperIndex;
    swiper;
  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
   this.initSwiper();
   this.swiperIndex = 0;
  }

    initSwiper(){
        this.swiper = new Swiper('.pageMenuSlides .swiper-container', {
            //设置slider容器能够同时显示的slides数量(
            slidesPreView: 3,
            //slide之间的距离（单位px）
            spaceBetween: 0,
            //断点设定：根据屏幕宽度设置某参数为不同的值
            breakpoints: {
                1024: {
                    slidesPerView: 3,
                    spaceBetween: 0
                },
                768: {
                    slidesPerView: 3,
                    spaceBetween: 0
                },
                640: {
                    slidesPerView: 3,
                    spaceBetween: 0
                },
                320: {
                    slidesPerView: 3,
                    spaceBetween: 0
                }
            }
        });
    }

    selectPageMenu(index) {
        this.swiperIndex = index;
        //切换页面
        this.contentSlides.slideTo(index);
    }

    slideChanged() {
        //getActiveIndex()获得当前页面的index
        let index = this.contentSlides.getActiveIndex();
        //s切换菜单
        this.swiper.slideTo(index, 300);

    }

    showOpra(item){
      this.showOp = true;
    }

    //创建
    create(){
      this.navCtrl.push('DesicrPage');
    }

    //查看
    look(){
      this.navCtrl.push('DetailPage');
    }

    //结果
    result(){
      this.navCtrl.push('ResultPage');
    }

    //复制
    copy(){

    }

    //删除
    delete(){

    }

}
