|
|
@ -16,22 +16,20 @@ import {HttpClient} from '@angular/common/http'; |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
export class LoginComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
loginForm: FormGroup; // 登录表单
|
|
|
|
loginForm: FormGroup; // 登录表单
|
|
|
|
code:string=""; |
|
|
|
code: string; |
|
|
|
|
|
|
|
|
|
|
|
constructor(private store: LocalStorageService, // 数据请求
|
|
|
|
constructor(private store: LocalStorageService, // 数据请求
|
|
|
|
private router: Router, // 路由
|
|
|
|
private router: Router, // 路由
|
|
|
|
private form: FormBuilder, // 表单校验
|
|
|
|
private form: FormBuilder, // 表单校验
|
|
|
|
private http: HttpClient, // http请求
|
|
|
|
private http: HttpClient, // http请求
|
|
|
|
private loginService: LoginService, |
|
|
|
private loginService: LoginService, |
|
|
|
private message: NzMessageService, |
|
|
|
private message: NzMessageService) { |
|
|
|
private modal: NzModalService) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
ngOnInit() { |
|
|
|
this.loginForm = this.form.group({ |
|
|
|
this.loginForm = this.form.group({ |
|
|
|
loginName: [null, [Validators.required]], |
|
|
|
loginName: [null, [Validators.required]], |
|
|
|
password: [null, [Validators.required]], |
|
|
|
password: [null, [Validators.required]], |
|
|
|
vertifyCode:[null, [Validators.required]]//验证码
|
|
|
|
verifyCode: [null, [Validators.required]] |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -40,29 +38,23 @@ export class LoginComponent implements OnInit { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
submitLogin() { |
|
|
|
submitLogin() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line:forin
|
|
|
|
// tslint:disable-next-line:forin
|
|
|
|
for (const i in this.loginForm.controls) { |
|
|
|
for (const i in this.loginForm.controls) { |
|
|
|
this.loginForm.controls[i].markAsDirty(); |
|
|
|
this.loginForm.controls[i].markAsDirty(); |
|
|
|
this.loginForm.controls[i].updateValueAndValidity(); |
|
|
|
this.loginForm.controls[i].updateValueAndValidity(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.loginForm.status == null || this.loginForm.status !== 'VALID') { |
|
|
|
if (this.loginForm.status == null || this.loginForm.status !== 'VALID') { |
|
|
|
// this.modal.warning({
|
|
|
|
|
|
|
|
// nzTitle: '提示',
|
|
|
|
|
|
|
|
// nzContent: '请填写用户和密码',
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if(this.loginForm.value.vertifyCode.toLowerCase() !== this.code ){ |
|
|
|
if (this.loginForm.value.verifyCode.toLowerCase() !== this.code ) { |
|
|
|
this.message.error("请填写正确的验证码"); |
|
|
|
this.message.error('请填写正确的验证码'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.loginService.userLogin(this.loginForm.value, data => { |
|
|
|
this.loginService.userLogin(this.loginForm.value, data => { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
data['return_data']['object']['menuList'] = data['return_data']['object']['menuList'].filter(o => o.showOnMobile == 0); |
|
|
|
data['return_data']['object']['menuList'] = data['return_data']['object']['menuList'].filter(o => o.showOnMobile === 0); |
|
|
|
this.store.set(ADMIN_INFO_OBJECT, data['return_data']['object']); |
|
|
|
this.store.set(ADMIN_INFO_OBJECT, data['return_data']['object']); |
|
|
|
this.store.set(TOKEN, data['return_data']['uniqueCode']); |
|
|
|
this.store.set(TOKEN, data['return_data']['uniqueCode']); |
|
|
|
this.store.set(INIT_FLAG, true); |
|
|
|
this.store.set(INIT_FLAG, true); |
|
|
|