|
|
|
@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { HttpClient } from '@angular/common/http' |
|
|
|
|
import { Router, ActivatedRoute } from '@angular/router' |
|
|
|
|
import { CacheTokenService } from '../../service/cache-token.service'//引入服务
|
|
|
|
|
import { CookieService } from 'ngx-cookie-service';//cookie插件
|
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
|
import { Base64 } from 'js-base64'; |
|
|
|
@ -17,7 +16,7 @@ import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
validateForm!: FormGroup; |
|
|
|
|
constructor(private http: HttpClient, private router: Router, public token: CacheTokenService, private cookieService: CookieService, private fb: FormBuilder, private message: NzMessageService) { } |
|
|
|
|
constructor(private http: HttpClient, private router: Router, public token: CacheTokenService, private fb: FormBuilder, private message: NzMessageService) { } |
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
@ -107,14 +106,11 @@ export class LoginComponent implements OnInit {
|
|
|
|
|
this.autoLogin() |
|
|
|
|
sessionStorage.setItem("token", data.token); |
|
|
|
|
sessionStorage.setItem("refreshToken", data.refreshToken); |
|
|
|
|
this.cookieService.set("token", data.token, null, '/'); |
|
|
|
|
this.cookieService.set("refreshToken", data.refreshToken, null, '/'); |
|
|
|
|
this.router.navigate(['/system/organization']) |
|
|
|
|
this.message.create('success', `登录成功`); |
|
|
|
|
}, |
|
|
|
|
(err) => { |
|
|
|
|
this.isLoading = false; |
|
|
|
|
this.message.create('error', err.error.error.details); |
|
|
|
|
|
|
|
|
|
//调用服务中的function刷新token
|
|
|
|
|
this.token.startUp() |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|