import { Component, Renderer, ElementRef } from '@angular/core';
import { NavParams, NavController, AlertController, Events } from 'ionic-angular';

import { WorkbenchPage } from './workbench/workbench';
import { ContactPage } from './contact/contact';
import { HomePage } from './home/home';
import { MinePage } from './mine/mine';

import { Storage } from '@ionic/storage';

import { ModifyPasswordPage } from '../modifyPassword/modifyPassword';
import { AppService, AppGlobal } from '../../service/appHttpService';
import {NoticePage} from "./notice/notice";

@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {

   tab1Root = HomePage;
   tab2Root = ContactPage;
   tab3Root = WorkbenchPage;
   tab4Root = MinePage;

  tabRoots: Object[];

  userInfo: any;

  userid: string;

  roleflag: any;

  role: any;
  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public alertCtrl: AlertController,
    public storage: Storage,
    public event: Events,
    public render: Renderer,
    public elementRef: ElementRef,
    public appService: AppService
  ) {
    this.tabRoots = [{
      root: HomePage,
      tabTitle: '首页',
      tabIcon: 'myhome'
    }, {
      root: ContactPage,
      tabTitle: '通讯录',
      tabIcon: 'mycontact'
    }, {
      root: NoticePage,
      tabTitle: '消息',
      tabIcon: 'myworkbench'
    }, {
      root: MinePage,
      tabTitle: '我的',
      tabIcon: 'mymine'
    }];

    //判断是否密码为初始六个0
    // this.userInfo = this.storage.get("userLoginInfo").then((value) => {
    //   this.userInfo = value;
    //   if (this.userInfo.password == '000000') {
    //     //进入修改密码页面
    //     this.navCtrl.push("ModifyPasswordPage")
    //   }
    // });

  }

  // ionViewDidEnter() {
  //   this.queryUserRole();
  // }

  // //获取角色
  // queryUserRole() {
  //   this.storage.get("userLoginInfo").then((data) => {
  //     this.appService.ObserverHttpGet("/wisdomgroup/sysmanagement/user/queryRoleByUserid", { userid: data.userid })
  //       .subscribe((res: Response) => {
  //         this.role = res.json();
  //       }, error => {
  //         this.appService.alert('网络异常！');
  //       }
  //       );
  //   });
  // }
}
