import { Component, OnInit } from '@angular/core';
import {Transfer} from '../service/transfer';
import {NavController} from '@ionic/angular';
import {Api} from '../service/api';

@Component({
  selector: 'v-index',
  templateUrl: './index.page.html',
  styleUrls: ['./index.page.scss'],
})
export class IndexPage implements OnInit {

  constructor(private tf: Transfer, public nav: NavController, private api: Api) { }

  ngOnInit() { }

  goTo(e) {
    // setTimeout(() => {
    //   // this.tf.transfer({url: '/' + e});
    //   this.nav.navigateRoot('/' + e);
    // }, 300);

    this.api.user.getSelfInfo(['', (data) => {
      if (data.userName) {
        this.nav.navigateRoot('/' + e);
      } else {
        this.api.presentMsgToast('用户未登录,请先登录');
      }
    }]);
  }
}
