Browse Source

[新增]默认密码进入后提示修改密码

zhuzhou
邵佳豪 4 years ago
parent
commit
06c5736947
  1. 3
      src/app/interface.ts
  2. 48
      src/app/pages/login/changePassword.html
  3. 15
      src/app/pages/login/changePassword.scss
  4. 65
      src/app/pages/login/login.component.ts
  5. 8
      src/app/pages/pages.module.ts
  6. 20
      src/app/ui/changepassword/changepassword.component.html
  7. 11
      src/app/ui/collection-tools-plan/collection-tools.component.ts
  8. 3
      src/app/ui/ui.module.ts

3
src/app/interface.ts

@ -11,7 +11,8 @@ export interface Data {
refreshToken:string,
expires: number,
realName:string,
level:any
level:any,
isDefaultPassword:string
}
export interface windows {

48
src/app/pages/login/changePassword.html

@ -0,0 +1,48 @@
<div mat-dialog-title>
修改密码
</div>
<div class="passwordCard" mat-dialog-content>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<!-- <span class="cardLeft">原密码</span>
<mat-form-field>
<input matInput id="password" name="password"
required type="password"
ngModel #password="ngModel" placeholder="请输入原密码">
</mat-form-field> -->
<span class="cardLeft">新密码</span>
<mat-form-field>
<input matInput id="newPassword" name="newPassword" type="password"
required pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.+[\!\@\#\$\%\^\&\*\(\)\-\=\\\`\_\+\|\~\[\]\{\}\;\'\:\,\.\/\<\>\?])[A-Za-z0-9\!\@\#\$\%\^\&\*\(\)\-\=\\\`\_\+\|\~\[\]\{\}\;\'\:\,\.\/\<\>\?]{8,32}$"
ngModel #newPassword="ngModel" placeholder="请输入新密码">
</mat-form-field>
<div *ngIf="newPassword.invalid && (newPassword.dirty || newPassword.touched)">
<div class="group-error-content">密码格式为8-20位,大小写字母+数字+特殊字符</div>
</div>
<span class="cardLeft">确认新密码</span>
<mat-form-field>
<input matInput id="newsPassword" name="newsPassword" type="password"
required
ngModel #newsPassword="ngModel" placeholder="请确认新密码"
[appConfirmpsw] = "newPassword.value">
</mat-form-field>
<div *ngIf="newsPassword.touched&&newsPassword.invalid">
<div class="group-error-content">密码输入不一致!</div>
</div>
<div *ngIf="errmsg" class="group-error-content">
{{errmsg}}
</div>
<div mat-dialog-actions class="btnbox">
<button mat-raised-button color="primary" type="submit"
[disabled]="!form.form.valid">
确定
</button>
<button mat-raised-button color="primary" mat-dialog-close>取消</button>
</div>
</form>
</div>

15
src/app/pages/login/changePassword.scss

@ -0,0 +1,15 @@
.passwordCard {
width: 300px;
height: 100%;
}
.mat-form-field {
display: block;
width: 300px;
}
.group-error-content {
font-size: 12px;
color: red;
}
.mat-dialog-content {
overflow: visible
}

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

@ -3,7 +3,8 @@ import { HttpClient } from '@angular/common/http'
import { Data } from '../../interface'
import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatSnackBar,MatSnackBarConfig } from '@angular/material/snack-bar';
import { MatDialog,MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'app-login',
@ -12,7 +13,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
})
export class LoginComponent implements OnInit {
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar) { }
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar, public dialog: MatDialog) { }
ngOnInit() {
this.automaticLogin()
@ -27,19 +28,25 @@ export class LoginComponent implements OnInit {
sessionStorage.setItem("level",data.level);
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
sessionStorage.setItem("isDefaultPassword",data.isDefaultPassword);//是否需要修改默认密码
this.http.get('/api/Account/NavMenus').subscribe((data:any)=>{
let isHave = data.find(item=>{ return item.url == "/statisticanalysis/home"})
let isHaveGis = data.find(item=>{ return item.url == "/gis"})
if (isHave) {
this.router.navigate([`/statisticanalysis/home`])
this.dialogChangePassword()
return
} else if(isHaveGis){
this.router.navigate([`/gis`])
this.dialogChangePassword()
return
} else if(data.length != 0){
data.forEach(item => {
if(item.url){
this.router.navigate([`/keyUnit`])
this.dialogChangePassword()
return
data.forEach(item => {
if(item.url){
}
});
}else{
@ -60,6 +67,17 @@ export class LoginComponent implements OnInit {
)
}
dialogChangePassword(){
if(sessionStorage.getItem('isDefaultPassword') == 'true'){
let dialogRef = this.dialog.open(ChangepasswordComponent2,
{width:'348px'});
dialogRef.afterClosed().subscribe((data)=>{
sessionStorage.setItem('isDefaultPassword','false')
});
}
}
//7天免登录自动登录
automaticLogin () {
let isNoLogin = localStorage.getItem("isnologin")
@ -89,4 +107,41 @@ export class LoginComponent implements OnInit {
}
@Component({
selector: 'app-changepassword',
templateUrl: './changePassword.html',
styleUrls: ['./changepassword.scss']
})
export class ChangepasswordComponent2 implements OnInit {
constructor(private http:HttpClient,public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<ChangepasswordComponent2>) { }
ngOnInit() {
}
errmsg :string = ''
onSubmit(e){
this.http.put(
'/api/Account/Password',
{
newPassword: e.newPassword,
password: 'SHya119!@'
}
).subscribe(data=> {
this.dialogRef.close(data);
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('密码修改成功','确定',config);
},(err) =>
{this.errmsg = err}
)
}
}

8
src/app/pages/pages.module.ts

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { PagesComponent } from './pages.component';
import { LoginComponent } from './login/login.component';
import { ChangepasswordComponent2, LoginComponent } from './login/login.component';
import { RegisterComponent } from './register/register.component';
import { PagesRoutingModule } from './pages-routing.module'
@ -52,8 +52,9 @@ import { RouterModule } from '@angular/router';
import { LockscreenComponent } from './lockscreen/lockscreen.component';
import { HomeComponent } from './home/home.component';
import { HomedetailComponent } from './homedetail/homedetail.component';
import { UiModule } from '../ui/ui.module';
@NgModule({
declarations: [PagesComponent, LoginComponent, RegisterComponent, LockscreenComponent, HomeComponent, HomedetailComponent],
declarations: [PagesComponent, LoginComponent, RegisterComponent, LockscreenComponent, HomeComponent, HomedetailComponent,ChangepasswordComponent2],
imports: [
PagesRoutingModule,
@ -105,8 +106,9 @@ import { HomedetailComponent } from './homedetail/homedetail.component';
FormsModule,
ReactiveFormsModule,
RouterModule
RouterModule,
// PagesRoutingModule,
UiModule
]
})
export class PagesModule { }

20
src/app/ui/changepassword/changepassword.component.html

@ -7,27 +7,24 @@
<span class="cardLeft">原密码</span>
<mat-form-field>
<input matInput id="password" name="password"
required type="password"
ngModel #password="ngModel" placeholder="请输入原密码">
<input matInput id="password" name="password" required type="password" ngModel #password="ngModel"
placeholder="请输入原密码">
</mat-form-field>
<span class="cardLeft">新密码</span>
<mat-form-field>
<input matInput id="newPassword" name="newPassword" type="password"
required pattern="^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9]{8,20}$"
<input matInput id="newPassword" name="newPassword" type="password" required
pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.+[\!\@\#\$\%\^\&\*\(\)\-\=\\\`\_\+\|\~\[\]\{\}\;\'\:\,\.\/\<\>\?])[A-Za-z0-9\!\@\#\$\%\^\&\*\(\)\-\=\\\`\_\+\|\~\[\]\{\}\;\'\:\,\.\/\<\>\?]{8,32}$"
ngModel #newPassword="ngModel" placeholder="请输入新密码">
</mat-form-field>
<div *ngIf="newPassword.invalid && (newPassword.dirty || newPassword.touched)">
<div class="group-error-content">密码格式8-20位,字母+数字</div>
<div class="group-error-content">密码格式8-20位,大小写字母+数字+特殊字符</div>
</div>
<span class="cardLeft">确认新密码</span>
<mat-form-field>
<input matInput id="newsPassword" name="newsPassword" type="password"
required
ngModel #newsPassword="ngModel" placeholder="请确认新密码"
[appConfirmpsw] = "newPassword.value">
<input matInput id="newsPassword" name="newsPassword" type="password" required ngModel
#newsPassword="ngModel" placeholder="请确认新密码" [appConfirmpsw]="newPassword.value">
</mat-form-field>
<div *ngIf="newsPassword.touched&&newsPassword.invalid">
<div class="group-error-content">密码输入不一致!</div>
@ -37,8 +34,7 @@
</div>
<div mat-dialog-actions class="btnbox">
<button mat-raised-button color="primary" type="submit"
[disabled]="!form.form.valid">
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">
确定
</button>
<button mat-raised-button color="primary" mat-dialog-close>取消</button>

11
src/app/ui/collection-tools-plan/collection-tools.component.ts

@ -86,7 +86,7 @@ export class CollectionToolsPlanComponent implements OnInit {
gallery//viewerJs实例
//设置属性框
setAssetsProperty(obj) {
console.log(obj)
console.log('传进来的属性信息',obj)
//初始化viewerJs实例
setTimeout(() => {
obj.PropertyInfos.forEach(item => {
@ -2017,7 +2017,8 @@ export class CollectionToolsPlanComponent implements OnInit {
this.clickId = e.target.id
for (let index = 0; index < this.planData.length; index++) {
const item = this.planData[index];
if (item.id == e.target.id) {
if (item.Id == e.target.id) {
this.setAssetsProperty(item)
return
}
@ -2028,7 +2029,7 @@ export class CollectionToolsPlanComponent implements OnInit {
this.clickId = e.target.id
for (let index = 0; index < this.planData.length; index++) {
const item = this.planData[index];
if (item.id == e.target.id) {
if (item.Id == e.target.id) {
//修改最终坐标数据
item.point = { x: e.lnglat.lng, y: e.lnglat.lat }
return
@ -2040,6 +2041,10 @@ export class CollectionToolsPlanComponent implements OnInit {
let itemData = JSON.parse(JSON.stringify(this.selectImage))
itemData.id = id
itemData.point = { x: e.lnglat.lng, y: e.lnglat.lat }
console.log(987,this.canvasData.deserialize(JSON.stringify(itemData)))
// console.log('originalcompanyBuildingData',this.canvasData.originalcompanyBuildingData)
// console.log('originaleveryStoreyData',this.canvasData.originaleveryStoreyData)
itemData = this.canvasData.deserialize(JSON.stringify(itemData))//反序列化为大写
this.planData.push(itemData)
//将marker点添加
this.planDataMarkers.push(startMarker)

3
src/app/ui/ui.module.ts

@ -159,7 +159,8 @@ import { addattinf } from './plan-template/plan-template.component'
exports: [
CollectionToolsComponent,
CollectionToolsBuildingComponent,
CollectionToolsPlanComponent
CollectionToolsPlanComponent,
ConfirmpswDirective
]
})
export class UiModule { }

Loading…
Cancel
Save