|
|
@ -2,11 +2,16 @@ import { Component, OnInit } from '@angular/core'; |
|
|
|
import {LocalStorageService} from '../../services/local-storage.service'; |
|
|
|
import {LocalStorageService} from '../../services/local-storage.service'; |
|
|
|
import {DATA, ROUTENAME, MENUNAME, CHILDMENUNAME, INIT_FLAG, ADMIN_INFO_OBJECT, TOKEN} from '../../services/local-storage.namespace'; |
|
|
|
import {DATA, ROUTENAME, MENUNAME, CHILDMENUNAME, INIT_FLAG, ADMIN_INFO_OBJECT, TOKEN} from '../../services/local-storage.namespace'; |
|
|
|
import {LoginService} from '../../services/login.service'; |
|
|
|
import {LoginService} from '../../services/login.service'; |
|
|
|
import {NzMessageService} from 'ng-zorro-antd'; |
|
|
|
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; |
|
|
|
import {Router} from '@angular/router'; |
|
|
|
import {Router} from '@angular/router'; |
|
|
|
import {IconService} from '../../services/icon.service'; |
|
|
|
import {IconService} from '../../services/icon.service'; |
|
|
|
import {RechargeService} from '../../services/recharge.service'; |
|
|
|
import {RechargeService} from '../../services/recharge.service'; |
|
|
|
import {CommonsService} from '../../services/commons.service'; |
|
|
|
import {CommonsService} from '../../services/commons.service'; |
|
|
|
|
|
|
|
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; |
|
|
|
|
|
|
|
import {ValidatorsService} from '../../services/validators.service'; |
|
|
|
|
|
|
|
import {Md5} from 'ts-md5'; |
|
|
|
|
|
|
|
import {environment} from '../../../environments/environment'; |
|
|
|
|
|
|
|
import {HttpClient} from '@angular/common/http'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-navigation', |
|
|
|
selector: 'app-navigation', |
|
|
@ -15,6 +20,9 @@ import {CommonsService} from '../../services/commons.service'; |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class NavigationComponent implements OnInit { |
|
|
|
export class NavigationComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
visibleUpdatePwd = false; // 修改密码抽屉
|
|
|
|
|
|
|
|
validateForm: FormGroup; // 定义表单
|
|
|
|
|
|
|
|
|
|
|
|
isCollapsed = false; |
|
|
|
isCollapsed = false; |
|
|
|
userInfo: any; |
|
|
|
userInfo: any; |
|
|
|
menuList: any; |
|
|
|
menuList: any; |
|
|
@ -25,11 +33,20 @@ export class NavigationComponent implements OnInit { |
|
|
|
private loginService: LoginService, |
|
|
|
private loginService: LoginService, |
|
|
|
private message: NzMessageService, |
|
|
|
private message: NzMessageService, |
|
|
|
private commonsService: CommonsService, |
|
|
|
private commonsService: CommonsService, |
|
|
|
|
|
|
|
private http: HttpClient, // http请求
|
|
|
|
private iconService: IconService, |
|
|
|
private iconService: IconService, |
|
|
|
|
|
|
|
private modal: NzModalService, |
|
|
|
|
|
|
|
private fb: FormBuilder, // 表单
|
|
|
|
private router: Router, |
|
|
|
private router: Router, |
|
|
|
) { } |
|
|
|
) { } |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
|
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
|
|
|
|
oldPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]], |
|
|
|
|
|
|
|
newPassword: [null, [Validators.required, ValidatorsService.minLength(6), ValidatorsService.maxLength(16)]], |
|
|
|
|
|
|
|
checkNewPassword: [null, [Validators.required, this.checkPwd]], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.routeName = this.storage.get(ROUTENAME) == null ? 'index' : this.storage.get(ROUTENAME); |
|
|
|
this.routeName = this.storage.get(ROUTENAME) == null ? 'index' : this.storage.get(ROUTENAME); |
|
|
|
this.userInfo = this.storage.getList(ADMIN_INFO_OBJECT); |
|
|
|
this.userInfo = this.storage.getList(ADMIN_INFO_OBJECT); |
|
|
|
this.commonsService.mappingSysNameOl('RECHARGE', data => { |
|
|
|
this.commonsService.mappingSysNameOl('RECHARGE', data => { |
|
|
@ -79,4 +96,77 @@ export class NavigationComponent implements OnInit { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 打开抽屉
|
|
|
|
|
|
|
|
openUpdatePwd(): void { |
|
|
|
|
|
|
|
this.visibleUpdatePwd = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭抽屉
|
|
|
|
|
|
|
|
closeUser(): void { |
|
|
|
|
|
|
|
this.visibleUpdatePwd = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提交表单
|
|
|
|
|
|
|
|
submitForm(value): void { |
|
|
|
|
|
|
|
// 表单验证
|
|
|
|
|
|
|
|
// tslint:disable-next-line:forin
|
|
|
|
|
|
|
|
for (const i in this.validateForm.controls) { |
|
|
|
|
|
|
|
this.validateForm.controls[i].markAsDirty(); |
|
|
|
|
|
|
|
this.validateForm.controls[i].updateValueAndValidity(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (this.validateForm.status == null || this.validateForm.status !== 'VALID') { |
|
|
|
|
|
|
|
this.modal.info({ |
|
|
|
|
|
|
|
nzTitle: '提示', |
|
|
|
|
|
|
|
nzContent: '请正确填写必填信息', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const timeNum = new Date().getTime(); |
|
|
|
|
|
|
|
const signStr = 'userId=' + this.storage.get(ADMIN_INFO_OBJECT)['secUser'].id + '&newPassword=' + value.newPassword + '&nonceStr=' + timeNum; |
|
|
|
|
|
|
|
// 定义请求数据
|
|
|
|
|
|
|
|
const params = { |
|
|
|
|
|
|
|
userId: this.storage.get(ADMIN_INFO_OBJECT)['secUser'].id, |
|
|
|
|
|
|
|
oldPassword: value.oldPassword, |
|
|
|
|
|
|
|
newPassword: value.newPassword, |
|
|
|
|
|
|
|
nonceStr: timeNum, |
|
|
|
|
|
|
|
sign: String(Md5.hashStr(signStr)).toLocaleUpperCase(), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
this.http.post(environment.baseUrl + '/secUser/sendUserPass', params).subscribe(data => { |
|
|
|
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
|
|
|
this.modal.success({ |
|
|
|
|
|
|
|
nzTitle: '提示', |
|
|
|
|
|
|
|
nzContent: '密码修改成功', |
|
|
|
|
|
|
|
nzOkText: '重新登录', |
|
|
|
|
|
|
|
nzOkType: 'primary', |
|
|
|
|
|
|
|
nzOnOk: () => this.loginOut() |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.modal.warning({ |
|
|
|
|
|
|
|
nzTitle: '提示', |
|
|
|
|
|
|
|
nzContent: data['return_msg'], |
|
|
|
|
|
|
|
nzOkText: '取消', |
|
|
|
|
|
|
|
nzOkType: 'primary', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
}, 1000); |
|
|
|
|
|
|
|
}, error => { |
|
|
|
|
|
|
|
this.message.create('error', `未知错误!`); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 新密码校验两次密码是否一致 |
|
|
|
|
|
|
|
* @param control |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
checkPwd = (control: FormControl): { [s: string]: boolean } => { |
|
|
|
|
|
|
|
if (!control.value) { |
|
|
|
|
|
|
|
return { required: true }; |
|
|
|
|
|
|
|
} else if (control.value !== this.validateForm.controls.newPassword.value) { |
|
|
|
|
|
|
|
return { confirm: true, error: true }; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return {}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|