import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';
import { AppNotification } from '@global/service/Notification';
import { Http } from '@global/service/Http';
import { App } from '@global/service/App';

@Component({
  selector: 'view-app-start-view',
  templateUrl: './app-start-view.page.html',
  styleUrls: ['./app-start-view.page.scss']
})
export class AppStartViewPage implements OnInit {

    /**
     * 计数器
     *
     * @memberof AppStartView
     */    
    public count:number =5;

    /**
     * 定时器指向
     *
     * @memberof AppStartView
     */ 
    public timer:any;

    /**
     * 实例化对象
     *
     * @memberof AppStartView
     */
    constructor(private $http: Http, private $notification: AppNotification,private $navCtrl:NavController,private $app:App) { }

    /**
     * angular生命周期
     *
     * @memberof AppStartView
     */
    ngOnInit() {
      this.timer=setInterval(() => {
        this.count --;
      }, 1000);
     }

    ngOnDestroy(): void {
      clearTimeout(this.timer);
    }

    /**
     * 登录
     *
     * @memberof AppStartView
     */
    public  login(){
      this.$navCtrl.navigateRoot([this.$app.getLoginPage()]);
    }

    /**
     * 跳过
     *
     * @memberof AppStartView
     */
    public viewJump(){
      this.$navCtrl.navigateRoot(this.$app.getDefaultPage());
      clearInterval(this.timer);
    }

  }