|
|
@ -3,10 +3,11 @@ 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 { CookieService } from 'ngx-cookie-service';//cookie插件
|
|
|
|
import { 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'; |
|
|
|
import { NzNotificationService } from 'ng-zorro-antd/notification'; |
|
|
|
import { NzNotificationService } from 'ng-zorro-antd/notification'; |
|
|
|
|
|
|
|
import { NzSafeAny } from 'ng-zorro-antd/core/types'; |
|
|
|
|
|
|
|
|
|
|
|
declare var abp: any |
|
|
|
declare var abp: any |
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
@ -18,15 +19,18 @@ 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) { } |
|
|
|
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) { |
|
|
|
|
|
|
|
const { password } = MyValidators; |
|
|
|
ngOnInit() { |
|
|
|
|
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
userName: [null, [Validators.required]], |
|
|
|
userName: [null, [Validators.required]], |
|
|
|
password: [null, [Validators.required]], |
|
|
|
password: [null, [Validators.required, password]], |
|
|
|
remember: [null], |
|
|
|
remember: [null], |
|
|
|
autologin: [null], |
|
|
|
autologin: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
|
|
|
|
|
|
|
//如果本地储存了账号密码信息,那就回显在输入框
|
|
|
|
//如果本地储存了账号密码信息,那就回显在输入框
|
|
|
|
let account = localStorage.getItem('account') |
|
|
|
let account = localStorage.getItem('account') |
|
|
|
let password = localStorage.getItem('password') |
|
|
|
let password = localStorage.getItem('password') |
|
|
@ -157,3 +161,24 @@ export class LoginComponent implements OnInit { |
|
|
|
this.message.create('warning', `请联系管理员`); |
|
|
|
this.message.create('warning', `请联系管理员`); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>; |
|
|
|
|
|
|
|
export type MyValidationErrors = Record<string, MyErrorsOptions>; |
|
|
|
|
|
|
|
export class MyValidators extends Validators { |
|
|
|
|
|
|
|
static password(control: AbstractControl): MyValidationErrors | null { |
|
|
|
|
|
|
|
const value = control.value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isEmptyInputValue(value)) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return isPassword(value) ? null : { mobile: { 'zh-cn': `长度 12 位以上,包含①大写字母、②小写字母、③数字、④特殊字符四种中的三种组合`, en: `Password phone number is not valid` } }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function isEmptyInputValue(value: NzSafeAny): boolean { |
|
|
|
|
|
|
|
return value == null || value.length === 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function isPassword(value: string): boolean { |
|
|
|
|
|
|
|
return typeof value === 'string' && /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{12,99}$/.test(value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|