|
|
@ -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 { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
import { AbstractControl, 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'; |
|
|
@ -19,7 +18,8 @@ declare var abp: any |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
validateForm!: FormGroup; |
|
|
|
validateForm!: FormGroup; |
|
|
|
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, private cookieService: CookieService, private fb: FormBuilder, private message: NzMessageService, private notificationService: NzNotificationService) { |
|
|
|
passwordValidateForm!: FormGroup; |
|
|
|
|
|
|
|
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, private fb: FormBuilder, private message: NzMessageService, private notificationService: NzNotificationService) { |
|
|
|
const { password } = MyValidators; |
|
|
|
const { password } = MyValidators; |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
userName: [null, [Validators.required]], |
|
|
|
userName: [null, [Validators.required]], |
|
|
@ -27,6 +27,11 @@ export class LoginComponent implements OnInit { |
|
|
|
remember: [null], |
|
|
|
remember: [null], |
|
|
|
autologin: [null], |
|
|
|
autologin: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
this.passwordValidateForm = this.fb.group({ |
|
|
|
|
|
|
|
oldpassword: [null, [Validators.required]], |
|
|
|
|
|
|
|
newpassword: [null, [Validators.required, password]], |
|
|
|
|
|
|
|
affirmpassword: [null, [Validators.required, password]] |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
ngOnInit() { |
|
|
@ -51,14 +56,11 @@ export class LoginComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
errmsg: string = ''; //错误信息
|
|
|
|
errmsg: string = ''; //错误信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//跳转注册页面
|
|
|
|
//跳转注册页面
|
|
|
|
toRegister() { |
|
|
|
toRegister() { |
|
|
|
this.router.navigate(['/register']) |
|
|
|
this.router.navigate(['/register']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//记住密码
|
|
|
|
//记住密码
|
|
|
|
rememberInfo() { |
|
|
|
rememberInfo() { |
|
|
|
// 判断用户是否勾选记住密码,如果勾选,在本地储存中储存登录信息
|
|
|
|
// 判断用户是否勾选记住密码,如果勾选,在本地储存中储存登录信息
|
|
|
@ -74,9 +76,6 @@ export class LoginComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
remember: any//记住密码
|
|
|
|
remember: any//记住密码
|
|
|
|
autologin: any//自动登录
|
|
|
|
autologin: any//自动登录
|
|
|
|
isLoading = false; |
|
|
|
isLoading = false; |
|
|
@ -108,11 +107,10 @@ export class LoginComponent implements OnInit { |
|
|
|
}).subscribe( |
|
|
|
}).subscribe( |
|
|
|
(data: any) => { |
|
|
|
(data: any) => { |
|
|
|
sessionStorage.setItem("token", data.result.accessToken); |
|
|
|
sessionStorage.setItem("token", data.result.accessToken); |
|
|
|
this.cookieService.set("token", data.result.accessToken, null, '/'); |
|
|
|
|
|
|
|
this.cookieService.set("refreshToken", data.result.encryptedAccessToken, null, '/'); |
|
|
|
|
|
|
|
sessionStorage.setItem("encryptedAccessToken", data.result.encryptedAccessToken); |
|
|
|
sessionStorage.setItem("encryptedAccessToken", data.result.encryptedAccessToken); |
|
|
|
console.log('token', data) |
|
|
|
console.log('token', data.result) |
|
|
|
this.http.get('/api/services/app/Session/GetCurrentLoginInformations').subscribe((data: any) => { |
|
|
|
this.http.get('/api/services/app/Session/GetCurrentLoginInformations').subscribe((data: any) => { |
|
|
|
|
|
|
|
console.log('GetCurrentLoginInformations', data.result) |
|
|
|
sessionStorage.setItem('userdata', JSON.stringify(data.result.user)) |
|
|
|
sessionStorage.setItem('userdata', JSON.stringify(data.result.user)) |
|
|
|
sessionStorage.setItem('userdataOfgasstation', JSON.stringify(data.result.user)) |
|
|
|
sessionStorage.setItem('userdataOfgasstation', JSON.stringify(data.result.user)) |
|
|
|
this.isLoading = false; |
|
|
|
this.isLoading = false; |
|
|
@ -129,10 +127,12 @@ export class LoginComponent implements OnInit { |
|
|
|
sessionStorage.setItem("isGasStation", 'true'); |
|
|
|
sessionStorage.setItem("isGasStation", 'true'); |
|
|
|
this.router.navigate(['/todaywarning/petrolStation']) |
|
|
|
this.router.navigate(['/todaywarning/petrolStation']) |
|
|
|
this.message.create('success', `登录成功`); |
|
|
|
this.message.create('success', `登录成功`); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sessionStorage.setItem("isGasStation", 'false'); |
|
|
|
sessionStorage.setItem("isGasStation", 'false'); |
|
|
|
this.router.navigate(['/homepage']) |
|
|
|
this.router.navigate(['/homepage']) |
|
|
|
this.message.create('success', `登录成功`); |
|
|
|
this.message.create('success', `登录成功`); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, err => { |
|
|
|
}, err => { |
|
|
@ -149,17 +149,12 @@ export class LoginComponent implements OnInit { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
roleList = [ |
|
|
|
|
|
|
|
'管理员', '职工' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectedRole: string |
|
|
|
|
|
|
|
selecteRole(role) { |
|
|
|
|
|
|
|
this.selectedRole = role |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
forget() { |
|
|
|
forget() { |
|
|
|
this.message.create('warning', `请联系管理员`); |
|
|
|
this.message.create('warning', `请联系管理员`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>; |
|
|
|
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>; |
|
|
|
export type MyValidationErrors = Record<string, MyErrorsOptions>; |
|
|
|
export type MyValidationErrors = Record<string, MyErrorsOptions>; |
|
|
|