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" "output": "/assets/abp"
} }
], ],
"styles": [ "styles": ["src/styles.scss"],
"src/styles.scss"
],
"scripts": [ "scripts": [
"node_modules/@aspnet/signalr/dist/browser/signalr.min.js", "node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
"node_modules/abp-web-resources/Abp/Framework/scripts/abp.js" "node_modules/abp-web-resources/Abp/Framework/scripts/abp.js"
@ -147,9 +145,7 @@
"tsconfig.spec.json", "tsconfig.spec.json",
"e2e/tsconfig.json" "e2e/tsconfig.json"
], ],
"exclude": [ "exclude": ["**/node_modules/**"]
"**/node_modules/**"
]
} }
}, },
"e2e": { "e2e": {
@ -171,4 +167,4 @@
"cli": { "cli": {
"analytics": false "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", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "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", "build": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --configuration production",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",

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

@ -119,43 +119,3 @@
</ng-template> </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; this.userName = JSON.parse(sessionStorage.getItem("userdata")).userName;
} }
if ( // if (
(sessionStorage.getItem("isDefaultPassword") == "true" || // (sessionStorage.getItem("isDefaultPassword") == "true" ||
sessionStorage.getItem("isPasswordExpired") == "true") && // sessionStorage.getItem("isPasswordExpired") == "true") &&
JSON.parse(sessionStorage.getItem("userdata")).userName != "admin" // JSON.parse(sessionStorage.getItem("userdata")).userName != "admin"
) { // ) {
this.changePasswordPopup(); // this.changePasswordPopup();
} // }
this.getWarningSwitch(); this.getWarningSwitch();
} }
@ -285,49 +285,7 @@ export class HomeComponent implements OnInit {
SignalRAspNetCoreHelper.initSignalR(); SignalRAspNetCoreHelper.initSignalR();
abp.event.on("abp.notifications.received", this.reloadPage); 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) => { reloadPage = (userNotification) => {
console.log("abp.notifications.received收到通知", 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 { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators, AbstractControl } from '@angular/forms'; import {
import { NzMessageService } from 'ng-zorro-antd/message'; FormBuilder,
import { NzSafeAny } from 'ng-zorro-antd/core/types'; FormGroup,
import { HttpClient } from '@angular/common/http'; Validators,
import { NzModalRef } from 'ng-zorro-antd/modal'; 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({ @Component({
selector: 'app-forget', selector: "app-forget",
templateUrl: './forget.component.html', templateUrl: "./forget.component.html",
styleUrls: ['./forget.component.scss'] styleUrls: ["./forget.component.scss"],
}) })
export class ForgetComponent implements OnInit { export class ForgetComponent implements OnInit {
validateForm!: FormGroup; validateForm!: FormGroup;
validateForm2!: FormGroup; validateForm2!: FormGroup;
validateForm3!: FormGroup; validateForm3!: FormGroup;
constructor(private fb: FormBuilder, private message: NzMessageService, private http: HttpClient, private modal: NzModalRef, private patternService: PatternService) { } constructor(
isProd: boolean private fb: FormBuilder,
private message: NzMessageService,
private http: HttpClient,
private modal: NzModalRef,
private patternService: PatternService
) {}
isProd: boolean;
ngOnInit(): void { ngOnInit(): void {
this.isProd = this.patternService.isProd this.isProd = this.patternService.isProd;
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
account: [null, [Validators.required]] account: [null, [Validators.required]],
}); });
this.validateForm2 = this.fb.group({ this.validateForm2 = this.fb.group({
code: [null, [Validators.required]] code: [null, [Validators.required]],
}); });
const { password } = MyValidators; const { password } = MyValidators;
this.validateForm3 = this.fb.group({ this.validateForm3 = this.fb.group({
newpassword: [null, [Validators.required, password]], newpassword: [null, [Validators.required, password]],
affirmpassword: [null, [Validators.required, password]] affirmpassword: [null, [Validators.required, password]],
}); });
} }
currentStep = 1 currentStep = 1;
phoneNum: string phoneNum: string;
step1() { step1() {
console.log(this.validateForm) console.log(this.validateForm);
if (this.validateForm.invalid) { if (this.validateForm.invalid) {
this.message.create('warning', '请填写完整'); this.message.create("warning", "请填写完整");
} else { } else {
this.http.get('/api/services/app/User/GetPhoneNumber', { this.http
params: { .get("/api/services/app/User/GetPhoneNumber", {
userName: this.validateForm.value.account params: {
} userName: this.validateForm.value.account,
}).subscribe({ },
next: (data: any) => { })
this.phoneNum = data.result .subscribe({
this.currentStep = 2 next: (data: any) => {
} this.phoneNum = data.result;
}) this.currentStep = 2;
},
});
} }
} }
//发送验证码 //发送验证码
codeCountDown = 0 codeCountDown = 0;
code() { code() {
this.codeCountDown = 30;
let params = { let params = {
userName: this.validateForm.value.account, userName: this.validateForm.value.account,
} };
this.http.post('/api/services/app/User/SendVerificationCode', null, { params: params }).subscribe({ this.http
next: (data: any) => { .post("/api/services/app/User/SendVerificationCode", null, {
this.message.create('success', '已发送'); params: params,
//按钮倒计时 })
this.codeCountDown = 30 .subscribe({
let codesetInterval = setInterval(() => { next: (data: any) => {
this.codeCountDown = this.codeCountDown - 1 this.message.create("success", "已发送");
if (this.codeCountDown == 0) { //按钮倒计时
clearInterval(codesetInterval) let codesetInterval = setInterval(() => {
} this.codeCountDown = this.codeCountDown - 1;
}, 1000); if (this.codeCountDown == 0) {
} clearInterval(codesetInterval);
}) }
}, 1000);
},
});
} }
step2() { step2() {
if (this.validateForm2.invalid) { if (this.validateForm2.invalid) {
this.message.create('warning', '请填写完整'); this.message.create("warning", "请填写完整");
} else { } else {
console.log(this.validateForm.value.account) console.log(this.validateForm.value.account);
let params = { let params = {
userName: this.validateForm.value.account, userName: this.validateForm.value.account,
code: this.validateForm2.value.code code: this.validateForm2.value.code,
} };
this.http.get('/api/services/app/User/VerifyVerificationCode', { params: params }).subscribe({ this.http
next: (data: any) => { .get("/api/services/app/User/VerifyVerificationCode", {
this.currentStep = 3 params: params,
} })
}) .subscribe({
next: (data: any) => {
this.currentStep = 3;
},
});
} }
} }
step3() { step3() {
if (this.validateForm3.valid) { if (this.validateForm3.valid) {
let word = JSON.parse(JSON.stringify(this.validateForm3.value.newpassword)).toLowerCase() let word = JSON.parse(
if (this.validateForm3.value.newpassword != this.validateForm3.value.affirmpassword) { JSON.stringify(this.validateForm3.value.newpassword)
this.message.create('warning', '两次密码输入不一致!'); ).toLowerCase();
return false if (
} if (word.indexOf('sino') != -1 || word.indexOf('zhonghua') != -1) { this.validateForm3.value.newpassword !=
this.message.create('warning', '口令禁止包含 sinochem、sino、zhonghua (含大小写变体) 等中国中化相关字符'); this.validateForm3.value.affirmpassword
return false ) {
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 { } else {
let body = { let body = {
userName: this.validateForm.value.account, userName: this.validateForm.value.account,
code: this.validateForm2.value.code, code: this.validateForm2.value.code,
newPassword: this.validateForm3.value.newpassword, newPassword: this.validateForm3.value.newpassword,
} };
this.http.post('/api/services/app/User/ChangePasswordBySms', body).subscribe(data => { this.http
this.message.create('success', '修改成功!'); .post("/api/services/app/User/ChangePasswordBySms", body)
this.modal.close() .subscribe(
return true (data) => {
}, err => { this.message.create("success", "修改成功!");
return false this.modal.close();
}) return true;
},
(err) => {
return false;
}
);
} }
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create("warning", "请填写完整!");
return false 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 type MyValidationErrors = Record<string, MyErrorsOptions>;
export class MyValidators extends Validators { export class MyValidators extends Validators {
static password(control: AbstractControl): MyValidationErrors | null { static password(control: AbstractControl): MyValidationErrors | null {
@ -133,13 +167,26 @@ export class MyValidators extends Validators {
return null; 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 { function isEmptyInputValue(value: NzSafeAny): boolean {
return value == null || value.length === 0; return value == null || value.length === 0;
} }
function isPassword(value: string): boolean { 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=""> <img *ngIf="isProd" src="../../../assets/images/logo2.png" alt="">
</div> </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 { Component, OnInit, ViewContainerRef } from "@angular/core";
import { HttpClient } from '@angular/common/http' import { HttpClient } from "@angular/common/http";
import { Router, ActivatedRoute } from '@angular/router' import { Router, ActivatedRoute } from "@angular/router";
import { CacheTokenService } from '../../service/cache-token.service'//引入服务 import { CacheTokenService } from "../../service/cache-token.service"; //引入服务
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import {
import { NzMessageService } from 'ng-zorro-antd/message'; AbstractControl,
import { Base64 } from 'js-base64'; FormBuilder,
import { NzNotificationService } from 'ng-zorro-antd/notification'; FormGroup,
import { NzSafeAny } from 'ng-zorro-antd/core/types'; Validators,
import { SelectedMenu } from 'src/app/service/selectedMenu.service'; } from "@angular/forms";
import { NzModalService } from 'ng-zorro-antd/modal'; import { NzMessageService } from "ng-zorro-antd/message";
import { ForgetComponent } from './forget/forget.component'; import { Base64 } from "js-base64";
import { PatternService } from 'src/app/service/pattern.service'; import { NzNotificationService } from "ng-zorro-antd/notification";
// import { THIS_EXPR } from '@angular/compiler/src/output/output_ast'; 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({ @Component({
selector: 'app-login', selector: "app-login",
templateUrl: './login.component.html', templateUrl: "./login.component.html",
styleUrls: ['./login.component.scss'] styleUrls: ["./login.component.scss"],
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
validateForm!: FormGroup; validateForm!: FormGroup;
passwordValidateForm!: 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; const { password } = MyValidators;
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
userName: [null, [Validators.required]], userName: [null, [Validators.required]],
@ -34,224 +48,325 @@ export class LoginComponent implements OnInit {
this.passwordValidateForm = this.fb.group({ this.passwordValidateForm = this.fb.group({
oldpassword: [null, [Validators.required]], oldpassword: [null, [Validators.required]],
newpassword: [null, [Validators.required, password]], newpassword: [null, [Validators.required, password]],
affirmpassword: [null, [Validators.required, password]] affirmpassword: [null, [Validators.required, password]],
}); });
} }
isProd: boolean;
isProd: boolean
ngOnInit() { ngOnInit() {
this.isProd = this.patternService.isProd this.isProd = this.patternService.isProd;
//如果本地储存了账号密码信息,那就回显在输入框 //如果本地储存了账号密码信息,那就回显在输入框
let account = localStorage.getItem('account') let account = localStorage.getItem("account");
let password = localStorage.getItem('password') let password = localStorage.getItem("password");
if (account && password) { if (account && password) {
this.validateForm.patchValue({ this.validateForm.patchValue({
userName: Base64.decode(localStorage.getItem('account')), userName: Base64.decode(localStorage.getItem("account")),
password: Base64.decode(localStorage.getItem('password')) password: Base64.decode(localStorage.getItem("password")),
}); });
this.remember = true //这一步是回显后让勾选框为选中状态 this.remember = true; //这一步是回显后让勾选框为选中状态
} }
//自动登录 //自动登录
if (localStorage.getItem('isautologin') == 'true') { if (localStorage.getItem("isautologin") == "true") {
this.submitForm() this.submitForm();
this.autologin = true //这一步是回显后让勾选框为选中状态 this.autologin = true; //这一步是回显后让勾选框为选中状态
} }
} }
errmsg: string = ''; //错误信息 errmsg: string = ""; //错误信息
//跳转注册页面 //跳转注册页面
toRegister() { toRegister() {
this.router.navigate(['/register']) this.router.navigate(["/register"]);
} }
//记住密码 //记住密码
rememberInfo() { rememberInfo() {
// 判断用户是否勾选记住密码,如果勾选,在本地储存中储存登录信息 // 判断用户是否勾选记住密码,如果勾选,在本地储存中储存登录信息
if (this.remember) { if (this.remember) {
localStorage.setItem("account", Base64.encode(this.validateForm.value.userName)) localStorage.setItem(
localStorage.setItem("password", Base64.encode(this.validateForm.value.password)) "account",
Base64.encode(this.validateForm.value.userName)
);
localStorage.setItem(
"password",
Base64.encode(this.validateForm.value.password)
);
} }
} }
//自动登录 //自动登录
autoLogin() { autoLogin() {
if (this.autologin) { if (this.autologin) {
localStorage.setItem("isautologin", 'true') localStorage.setItem("isautologin", "true");
} }
} }
remember: any//记住密码 remember: any; //记住密码
autologin: any//自动登录 autologin: any; //自动登录
isLoading = false; isLoading = false;
messages messages;
encryptedAccessToken encryptedAccessToken;
menu1 = [ menu1 = [
{ name: '首页', url: '/homepage' }, { name: "首页", url: "/homepage" },
{ name: '数字油站', url: '/plan' }, { name: "数字油站", url: "/plan" },
{ name: '今日预警', url: '/todaywarning' }, { name: "今日预警", url: "/todaywarning" },
{ name: '预警记录', url: '/records_nav' }, { name: "预警记录", url: "/records_nav" },
{ name: '证照管理', url: '/audit' }, { name: "证照管理", url: "/audit" },
] ];
menu2 = [ menu2 = [
{ name: '数字油站', url: '/plan/petrolStation' }, { name: "数字油站", url: "/plan/petrolStation" },
{ name: '今日预警', url: '/todaywarning/petrolStation' }, { name: "今日预警", url: "/todaywarning/petrolStation" },
{ name: '预警记录', url: '/records_nav/petrolStation' }, { name: "预警记录", url: "/records_nav/petrolStation" },
{ name: '证照管理', url: '/license/petrolStation' }, { name: "证照管理", url: "/license/petrolStation" },
] ];
init3D init3D;
async getGasStationBaseInfo() { async getGasStationBaseInfo() {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
let params = { organizationUnitId: (JSON.parse(sessionStorage.getItem('userdataOfgasstation'))).organization.id } let params = {
this.http.get('/api/services/app/GasStation/Get', { params: params }).subscribe((data: any) => { organizationUnitId: JSON.parse(
resolve(data.result) 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)) sessionStorage.setItem("3dSceneData", JSON.stringify(data.result));
this.init3D = data.result.hasBuildingInfo this.init3D = data.result.hasBuildingInfo;
});
}) });
})
} }
submitForm(): void {
submitData;
submitForm(): void {
if (!this.remember) { if (!this.remember) {
localStorage.removeItem("account") localStorage.removeItem("account");
localStorage.removeItem("password") localStorage.removeItem("password");
} }
if (!this.autologin) { if (!this.autologin) {
localStorage.removeItem("isautologin") localStorage.removeItem("isautologin");
} }
for (const i in this.validateForm.controls) { for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity(); this.validateForm.controls[i].updateValueAndValidity();
} }
if (!this.validateForm.valid) { if (!this.validateForm.valid) {
this.message.create('error', `请输入账号密码`); this.message.create("error", `请输入账号密码`);
return return;
} }
this.isLoading = true; this.isLoading = true;
this.http.post('/api/TokenAuth/Authenticate', { this.http
userNameOrEmailAddress: this.validateForm.value.userName, .post("/api/TokenAuth/Authenticate", {
password: this.validateForm.value.password userNameOrEmailAddress: this.validateForm.value.userName,
}).subscribe( password: this.validateForm.value.password,
(data: any) => { })
sessionStorage.setItem("token", data.result.accessToken); .subscribe(
sessionStorage.setItem("encryptedAccessToken", data.result.encryptedAccessToken); (data: any) => {
this.http.get('/api/services/app/Session/GetCurrentLoginInformations').subscribe(async (data: any) => { sessionStorage.setItem("token", data.result.accessToken);
console.log('GetCurrentLoginInformations', data.result) sessionStorage.setItem(
if (data.result.user.menus.length == 0) { "encryptedAccessToken",
this.message.create('error', `当前用户未分配菜单`); data.result.encryptedAccessToken
this.isLoading = false );
return this.http
} .get("/api/services/app/Session/GetCurrentLoginInformations")
.subscribe(
sessionStorage.setItem('userdata', JSON.stringify(data.result.user)) async (data: any) => {
sessionStorage.setItem('userdataOfgasstation', JSON.stringify(data.result.user)) this.submitData = data;
sessionStorage.setItem('isDefaultPassword', JSON.stringify(data.result.user.isDefaultPassword)) console.log("GetCurrentLoginInformations", data.result);
sessionStorage.setItem('isPasswordExpired', JSON.stringify(data.result.user.isPasswordExpired)) if (data.result.user.menus.length == 0) {
this.isLoading = false; this.message.create("error", `当前用户未分配菜单`);
if (!data.result.user.organization) { this.isLoading = false;
this.message.create('error', `当前用户没有组织机构信息`); return;
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.organization.isGasStation) { sessionStorage.setItem(
sessionStorage.setItem("isGasStation", 'true'); "userdata",
let a = sessionStorage.getItem('userdataOfgasstation') JSON.stringify(data.result.user)
let menuList = this.returnLastMenus(a, this.menu2) );
let isTrue = menuList.find((item) => { sessionStorage.setItem(
return item.name == "今日预警" "userdataOfgasstation",
}); JSON.stringify(data.result.user)
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', `当前用户未分配菜单`); 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.toPage(data);
this.router.navigate(['/homepage'])
sessionStorage.setItem('selectedMenu', '首页')
} else {
this.router.navigate([menuList[0].url])
sessionStorage.setItem('selectedMenu', menuList[0].name)
}
//
} this.message.create("success", `登录成功`);
this.message.create('success', `登录成功`); },
}, err => { (err) => {
this.isLoading = false;
}
);
},
(err) => {
this.isLoading = false; 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) { returnLastMenus(data, originalMenus) {
let userMenu = JSON.parse(data).menus let userMenu = JSON.parse(data).menus;
let tap = [] let tap = [];
let menuList = [] let menuList = [];
for (let index = 0; index < userMenu.length; index++) { for (let index = 0; index < userMenu.length; index++) {
let a = userMenu[index].name let a = userMenu[index].name;
tap.push(a) tap.push(a);
} }
for (let index = 0; index < originalMenus.length; index++) { for (let index = 0; index < originalMenus.length; index++) {
for (let k = 0; k < tap.length; k++) { for (let k = 0; k < tap.length; k++) {
if (tap[k] == originalMenus[index].name) { if (tap[k] == originalMenus[index].name) {
menuList.push(originalMenus[index]) menuList.push(originalMenus[index]);
} }
} }
} }
return menuList return menuList;
} }
forget() { forget() {
// this.message.create('warning', `请联系管理员`); // this.message.create('warning', `请联系管理员`);
this.modal.create({ this.modal.create({
nzTitle: '忘记密码', nzTitle: "忘记密码",
nzContent: ForgetComponent, nzContent: ForgetComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 288, nzWidth: 288,
nzComponentParams: {}, 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 type MyValidationErrors = Record<string, MyErrorsOptions>;
export class MyValidators extends Validators { export class MyValidators extends Validators {
static password(control: AbstractControl): MyValidationErrors | null { static password(control: AbstractControl): MyValidationErrors | null {
@ -261,14 +376,24 @@ export class MyValidators extends Validators {
return null; 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 { function isEmptyInputValue(value: NzSafeAny): boolean {
return value == null || value.length === 0; return value == null || value.length === 0;
} }
function isPassword(value: string): boolean { 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 { .dropDown {
border: 1px solid #23D9FF; border: 1px solid #23d9ff;
background: linear-gradient(180deg, #000D21 0%, #006E85 100%); background: linear-gradient(180deg, #000d21 0%, #006e85 100%);
li:hover { li:hover {
background-color: transparent; background-color: transparent;
@ -121,8 +121,8 @@ h1 {
} }
.dropDownPlan { .dropDownPlan {
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%);
box-shadow: 0px 0px 6px #2399FF; box-shadow: 0px 0px 6px #2399ff;
li { li {
color: #fff; color: #fff;
@ -131,10 +131,9 @@ h1 {
//任务弹窗 //任务弹窗
.taskDialog { .taskDialog {
.ant-modal-header, .ant-modal-header,
.ant-modal-content { .ant-modal-content {
background: radial-gradient(circle, #004988 0%, #00122D 100%); background: radial-gradient(circle, #004988 0%, #00122d 100%);
} }
.ant-modal-header, .ant-modal-header,
@ -143,26 +142,26 @@ h1 {
} }
.ant-modal-title, .ant-modal-title,
.ant-form-item-label>label, .ant-form-item-label > label,
.ant-input { .ant-input {
color: #C4E2FC; color: #c4e2fc;
} }
.ant-modal-footer .ant-btn:first-child { .ant-modal-footer .ant-btn:first-child {
color: #C4E2FC; color: #c4e2fc;
background: #000D21; background: #000d21;
border: 1px solid #C4E2FC; border: 1px solid #c4e2fc;
} }
.ant-modal-footer .ant-btn:last-child { .ant-modal-footer .ant-btn:last-child {
color: #C4E2FC; color: #c4e2fc;
background: rgba(0, 129, 255, 0.6); background: rgba(0, 129, 255, 0.6);
border: 1px solid #36A2FF; border: 1px solid #36a2ff;
} }
.ant-input { .ant-input {
background: rgba(145, 204, 255, 0.41); background: rgba(145, 204, 255, 0.41);
border: 1px solid #91CCFF; border: 1px solid #91ccff;
} }
textarea { textarea {
@ -181,7 +180,11 @@ h1 {
.ant-modal-body, .ant-modal-body,
.ant-modal-content { .ant-modal-content {
height: 100%; 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 //bbl 内置color
#threeDimensional { #threeDimensional {
//可展开面板 //可展开面板
#disposalPlan { #disposalPlan {
font-size: 15px; font-size: 15px;
@ -223,7 +225,7 @@ h1 {
width: 100%; width: 100%;
height: 35px; height: 35px;
line-height: 35px; line-height: 35px;
color: #23D9FF; color: #23d9ff;
padding: 0px; padding: 0px;
background: rgba(35, 153, 255, 0.41); background: rgba(35, 153, 255, 0.41);
border: 1px solid rgba(35, 217, 255, 0.4); border: 1px solid rgba(35, 217, 255, 0.4);
@ -235,12 +237,12 @@ h1 {
.ant-collapse-content { .ant-collapse-content {
background-color: transparent; background-color: transparent;
width: 100% width: 100%;
} }
} }
.ant-tree { .ant-tree {
color: #C4E2FC; color: #c4e2fc;
} }
//tree //tree
@ -257,7 +259,8 @@ h1 {
//tree //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; color: #fff;
} }
@ -296,9 +299,9 @@ h1 {
padding-left: 5px; padding-left: 5px;
height: 30px; height: 30px;
line-height: 28px; 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); border: 1px solid rgba(35, 217, 255, 0.4);
color: #23D9FF; color: #23d9ff;
.ant-collapse-arrow { .ant-collapse-arrow {
left: 5px; left: 5px;
@ -314,13 +317,13 @@ h1 {
//步骤条 //步骤条
//滚动条样式 //滚动条样式
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 5px; width: 5px;
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background-image: linear-gradient(#2495f8, #1c73c2, #02233f, ); background-image: linear-gradient(#2495f8, #1c73c2, #02233f);
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
@ -366,7 +369,7 @@ ul {
} }
.btn { .btn {
color: #36A2FF; color: #36a2ff;
span { span {
cursor: pointer; cursor: pointer;
@ -380,7 +383,6 @@ ul {
margin-right: 40px; margin-right: 40px;
} }
} }
} }
.spin { .spin {
@ -395,3 +397,12 @@ ul {
left: 0; left: 0;
top: 0; top: 0;
} }
#progressBar {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 5px;
background-color: #ccc; /* 进度条默认颜色 */
}

Loading…
Cancel
Save