import { Component } from '@angular/core';
import {IonicPage, NavController, NavParams, ModalController, App, ToastController} from 'ionic-angular';
import {SelectBlockPage} from "../select-block/select-block";
import {Response} from "@angular/http";
import { AppService } from "../../../service/appHttpService";

@IonicPage()
@Component({
  selector: 'page-add-block',
  templateUrl: 'add-block.html',
})
export class AddBlockPage {

    groupName;
  constructor(public navCtrl: NavController, public navParams: NavParams,
              public modalCtrl: ModalController, public appService: AppService,
              public toastCtrl: ToastController) {
  }

  ionViewDidLoad() {
  }

    goSelectmodal(){
      this.navCtrl.push('SelectBlockPage');
    }

    //创建分组
    done(){
      const data = {
          groupName:this.groupName
      };
        this.appService.ObserverHttpPostData("/wisdomgroup/modules/telpBook/",data)
            .subscribe((res: Response) => {
                    let data = res.json();
                    let toast = this.toastCtrl.create({
                        message:'创建成功',
                        duration:2000,
                        dismissOnPageChange: true,
                    });
                    toast.present();
                    this.navCtrl.pop();
                }, error => {
                    this.appService.alert('网络异常！');
                }
            );
    }

}
