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