import {Component, OnInit} from '@angular/core';
import {RequestService} from '../common/request.service';
import {LocalStorageService} from 'ngx-webstorage';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {AppService} from '../../app.service';
declare let md5;
@Component({
    selector: 'smart-check-auth',
    templateUrl: './check-auth.component.html',
    styles: []
})
export class CheckAuthComponent implements OnInit {

    constructor(
        private reqSer: RequestService,
        private router: Router,
        private appSer:AppService,
        private activedRoute:ActivatedRoute,
        private $localStorage: LocalStorageService,
    ) {
    }

    ngOnInit() {
        this.activedRoute.queryParams.subscribe((params:Params)=>{
            if (params.token) {
                this.$localStorage.store('accessToken', params.token);
                if (params.type) {
                    this.appSer.setInfoResource(params.type)
                    this.router.navigate(['app/main/assetManage']);
                } else {
                    this.router.navigate(['app/main/home']);
                }
            }
        })
    }

}
