import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController, ToastController } from 'ionic-angular';

import { Http } from '@angular/http';

import { AppService } from '../../service/appHttpService';
import { JoinDetailPage } from '../joinDetail/joinDetail';

@IonicPage()
@Component({
  selector: 'page-activityDetail',
  templateUrl: 'activityDetail.html',
})
export class ActivityDetailPage {

  batches: object[];
  activity: object;
  //页面报名保存展示
  isCover: boolean = false;
  //活动详情显示
  introduce: string;



  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public alertCtrl: AlertController,
    public http: Http,
    public appService: AppService, public toast: ToastController) {
    // console.log(this.navParams.get("activityId"));
    this.subIntroduce("2018年市委组织部体检活动将在3月5号在上海市人民医院进行，共分八批，欢迎大家根据个人安排进行报名工作。2018年市委组织部体检活动将在3月5号在上海市人民医院进行，共分八批，欢迎大家根据个人安排进行报名工作。");
    this.activity = {
      id: 1,
      time: "2018/4/10",
      location: "上海市人民医院（虹桥路xxxx号）",
      musterTime: "自行前往",
      deadlineTime: "所有处级以下人员"
    }

    this.batches = [{
      id: 1,
      time: "03/20",
      quantity: 20
    }, {
      id: 2,
      time: "03/27",
      quantity: 20
    }, {
      id: 3,
      time: "04/03",
      quantity: 20
    }, {
      id: 4,
      time: "04/10",
      quantity: 20
    }, {
      id: 5,
      time: "04/17",
      quantity: 20
    }, {
      id: 6,
      time: "04/24",
      quantity: 20
    }, {
      id: 7,
      time: "05/01",
      quantity: 20
    }, {
      id: 8,
      time: "05/08",
      quantity: 20
    }];
  }

  goJoinDetail(){
    this.navCtrl.push("JoinDetailPage");
  }

    //活动介绍限定65个字符串，多余以省略号代替
    subIntroduce(str: string) {
      if (!str) this.introduce = '';
      if (str.length <= 65) this.introduce = str;
      if (str.length > 65) this.introduce = str.substr(0, 65) + "...";
    }
  
    //具体介绍
    hidden() {
      this.isCover = false;
    }
    show() {
      this.isCover = true;
    }

}
