Browse Source

[新增]忘记密码框

beijing
邵佳豪 2 years ago
parent
commit
a816b7144d
  1. 59
      src/app/pages/login/forget/forget.component.html
  2. 26
      src/app/pages/login/forget/forget.component.scss
  3. 98
      src/app/pages/login/forget/forget.component.ts
  4. 14
      src/app/pages/login/login.component.ts
  5. 3
      src/app/pages/pages.module.ts
  6. 1
      src/app/system-management/push/push.component.scss
  7. 18
      src/app/system-management/push/push.component.ts

59
src/app/pages/login/forget/forget.component.html

@ -0,0 +1,59 @@
<div class="box">
<div class="step1" *ngIf="currentStep == 1">
<form nz-form [formGroup]="validateForm" (ngSubmit)="step1()">
<nz-form-item>
<nz-form-label nzRequired nzFor="">请输入要修改密码的账号</nz-form-label>
<nz-form-control>
<input autocomplete="off" nz-input formControlName="account" id="account" />
</nz-form-control>
</nz-form-item>
<div class="btn">
<button type="submit" nz-button nzType="primary">下一步</button>
</div>
</form>
</div>
<div class="step2" *ngIf="currentStep == 2">
<div class="phonebox">
该账号绑定的手机号为:13864340193 <button type="button" nz-button nzType="primary">点击获取验证码</button>
</div>
<form nz-form [formGroup]="validateForm2" (ngSubmit)="step2()">
<nz-form-item>
<nz-form-label nzRequired nzFor="">请输入验证码</nz-form-label>
<nz-form-control>
<input autocomplete="off" nz-input formControlName="code" id="code" />
</nz-form-control>
</nz-form-item>
<div class="btn">
<button type="submit" nz-button nzType="primary">下一步</button>
</div>
</form>
</div>
<div class="step3" *ngIf="currentStep == 3">
<form nz-form [formGroup]="validateForm3" (ngSubmit)="step3()">
<nz-form-item>
<!-- <nz-form-label nzRequired nzFor="">请输入原密码</nz-form-label> -->
<nz-form-control>
<input name="oldpassword" nz-input type="password" formControlName="oldpassword"
placeholder="请输入原密码" autocomplete="off" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<!-- <nz-form-label nzRequired nzFor="">请输入新密码</nz-form-label> -->
<nz-form-control>
<input name="newpassword" nz-input type="password" formControlName="newpassword"
placeholder="请输入新密码" autocomplete="off" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<!-- <nz-form-label nzRequired nzFor="">确认新密码</nz-form-label> -->
<nz-form-control>
<input name="affirmpassword" nz-input type="password" formControlName="affirmpassword"
placeholder="确认新密码" autocomplete="new-password" />
</nz-form-control>
</nz-form-item>
<div class="btn">
<button type="submit" nz-button nzType="primary">确定</button>
</div>
</form>
</div>
</div>

26
src/app/pages/login/forget/forget.component.scss

@ -0,0 +1,26 @@
.step1,
.step2 {
nz-form-item {
display: flex;
flex-direction: column;
nz-form-label {
text-align: left;
}
}
.btn {
width: 100%;
text-align: center;
margin-top: 50px;
}
}
.step3 {
.btn {
width: 100%;
text-align: center;
margin-top: 10px;
}
}

98
src/app/pages/login/forget/forget.component.ts

@ -0,0 +1,98 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators, AbstractControl } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-forget',
templateUrl: './forget.component.html',
styleUrls: ['./forget.component.scss']
})
export class ForgetComponent implements OnInit {
validateForm!: FormGroup;
validateForm2!: FormGroup;
validateForm3!: FormGroup;
constructor(private fb: FormBuilder, private message: NzMessageService, private http: HttpClient) { }
ngOnInit(): void {
this.validateForm = this.fb.group({
account: [null, [Validators.required]]
});
this.validateForm2 = this.fb.group({
code: [null, [Validators.required]]
});
const { password } = MyValidators;
this.validateForm3 = this.fb.group({
oldpassword: [null, [Validators.required]],
newpassword: [null, [Validators.required, password]],
affirmpassword: [null, [Validators.required, password]]
});
}
currentStep = 1
step1() {
console.log(this.validateForm)
if (this.validateForm.invalid) {
this.message.create('warning', '请填写完整');
} else {
this.currentStep = 2
}
}
step2() {
if (this.validateForm2.invalid) {
this.message.create('warning', '请填写完整');
} else {
this.currentStep = 3
}
}
step3() {
if (this.validateForm3.valid) {
if (this.validateForm3.value.newpassword != this.validateForm3.value.affirmpassword) {
this.message.create('warning', '两次密码输入不一致!');
return false
} else {
// let body = {
// currentPassword: this.validateForm3.value.oldpassword,
// newPassword: this.validateForm3.value.newpassword
// }
// this.http.post('/api/services/app/User/ChangePassword', body).subscribe(data => {
// this.message.create('success', '修改成功!');
// return true
// }, err => {
// this.message.create('warning', err.error.error.message);
// return false
// })
}
} else {
this.message.create('warning', '请填写完整!');
return false
}
}
}
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);
}

14
src/app/pages/login/login.component.ts

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewContainerRef } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Router, ActivatedRoute } from '@angular/router'
import { CacheTokenService } from '../../service/cache-token.service'//引入服务
@ -8,6 +8,8 @@ import { Base64 } from 'js-base64';
import { NzNotificationService } from 'ng-zorro-antd/notification';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { SelectedMenu } from 'src/app/service/selectedMenu.service';
import { NzModalService } from 'ng-zorro-antd/modal';
import { ForgetComponent } from './forget/forget.component';
// import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
declare var abp: any
@ -20,7 +22,7 @@ export class LoginComponent implements OnInit {
validateForm!: FormGroup;
passwordValidateForm!: FormGroup;
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, private fb: FormBuilder, private message: NzMessageService, private notificationService: NzNotificationService, private selectedMenu: SelectedMenu) {
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, private fb: FormBuilder, private message: NzMessageService, private notificationService: NzNotificationService, private selectedMenu: SelectedMenu, private modal: NzModalService, private viewContainerRef: ViewContainerRef) {
const { password } = MyValidators;
this.validateForm = this.fb.group({
userName: [null, [Validators.required]],
@ -235,6 +237,14 @@ export class LoginComponent implements OnInit {
}
forget() {
this.message.create('warning', `请联系管理员`);
// this.modal.create({
// nzTitle: '忘记密码',
// nzContent: ForgetComponent,
// nzViewContainerRef: this.viewContainerRef,
// nzWidth: 288,
// nzComponentParams: {},
// nzFooter: null
// });
}
}

3
src/app/pages/pages.module.ts

@ -89,10 +89,11 @@ import { RecordsNavComponent } from './records/records-nav/records-nav.component
import { UserDetailsComponent } from './audit/audit-ing/user-details/user-details.component';
import { AppealDetailsComponent } from './audit/audit-ing/appeal-details/appeal-details.component';
import { SystemModelComponent } from './home/system-model/system-model.component';
import { ForgetComponent } from './login/forget/forget.component';
@NgModule({
declarations: [LoginComponent, RegisterComponent, HomeComponent, PlanComponent, TodayWarningComponent, CriminalRecordsComponent,
TodayWarningAdminComponent, CriminalRecordsAdminComponent, LeftDomainComponent, EquipmentInfoComponent, OilStationInfoComponent,
AddequipmentComponent, EditequipmentComponent, PlanAdminComponent, GetOutOfLineDetailsComponent, DispositionComponent, OilUnloadingProcessComponent, HomePageComponent, OilUnloadingProcessListComponent, ChangePasswordComponent, FacilitySortPipe, WarningStatisticsListComponent, DisposeequipmentComponent, NavBarComponent, InformComponent, UpdateCategoryComponent, FileCategoryComponent, HistoriesComponent, EditUpdateCategoryComponent, DetailsUpdateCategoryComponent, EditFileCategoryComponent, DetailsFileCategoryComponent, PdfWordLookComponent, OilStationListComponent, UpdateLicenseListComponent, FileLicenseListComponent, AuditNavComponent, AuditIngComponent, AuditRecordComponent, AuditInformTimeComponent, AuditDisposeComponent, EditInformTimeComponent, AuditDetailsInformTimeComponent, auditStatusPipe, GasBaseInfoComponent, notificationContent, licenseViolationType, handleState, AnnualInspectionComponent, EditAnnualInspectionComponent, RecordsNavComponent, UserDetailsComponent, AppealDetailsComponent, fileName, SystemModelComponent],
AddequipmentComponent, EditequipmentComponent, PlanAdminComponent, GetOutOfLineDetailsComponent, DispositionComponent, OilUnloadingProcessComponent, HomePageComponent, OilUnloadingProcessListComponent, ChangePasswordComponent, FacilitySortPipe, WarningStatisticsListComponent, DisposeequipmentComponent, NavBarComponent, InformComponent, UpdateCategoryComponent, FileCategoryComponent, HistoriesComponent, EditUpdateCategoryComponent, DetailsUpdateCategoryComponent, EditFileCategoryComponent, DetailsFileCategoryComponent, PdfWordLookComponent, OilStationListComponent, UpdateLicenseListComponent, FileLicenseListComponent, AuditNavComponent, AuditIngComponent, AuditRecordComponent, AuditInformTimeComponent, AuditDisposeComponent, EditInformTimeComponent, AuditDetailsInformTimeComponent, auditStatusPipe, GasBaseInfoComponent, notificationContent, licenseViolationType, handleState, AnnualInspectionComponent, EditAnnualInspectionComponent, RecordsNavComponent, UserDetailsComponent, AppealDetailsComponent, fileName, SystemModelComponent, ForgetComponent],
imports: [

1
src/app/system-management/push/push.component.scss

@ -66,6 +66,7 @@
color: #000D21;
font-family: synormal;
font-weight: 400;
text-align: left;
}
tr:nth-child(odd) {
background-color:rgba(145, 204, 255, 0.16);

18
src/app/system-management/push/push.component.ts

@ -144,7 +144,7 @@ export class PushComponent implements OnInit {
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
await new Promise((resolve, reject) => {
console.log('表单信息', instance.validateForm)
let body = {
id: item.id,
@ -152,11 +152,17 @@ export class PushComponent implements OnInit {
// handleRoleIds: instance.validateForm.value.handle,
smsPushRoleIds: instance.validateForm.value.note
}
this.http.put('/api/services/app/Violation/UpdateRoles', body).subscribe(data => {
resolve(data)
this.message.create('success', '修改成功!');
this.getViolation()
return true
this.http.put('/api/services/app/Violation/UpdateRoles', body).subscribe({
next: data => {
resolve(data)
this.message.create('success', '修改成功!');
this.getViolation()
return true
},
error: err => {
this.message.create('success', '修改失败!');
reject(err)
}
})
})
} else {

Loading…
Cancel
Save