fengxiang
2018-02-28 63006583f40f12781c4cadfd412a8c459565ae8e
src/app/routes/passport/login/login.component.ts
@@ -1,11 +1,12 @@
import { Authorization } from '@business/entity/token';
import { LoginService } from './../../../business/services/http/login.service';
import { LoginService } from '@business/services/http/login.service';
import { SettingsService } from '@delon/theme';
import { Component, OnDestroy, Inject } from '@angular/core';
import { Component, OnDestroy, Inject, Optional } from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd';
import { SocialService, SocialOpenType, ITokenService, DA_SERVICE_TOKEN } from '@delon/auth';
import { ReuseTabService } from '@delon/abc';
import { environment } from '@env/environment';
import { CookieService } from 'angular2-cookie/services/cookies.service';
@Component({
@@ -27,8 +28,8 @@
        public msg: NzMessageService,
        private settingsService: SettingsService,
        private socialService: SocialService,
        @Optional() @Inject(ReuseTabService) private reuseTabService: ReuseTabService,
        private loginService:LoginService,
        private _cookieService:CookieService,
        @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {
        this.form = fb.group({
            userName: [null, [Validators.required, Validators.minLength(5)]],
@@ -37,9 +38,8 @@
            captcha: [null, [Validators.required]],
            remember: [true]
        });
        let nowTime = new Date();
        nowTime.setDate(nowTime.getDate()+1);
        this._cookieService.put('test','test',{expires:nowTime});
        // let nowTime = new Date();
        // nowTime.setDate(nowTime.getDate()+1);
    }
    // region: fields
@@ -86,6 +86,8 @@
            this.loginService.validate(this.userName.value,this.password.value).subscribe(
                (res:Authorization) => {
                   if(res.token!=null){
                        // 清空路由复用信息
                       this.reuseTabService.clear();
                       this.tokenService.set({
                           token: res.token,
                           name: this.userName.value,