Browse Source

[完善]修改默认密码弹出逻辑+发送短信按钮bug

test-assets
邵佳豪 11 months ago
parent
commit
cfb5c9c13a
  1. 10
      angular.json
  2. 16787
      package-lock.json
  3. 2
      package.json
  4. 40
      src/app/pages/home/home.component.html
  5. 58
      src/app/pages/home/home.component.ts
  6. 205
      src/app/pages/login/forget/forget.component.ts
  7. 43
      src/app/pages/login/login.component.html
  8. 453
      src/app/pages/login/login.component.ts
  9. 63
      src/styles.scss

10
angular.json

@ -130,9 +130,7 @@
"output": "/assets/abp"
}
],
"styles": [
"src/styles.scss"
],
"styles": ["src/styles.scss"],
"scripts": [
"node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
"node_modules/abp-web-resources/Abp/Framework/scripts/abp.js"
@ -147,9 +145,7 @@
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
},
"e2e": {
@ -171,4 +167,4 @@
"cli": {
"analytics": false
}
}
}

16787
package-lock.json generated

File diff suppressed because it is too large Load Diff

2
package.json

@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json --open --port 1119 --host 192.168.1.82",
"start": "ng serve --proxy-config proxy.config.json --open --port 1119",
"build": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --configuration production",
"test": "ng test",
"lint": "ng lint",

40
src/app/pages/home/home.component.html

@ -119,43 +119,3 @@
</ng-template>
<!-- 修改密码 -->
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="modalTitle" [nzContent]="modalContent" [nzFooter]="modalFooter"
[nzWidth]="350">
<ng-template #modalTitle>
修改初始密码
</ng-template>
<ng-template #modalContent>
<form nz-form [formGroup]="passwordValidateForm">
<nz-form-item>
<nz-form-control nzErrorTip="">
<nz-input-group>
<input name="oldpassword" type="password" nz-input formControlName="oldpassword" placeholder="请输入原密码"
autocomplete="off" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-input-group>
<input name="newpassword" nz-input type="password" formControlName="newpassword" placeholder="请输入新密码"
autocomplete="off" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-input-group>
<input name="affirmpassword" nz-input type="password" formControlName="affirmpassword" placeholder="确认新密码"
autocomplete="new-password" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
</form>
</ng-template>
<ng-template #modalFooter>
<button nz-button nzType="primary" (click)="handleOk()" [nzLoading]="isConfirmLoading">确定</button>
</ng-template>
</nz-modal>

58
src/app/pages/home/home.component.ts

@ -205,13 +205,13 @@ export class HomeComponent implements OnInit {
this.userName = JSON.parse(sessionStorage.getItem("userdata")).userName;
}
if (
(sessionStorage.getItem("isDefaultPassword") == "true" ||
sessionStorage.getItem("isPasswordExpired") == "true") &&
JSON.parse(sessionStorage.getItem("userdata")).userName != "admin"
) {
this.changePasswordPopup();
}
// if (
// (sessionStorage.getItem("isDefaultPassword") == "true" ||
// sessionStorage.getItem("isPasswordExpired") == "true") &&
// JSON.parse(sessionStorage.getItem("userdata")).userName != "admin"
// ) {
// this.changePasswordPopup();
// }
this.getWarningSwitch();
}
@ -285,49 +285,7 @@ export class HomeComponent implements OnInit {
SignalRAspNetCoreHelper.initSignalR();
abp.event.on("abp.notifications.received", this.reloadPage);
}
//初次登陆修改密码弹窗
isVisible = false;
isConfirmLoading = false;
changePasswordPopup() {
this.isVisible = true;
}
handleOk(): void {
if (this.passwordValidateForm.invalid) {
this.message.create("warning", `输入格式不正确`);
} else {
if (
this.passwordValidateForm.value.newpassword !=
this.passwordValidateForm.value.affirmpassword
) {
this.message.create("warning", "两次密码输入不一致!");
} else if (
this.passwordValidateForm.value.newpassword ==
this.passwordValidateForm.value.oldpassword
) {
this.message.create("warning", "旧密码和新密码不能相同!");
} else {
this.isConfirmLoading = true;
let body = {
currentPassword: this.passwordValidateForm.value.oldpassword,
newPassword: this.passwordValidateForm.value.newpassword,
};
this.http.post("/api/services/app/User/ChangePassword", body).subscribe(
(data) => {
this.message.create("success", "修改成功!");
this.isConfirmLoading = false;
this.isVisible = false;
//清除sessionStorage
sessionStorage.removeItem("isDefaultPassword");
sessionStorage.removeItem("isPasswordExpired");
},
(err) => {
this.message.create("warning", err.error.error.message);
this.isConfirmLoading = false;
}
);
}
}
}
reloadPage = (userNotification) => {
console.log("abp.notifications.received收到通知", userNotification);

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

@ -1,129 +1,163 @@
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';
import { NzModalRef } from 'ng-zorro-antd/modal';
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";
import { NzModalRef } from "ng-zorro-antd/modal";
@Component({
selector: 'app-forget',
templateUrl: './forget.component.html',
styleUrls: ['./forget.component.scss']
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, private modal: NzModalRef, private patternService: PatternService) { }
isProd: boolean
constructor(
private fb: FormBuilder,
private message: NzMessageService,
private http: HttpClient,
private modal: NzModalRef,
private patternService: PatternService
) {}
isProd: boolean;
ngOnInit(): void {
this.isProd = this.patternService.isProd
this.isProd = this.patternService.isProd;
this.validateForm = this.fb.group({
account: [null, [Validators.required]]
account: [null, [Validators.required]],
});
this.validateForm2 = this.fb.group({
code: [null, [Validators.required]]
code: [null, [Validators.required]],
});
const { password } = MyValidators;
this.validateForm3 = this.fb.group({
newpassword: [null, [Validators.required, password]],
affirmpassword: [null, [Validators.required, password]]
affirmpassword: [null, [Validators.required, password]],
});
}
currentStep = 1
phoneNum: string
currentStep = 1;
phoneNum: string;
step1() {
console.log(this.validateForm)
console.log(this.validateForm);
if (this.validateForm.invalid) {
this.message.create('warning', '请填写完整');
this.message.create("warning", "请填写完整");
} else {
this.http.get('/api/services/app/User/GetPhoneNumber', {
params: {
userName: this.validateForm.value.account
}
}).subscribe({
next: (data: any) => {
this.phoneNum = data.result
this.currentStep = 2
}
})
this.http
.get("/api/services/app/User/GetPhoneNumber", {
params: {
userName: this.validateForm.value.account,
},
})
.subscribe({
next: (data: any) => {
this.phoneNum = data.result;
this.currentStep = 2;
},
});
}
}
//发送验证码
codeCountDown = 0
codeCountDown = 0;
code() {
this.codeCountDown = 30;
let params = {
userName: this.validateForm.value.account,
}
this.http.post('/api/services/app/User/SendVerificationCode', null, { params: params }).subscribe({
next: (data: any) => {
this.message.create('success', '已发送');
//按钮倒计时
this.codeCountDown = 30
let codesetInterval = setInterval(() => {
this.codeCountDown = this.codeCountDown - 1
if (this.codeCountDown == 0) {
clearInterval(codesetInterval)
}
}, 1000);
}
})
};
this.http
.post("/api/services/app/User/SendVerificationCode", null, {
params: params,
})
.subscribe({
next: (data: any) => {
this.message.create("success", "已发送");
//按钮倒计时
let codesetInterval = setInterval(() => {
this.codeCountDown = this.codeCountDown - 1;
if (this.codeCountDown == 0) {
clearInterval(codesetInterval);
}
}, 1000);
},
});
}
step2() {
if (this.validateForm2.invalid) {
this.message.create('warning', '请填写完整');
this.message.create("warning", "请填写完整");
} else {
console.log(this.validateForm.value.account)
console.log(this.validateForm.value.account);
let params = {
userName: this.validateForm.value.account,
code: this.validateForm2.value.code
}
this.http.get('/api/services/app/User/VerifyVerificationCode', { params: params }).subscribe({
next: (data: any) => {
this.currentStep = 3
}
})
code: this.validateForm2.value.code,
};
this.http
.get("/api/services/app/User/VerifyVerificationCode", {
params: params,
})
.subscribe({
next: (data: any) => {
this.currentStep = 3;
},
});
}
}
step3() {
if (this.validateForm3.valid) {
let word = JSON.parse(JSON.stringify(this.validateForm3.value.newpassword)).toLowerCase()
if (this.validateForm3.value.newpassword != this.validateForm3.value.affirmpassword) {
this.message.create('warning', '两次密码输入不一致!');
return false
} if (word.indexOf('sino') != -1 || word.indexOf('zhonghua') != -1) {
this.message.create('warning', '口令禁止包含 sinochem、sino、zhonghua (含大小写变体) 等中国中化相关字符');
return false
let word = JSON.parse(
JSON.stringify(this.validateForm3.value.newpassword)
).toLowerCase();
if (
this.validateForm3.value.newpassword !=
this.validateForm3.value.affirmpassword
) {
this.message.create("warning", "两次密码输入不一致!");
return false;
}
if (word.indexOf("sino") != -1 || word.indexOf("zhonghua") != -1) {
this.message.create(
"warning",
"口令禁止包含 sinochem、sino、zhonghua (含大小写变体) 等中国中化相关字符"
);
return false;
} else {
let body = {
userName: this.validateForm.value.account,
code: this.validateForm2.value.code,
newPassword: this.validateForm3.value.newpassword,
}
this.http.post('/api/services/app/User/ChangePasswordBySms', body).subscribe(data => {
this.message.create('success', '修改成功!');
this.modal.close()
return true
}, err => {
return false
})
};
this.http
.post("/api/services/app/User/ChangePasswordBySms", body)
.subscribe(
(data) => {
this.message.create("success", "修改成功!");
this.modal.close();
return true;
},
(err) => {
return false;
}
);
}
} else {
this.message.create('warning', '请填写完整!');
return false
this.message.create("warning", "请填写完整!");
return false;
}
}
}
import { PatternService } from 'src/app/service/pattern.service';
import { PatternService } from "src/app/service/pattern.service";
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>;
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 {
@ -133,13 +167,26 @@ export class MyValidators extends Validators {
return null;
}
return isPassword(value) ? null : { mobile: { 'zh-cn': PatternService.isProd ? `长度至少 12 位,必须包含大写字母、小写字母、数字、符号四种中的三种,且口令禁止包含 sinochem、sino、zhonghua (含大小写变体) 等中国中化相关字符` : '长度至少 12 位,必须包含大写字母、小写字母、数字、符号四种中的三种', en: `Password phone number is not valid` } };
return isPassword(value)
? null
: {
mobile: {
"zh-cn": PatternService.isProd
? `长度至少 12 位,必须包含大写字母、小写字母、数字、符号四种中的三种,且口令禁止包含 sinochem、sino、zhonghua (含大小写变体) 等中国中化相关字符`
: "长度至少 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_!@#$%^&*`~()-+=]+$)(?!.*[sS][iI][nN][oO].*)(?!.*[zZ][hH][oO][nN][gG][hH][uU][aA].*)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{12,99}$/.test(value);
return (
typeof value === "string" &&
/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)(?!.*[sS][iI][nN][oO].*)(?!.*[zZ][hH][oO][nN][gG][hH][uU][aA].*)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{12,99}$/.test(
value
)
);
}

43
src/app/pages/login/login.component.html

@ -46,4 +46,45 @@
<img *ngIf="isProd" src="../../../assets/images/logo2.png" alt="">
</div>
</div>
</div>
<!-- 修改密码 -->
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="modalTitle" [nzContent]="modalContent" [nzFooter]="modalFooter"
[nzWidth]="350">
<ng-template #modalTitle>
修改初始密码
</ng-template>
<ng-template #modalContent>
<form nz-form [formGroup]="passwordValidateForm">
<nz-form-item>
<nz-form-control nzErrorTip="">
<nz-input-group>
<input name="oldpassword" type="password" nz-input formControlName="oldpassword" placeholder="请输入原密码"
autocomplete="off" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-input-group>
<input name="newpassword" nz-input type="password" formControlName="newpassword" placeholder="请输入新密码"
autocomplete="off" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-input-group>
<input name="affirmpassword" nz-input type="password" formControlName="affirmpassword" placeholder="确认新密码"
autocomplete="new-password" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
</form>
</ng-template>
<ng-template #modalFooter>
<button nz-button nzType="primary" (click)="handleOk()" [nzLoading]="isConfirmLoading">确定</button>
</ng-template>
</nz-modal>

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

@ -1,29 +1,43 @@
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'//引入服务
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd/message';
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 { PatternService } from 'src/app/service/pattern.service';
// import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
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"; //引入服务
import {
AbstractControl,
FormBuilder,
FormGroup,
Validators,
} from "@angular/forms";
import { NzMessageService } from "ng-zorro-antd/message";
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 { PatternService } from "src/app/service/pattern.service";
declare var abp: any
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
selector: "app-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"],
})
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, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private patternService: PatternService) {
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,
private patternService: PatternService
) {
const { password } = MyValidators;
this.validateForm = this.fb.group({
userName: [null, [Validators.required]],
@ -34,224 +48,325 @@ export class LoginComponent implements OnInit {
this.passwordValidateForm = this.fb.group({
oldpassword: [null, [Validators.required]],
newpassword: [null, [Validators.required, password]],
affirmpassword: [null, [Validators.required, password]]
affirmpassword: [null, [Validators.required, password]],
});
}
isProd: boolean
isProd: boolean;
ngOnInit() {
this.isProd = this.patternService.isProd
this.isProd = this.patternService.isProd;
//如果本地储存了账号密码信息,那就回显在输入框
let account = localStorage.getItem('account')
let password = localStorage.getItem('password')
let account = localStorage.getItem("account");
let password = localStorage.getItem("password");
if (account && password) {
this.validateForm.patchValue({
userName: Base64.decode(localStorage.getItem('account')),
password: Base64.decode(localStorage.getItem('password'))
userName: Base64.decode(localStorage.getItem("account")),
password: Base64.decode(localStorage.getItem("password")),
});
this.remember = true //这一步是回显后让勾选框为选中状态
this.remember = true; //这一步是回显后让勾选框为选中状态
}
//自动登录
if (localStorage.getItem('isautologin') == 'true') {
this.submitForm()
this.autologin = true //这一步是回显后让勾选框为选中状态
if (localStorage.getItem("isautologin") == "true") {
this.submitForm();
this.autologin = true; //这一步是回显后让勾选框为选中状态
}
}
errmsg: string = ''; //错误信息
errmsg: string = ""; //错误信息
//跳转注册页面
toRegister() {
this.router.navigate(['/register'])
this.router.navigate(["/register"]);
}
//记住密码
rememberInfo() {
// 判断用户是否勾选记住密码,如果勾选,在本地储存中储存登录信息
if (this.remember) {
localStorage.setItem("account", Base64.encode(this.validateForm.value.userName))
localStorage.setItem("password", Base64.encode(this.validateForm.value.password))
localStorage.setItem(
"account",
Base64.encode(this.validateForm.value.userName)
);
localStorage.setItem(
"password",
Base64.encode(this.validateForm.value.password)
);
}
}
//自动登录
autoLogin() {
if (this.autologin) {
localStorage.setItem("isautologin", 'true')
localStorage.setItem("isautologin", "true");
}
}
remember: any//记住密码
autologin: any//自动登录
remember: any; //记住密码
autologin: any; //自动登录
isLoading = false;
messages
encryptedAccessToken
messages;
encryptedAccessToken;
menu1 = [
{ name: '首页', url: '/homepage' },
{ name: '数字油站', url: '/plan' },
{ name: '今日预警', url: '/todaywarning' },
{ name: '预警记录', url: '/records_nav' },
{ name: '证照管理', url: '/audit' },
]
{ name: "首页", url: "/homepage" },
{ name: "数字油站", url: "/plan" },
{ name: "今日预警", url: "/todaywarning" },
{ name: "预警记录", url: "/records_nav" },
{ name: "证照管理", url: "/audit" },
];
menu2 = [
{ name: '数字油站', url: '/plan/petrolStation' },
{ name: '今日预警', url: '/todaywarning/petrolStation' },
{ name: '预警记录', url: '/records_nav/petrolStation' },
{ name: '证照管理', url: '/license/petrolStation' },
]
init3D
{ name: "数字油站", url: "/plan/petrolStation" },
{ name: "今日预警", url: "/todaywarning/petrolStation" },
{ name: "预警记录", url: "/records_nav/petrolStation" },
{ name: "证照管理", url: "/license/petrolStation" },
];
init3D;
async getGasStationBaseInfo() {
await new Promise((resolve, reject) => {
let params = { organizationUnitId: (JSON.parse(sessionStorage.getItem('userdataOfgasstation'))).organization.id }
this.http.get('/api/services/app/GasStation/Get', { params: params }).subscribe((data: any) => {
resolve(data.result)
let params = {
organizationUnitId: JSON.parse(
sessionStorage.getItem("userdataOfgasstation")
).organization.id,
};
this.http
.get("/api/services/app/GasStation/Get", { params: params })
.subscribe((data: any) => {
resolve(data.result);
sessionStorage.setItem("3dSceneData", JSON.stringify(data.result))
this.init3D = data.result.hasBuildingInfo
})
})
sessionStorage.setItem("3dSceneData", JSON.stringify(data.result));
this.init3D = data.result.hasBuildingInfo;
});
});
}
submitForm(): void {
submitData;
submitForm(): void {
if (!this.remember) {
localStorage.removeItem("account")
localStorage.removeItem("password")
localStorage.removeItem("account");
localStorage.removeItem("password");
}
if (!this.autologin) {
localStorage.removeItem("isautologin")
localStorage.removeItem("isautologin");
}
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
if (!this.validateForm.valid) {
this.message.create('error', `请输入账号密码`);
return
this.message.create("error", `请输入账号密码`);
return;
}
this.isLoading = true;
this.http.post('/api/TokenAuth/Authenticate', {
userNameOrEmailAddress: this.validateForm.value.userName,
password: this.validateForm.value.password
}).subscribe(
(data: any) => {
sessionStorage.setItem("token", data.result.accessToken);
sessionStorage.setItem("encryptedAccessToken", data.result.encryptedAccessToken);
this.http.get('/api/services/app/Session/GetCurrentLoginInformations').subscribe(async (data: any) => {
console.log('GetCurrentLoginInformations', data.result)
if (data.result.user.menus.length == 0) {
this.message.create('error', `当前用户未分配菜单`);
this.isLoading = false
return
}
sessionStorage.setItem('userdata', JSON.stringify(data.result.user))
sessionStorage.setItem('userdataOfgasstation', JSON.stringify(data.result.user))
sessionStorage.setItem('isDefaultPassword', JSON.stringify(data.result.user.isDefaultPassword))
sessionStorage.setItem('isPasswordExpired', JSON.stringify(data.result.user.isPasswordExpired))
this.isLoading = false;
if (!data.result.user.organization) {
this.message.create('error', `当前用户没有组织机构信息`);
return
}
if (data.result.user.organization.isGasStation) {
await this.getGasStationBaseInfo()
if (data.result.user.menus[0].name == "数字油站" && data.result.user.menus.length == 1 && !this.init3D) {
this.message.create('error', `当前用户油站未开通3D且仅分配油站菜单`);
return
}
}
//记住密码
this.rememberInfo()
//自动登录
this.autoLogin()
this.http
.post("/api/TokenAuth/Authenticate", {
userNameOrEmailAddress: this.validateForm.value.userName,
password: this.validateForm.value.password,
})
.subscribe(
(data: any) => {
sessionStorage.setItem("token", data.result.accessToken);
sessionStorage.setItem(
"encryptedAccessToken",
data.result.encryptedAccessToken
);
this.http
.get("/api/services/app/Session/GetCurrentLoginInformations")
.subscribe(
async (data: any) => {
this.submitData = data;
console.log("GetCurrentLoginInformations", data.result);
if (data.result.user.menus.length == 0) {
this.message.create("error", `当前用户未分配菜单`);
this.isLoading = false;
return;
}
if (data.result.user.organization.isGasStation) {
sessionStorage.setItem("isGasStation", 'true');
let a = sessionStorage.getItem('userdataOfgasstation')
let menuList = this.returnLastMenus(a, this.menu2)
let isTrue = menuList.find((item) => {
return item.name == "今日预警"
});
if (isTrue) {
this.router.navigate(['/todaywarning/petrolStation'])
sessionStorage.setItem('selectedMenu', '今日预警')
} else if (data.result.user.menus[0].name == "数字油站" && !this.init3D) {
this.router.navigate([menuList[1].url])
sessionStorage.setItem('selectedMenu', menuList[1].name)
} else if (menuList.length == 0) {
return this.message.create('warning', `当前用户未分配菜单`);
} else {
this.router.navigate([menuList[0].url])
sessionStorage.setItem('selectedMenu', menuList[0].name)
}
} else {
sessionStorage.setItem("isGasStation", 'false');
let a = sessionStorage.getItem('userdata')
let menuList = this.returnLastMenus(a, this.menu1)
let isTrue = menuList.find((item) => {
return item.name == "首页"
});
if (menuList.length == 0) {
sessionStorage.setItem(
"userdata",
JSON.stringify(data.result.user)
);
sessionStorage.setItem(
"userdataOfgasstation",
JSON.stringify(data.result.user)
);
return this.message.create('warning', `当前用户未分配菜单`);
this.isLoading = false;
if (!data.result.user.organization) {
this.message.create("error", `当前用户没有组织机构信息`);
return;
}
if (data.result.user.organization.isGasStation) {
await this.getGasStationBaseInfo();
if (
data.result.user.menus[0].name == "数字油站" &&
data.result.user.menus.length == 1 &&
!this.init3D
) {
this.message.create(
"error",
`当前用户油站未开通3D且仅分配油站菜单`
);
return;
}
}
//记住密码
this.rememberInfo();
//自动登录
this.autoLogin();
if (
data.result.user.isDefaultPassword ||
data.result.user.isPasswordExpired
) {
this.isLoading = false;
this.changePasswordPopup();
return;
}
}
if (isTrue) {
this.router.navigate(['/homepage'])
sessionStorage.setItem('selectedMenu', '首页')
} else {
this.router.navigate([menuList[0].url])
sessionStorage.setItem('selectedMenu', menuList[0].name)
}
//
//跳转页面
this.toPage(data);
}
this.message.create('success', `登录成功`);
}, err => {
this.message.create("success", `登录成功`);
},
(err) => {
this.isLoading = false;
}
);
},
(err) => {
this.isLoading = false;
})
},
(err) => {
this.isLoading = false;
// this.message.create('error', err.error.error.details);
}
);
}
toPage(data) {
if (data.result.user.organization.isGasStation) {
sessionStorage.setItem("isGasStation", "true");
let a = sessionStorage.getItem("userdataOfgasstation");
let menuList = this.returnLastMenus(a, this.menu2);
let isTrue = menuList.find((item) => {
return item.name == "今日预警";
});
if (isTrue) {
this.router.navigate(["/todaywarning/petrolStation"]);
sessionStorage.setItem("selectedMenu", "今日预警");
} else if (data.result.user.menus[0].name == "数字油站" && !this.init3D) {
this.router.navigate([menuList[1].url]);
sessionStorage.setItem("selectedMenu", menuList[1].name);
} else if (menuList.length == 0) {
return this.message.create("warning", `当前用户未分配菜单`);
} else {
this.router.navigate([menuList[0].url]);
sessionStorage.setItem("selectedMenu", menuList[0].name);
}
)
} else {
sessionStorage.setItem("isGasStation", "false");
let a = sessionStorage.getItem("userdata");
let menuList = this.returnLastMenus(a, this.menu1);
let isTrue = menuList.find((item) => {
return item.name == "首页";
});
if (menuList.length == 0) {
return this.message.create("warning", `当前用户未分配菜单`);
}
if (isTrue) {
this.router.navigate(["/homepage"]);
sessionStorage.setItem("selectedMenu", "首页");
} else {
this.router.navigate([menuList[0].url]);
sessionStorage.setItem("selectedMenu", menuList[0].name);
}
//
}
}
returnLastMenus(data, originalMenus) {
let userMenu = JSON.parse(data).menus
let tap = []
let menuList = []
let userMenu = JSON.parse(data).menus;
let tap = [];
let menuList = [];
for (let index = 0; index < userMenu.length; index++) {
let a = userMenu[index].name
tap.push(a)
let a = userMenu[index].name;
tap.push(a);
}
for (let index = 0; index < originalMenus.length; index++) {
for (let k = 0; k < tap.length; k++) {
if (tap[k] == originalMenus[index].name) {
menuList.push(originalMenus[index])
menuList.push(originalMenus[index]);
}
}
}
return menuList
return menuList;
}
forget() {
// this.message.create('warning', `请联系管理员`);
this.modal.create({
nzTitle: '忘记密码',
nzTitle: "忘记密码",
nzContent: ForgetComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 288,
nzComponentParams: {},
nzFooter: null
nzFooter: null,
});
}
//初次登陆修改密码弹窗
isVisible = false;
isConfirmLoading = false;
changePasswordPopup() {
this.isVisible = true;
}
handleOk(): void {
if (this.passwordValidateForm.invalid) {
this.message.create("warning", `输入格式不正确`);
} else {
if (
this.passwordValidateForm.value.newpassword !=
this.passwordValidateForm.value.affirmpassword
) {
this.message.create("warning", "两次密码输入不一致!");
} else if (
this.passwordValidateForm.value.newpassword ==
this.passwordValidateForm.value.oldpassword
) {
this.message.create("warning", "旧密码和新密码不能相同!");
} else {
this.isConfirmLoading = true;
let body = {
currentPassword: this.passwordValidateForm.value.oldpassword,
newPassword: this.passwordValidateForm.value.newpassword,
};
this.http.post("/api/services/app/User/ChangePassword", body).subscribe(
(data) => {
//记住密码
if (this.remember) {
localStorage.setItem(
"account",
Base64.encode(this.validateForm.value.userName)
);
localStorage.setItem(
"password",
Base64.encode(this.passwordValidateForm.value.newpassword)
);
}
//自动登录
this.autoLogin();
this.message.create("success", "修改成功!");
this.isConfirmLoading = false;
this.isVisible = false;
this.toPage(this.submitData);
},
(err) => {
this.message.create("warning", err.error.error.message);
this.isConfirmLoading = false;
}
);
}
}
}
}
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>;
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 {
@ -261,14 +376,24 @@ export class MyValidators extends Validators {
return null;
}
return isPassword(value) ? null : { mobile: { 'zh-cn': `长度至少 12 位,必须包含大写字母、小写字母、数字、符号四种中的三种`, en: `Password phone number is not valid` } };
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);
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
)
);
}

63
src/styles.scss

@ -104,8 +104,8 @@ h1 {
//三维场景
.dropDown {
border: 1px solid #23D9FF;
background: linear-gradient(180deg, #000D21 0%, #006E85 100%);
border: 1px solid #23d9ff;
background: linear-gradient(180deg, #000d21 0%, #006e85 100%);
li:hover {
background-color: transparent;
@ -121,8 +121,8 @@ h1 {
}
.dropDownPlan {
background: linear-gradient(360deg, #000D21 0%, rgba(0, 59, 110, 0.8) 100%);
box-shadow: 0px 0px 6px #2399FF;
background: linear-gradient(360deg, #000d21 0%, rgba(0, 59, 110, 0.8) 100%);
box-shadow: 0px 0px 6px #2399ff;
li {
color: #fff;
@ -131,10 +131,9 @@ h1 {
//任务弹窗
.taskDialog {
.ant-modal-header,
.ant-modal-content {
background: radial-gradient(circle, #004988 0%, #00122D 100%);
background: radial-gradient(circle, #004988 0%, #00122d 100%);
}
.ant-modal-header,
@ -143,26 +142,26 @@ h1 {
}
.ant-modal-title,
.ant-form-item-label>label,
.ant-form-item-label > label,
.ant-input {
color: #C4E2FC;
color: #c4e2fc;
}
.ant-modal-footer .ant-btn:first-child {
color: #C4E2FC;
background: #000D21;
border: 1px solid #C4E2FC;
color: #c4e2fc;
background: #000d21;
border: 1px solid #c4e2fc;
}
.ant-modal-footer .ant-btn:last-child {
color: #C4E2FC;
color: #c4e2fc;
background: rgba(0, 129, 255, 0.6);
border: 1px solid #36A2FF;
border: 1px solid #36a2ff;
}
.ant-input {
background: rgba(145, 204, 255, 0.41);
border: 1px solid #91CCFF;
border: 1px solid #91ccff;
}
textarea {
@ -181,7 +180,11 @@ h1 {
.ant-modal-body,
.ant-modal-content {
height: 100%;
background: radial-gradient(closest-side at 50% 55%, #004988 0%, #00122D 100%);
background: radial-gradient(
closest-side at 50% 55%,
#004988 0%,
#00122d 100%
);
}
}
@ -214,7 +217,6 @@ h1 {
//bbl 内置color
#threeDimensional {
//可展开面板
#disposalPlan {
font-size: 15px;
@ -223,7 +225,7 @@ h1 {
width: 100%;
height: 35px;
line-height: 35px;
color: #23D9FF;
color: #23d9ff;
padding: 0px;
background: rgba(35, 153, 255, 0.41);
border: 1px solid rgba(35, 217, 255, 0.4);
@ -235,12 +237,12 @@ h1 {
.ant-collapse-content {
background-color: transparent;
width: 100%
width: 100%;
}
}
.ant-tree {
color: #C4E2FC;
color: #c4e2fc;
}
//tree
@ -257,7 +259,8 @@ h1 {
//tree
.ant-select-disabled.ant-select-single:not(.ant-select-customize-input) .ant-select-selector {
.ant-select-disabled.ant-select-single:not(.ant-select-customize-input)
.ant-select-selector {
color: #fff;
}
@ -296,9 +299,9 @@ h1 {
padding-left: 5px;
height: 30px;
line-height: 28px;
background: linear-gradient(360deg, #000D21 0%, rgba(0, 59, 110, 0.8) 100%);
background: linear-gradient(360deg, #000d21 0%, rgba(0, 59, 110, 0.8) 100%);
border: 1px solid rgba(35, 217, 255, 0.4);
color: #23D9FF;
color: #23d9ff;
.ant-collapse-arrow {
left: 5px;
@ -314,13 +317,13 @@ h1 {
//步骤条
//滚动条样式
//滚动条样式
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-thumb {
background-image: linear-gradient(#2495f8, #1c73c2, #02233f, );
background-image: linear-gradient(#2495f8, #1c73c2, #02233f);
}
::-webkit-scrollbar-track {
@ -366,7 +369,7 @@ ul {
}
.btn {
color: #36A2FF;
color: #36a2ff;
span {
cursor: pointer;
@ -380,7 +383,6 @@ ul {
margin-right: 40px;
}
}
}
.spin {
@ -395,3 +397,12 @@ ul {
left: 0;
top: 0;
}
#progressBar {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 5px;
background-color: #ccc; /* 进度条默认颜色 */
}

Loading…
Cancel
Save