车辆对接

This commit is contained in:
wangshiming
2021-12-27 21:08:22 +08:00
parent 1a41c2999e
commit 777e5dd101
19 changed files with 746 additions and 136 deletions

View File

@ -154,9 +154,12 @@ export class AccountComponentsCenterComponent implements OnInit {
edit(tpye: string) {
if (tpye === 'phone') {
const modalRef = this.modalService.create({
nzTitle: '修改用户名',
nzTitle: '验证手机号码',
nzContent: AccountComponentsEditNameComponent,
nzComponentParams: { },
nzComponentParams: {
i: this.infoData
},
nzFooter: null
});
modalRef.afterClose.subscribe((result: any) => {
if (result === true) {

View File

@ -1,7 +1,7 @@
<!--
* @Author: your name
* @Date: 2021-11-29 11:06:01
* @LastEditTime: 2021-11-29 15:08:06
* @LastEditTime: 2021-12-27 20:37:25
* @LastEditors: Please set LastEditors
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \tms-obc-web\src\app\routes\account\components\edit-name\edit-name.component.html
@ -24,8 +24,36 @@
</ng-template>
</sf>
<!-- <div class="modal-footer">
<div class="modal-footer">
<button nz-button type="button" (click)="close()">关闭</button>
<button nz-button type="button" nzType="primary" (click)="submitForm()" [disabled]="!sf.valid">确定</button>
</div> -->
<!-- <app-captcha #dun [phone]="this.i.phone" (done)="captchaDone($event)"></app-captcha> -->
<button nz-button type="button" nzType="primary" (click)="submitForm()" [disabled]="!sf.valid">下一步</button>
</div>
<nz-modal [(nzVisible)]="isVisibleView" [nzWidth]="600" [nzFooter]="nzModalFooterview" nzTitle="修改手机号码" (nzOnOk)="handleOK()" (nzOnCancel)="handleCancel('1')">
<ng-container *nzModalContent>
<sf #sfView [schema]="schemaView" [ui]="uiView" [compact]="true" [button]="'none'">
<ng-template sf-template="smsVerifyCode" let-me let-ui="uiView" let-schema="schemaView">
<div style="position: relative;">
<input
type="text"
maxlength="6"
nz-input
[ngModel]="me.formProperty.value"
(ngModelChange)="me.setValue($event)"
placeholder="请输入验证码"
/>
<button style="position: absolute;
top: 0;
right: 0;
z-index: 9;" nz-button nzType="link" [disabled]="count2 > 0" (click)="getCaptcha2()">
{{ count2 > 0 ? '请等待' + count2 + 's' : '获取验证码' }}
</button>
</div>
</ng-template>
</sf>
</ng-container>
<ng-template #nzModalFooterview>
<button nz-button nzType="default" (click)="handleCancel('1')">取消</button>
<button nz-button nzType="primary" (click)="handleNew()">确定</button>
</ng-template>
</nz-modal>

View File

@ -4,8 +4,17 @@
}
.btn-code {
position: absolute;
right: 0;
top: 0;
right: 0;
z-index: 9;
}
.valid-code2 {
position: relative;
}
.btn-code2 {
position: absolute;
top: 0;
right: 0;
z-index: 9;
}
}

View File

@ -14,17 +14,21 @@ import { AccountService } from '../../services/account.service';
})
export class AccountComponentsEditNameComponent implements OnInit, AfterViewInit {
// @ViewChild('dun', { static: false })
url = `/rule?_allow_anonymous=true`;
// private dun!: CaptchaComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
@ViewChild('sfView', { static: false }) sfView!: SFComponent;
record: any = {};
i: any;
schema!: SFSchema;
schemaView!: SFSchema;
ui!: SFUISchema;
uiView: SFUISchema = {};
isVisibleView = false;
formData: any = {};
count = 0;
count2 = 0;
oldName: any;
voucher: any;
codeTips: any;
interval$: any;
@ -34,47 +38,37 @@ export class AccountComponentsEditNameComponent implements OnInit, AfterViewInit
}
ngOnInit() {
this.codeTips = '为了账户安全,需您的手机验证(' + this.i.phone + '';
this.formData.oldName = this.i.name;
console.log(this.i)
this.codeTips = '为了账户安全,需您的手机验证(' + this.i?.phone + '';
this.formData.oldName = this.i?.phone;
this.initSF();
this.initSFNew();
// this.getInfo();
}
initSF() {
this.schema = {
properties: {
oldName: {
title: '用户名(旧)',
title: '手机号',
type: 'string',
default: this.formData.oldName,
default: this.formData?.oldName,
ui: {
widget: 'text',
},
},
userName: {
title: '用户名(新)',
type: 'string',
minLength: 3,
maxLength: 30,
description: '3-30个字符支持中英文、数字、符号“_”和“-”,只能修改一次',
ui: {
placeholder: '请输入新用户名',
errors: {
required: '请输入新用户名',
},
// validator: (val) => this.validatecomponent(val),
// blur: () => this.checkUserName(),
// validator: (val) => {
// const name = this.sf?.getValue('/oldName');
// if (name === val) {
// return [{ keyword: 'validateName', message: '新用户名不能与旧用户名一样' }];
// }
// // console.log(this.isCheck,'this.isCheck');
// // if (!this.isCheck) {
// // return [{ keyword: 'validateName', message: '用户名已存在,请修改' }];
// // }
// },
} as SFStringWidgetSchema,
},
// userName: {
// title: '用户名(新)',
// type: 'string',
// minLength: 3,
// maxLength: 30,
// description: '3-30个字符支持中英文、数字、符号“_”和“-”,只能修改一次',
// ui: {
// placeholder: '请输入新用户名',
// errors: {
// required: '请输入新用户名',
// },
// } as SFStringWidgetSchema,
// },
smsVerifyCode: {
title: '验证码',
type: 'string',
@ -100,6 +94,46 @@ export class AccountComponentsEditNameComponent implements OnInit, AfterViewInit
},
};
}
initSFNew() {
this.schemaView = {
properties: {
phone: {
title: '新手机号',
type: 'string',
minLength: 3,
maxLength: 30,
ui: {
placeholder: '请输入新手机号',
errors: {
required: '请输入新手机号',
},
} as SFStringWidgetSchema,
},
smsVerifyCode: {
title: '验证码',
type: 'string',
maxLength: 6,
minLength: 6,
description: this.codeTips,
ui: {
widget: 'custom',
placeholder: '请输入验证码',
errors: {
required: '请输入6位验证码',
minLength: '请输入6位验证码',
},
},
},
},
required: ['phone', 'smsVerifyCode'],
};
this.uiView = {
'*': {
spanLabelFixed: 100,
grid: { span: 24 },
},
};
}
getCaptcha() {
const params = {
@ -119,6 +153,24 @@ export class AccountComponentsEditNameComponent implements OnInit, AfterViewInit
});
}
getCaptcha2() {
const params = {
phoneNumber: this.sfView.value.phone
};
this.service.request(this.service.$api_get_getSMVerificationCode, params, 'POST', true, 'FORM').subscribe((res) => {
console.log(res);
// code==503046 弹出网易盾
if (res && res.code === '1') {
this.service.msgSrv.success('发送成功');
this.codeCountDown2();
} else if (res.code === '503046') {
// this.dun.popUp();
} else {
this.service.msgSrv.success(res.msg);
}
});
}
/* code倒计时 */
codeCountDown() {
this.count = 59;
@ -129,6 +181,15 @@ export class AccountComponentsEditNameComponent implements OnInit, AfterViewInit
}
}, 1000);
}
codeCountDown2() {
this.count2 = 59;
this.interval$ = setInterval(() => {
this.count2 -= 1;
if (this.count <= 0) {
clearInterval(this.interval$);
}
}, 1000);
}
/* 网易盾验证通过 */
captchaDone(validate: any) {
this.codeCountDown();
@ -144,71 +205,53 @@ export class AccountComponentsEditNameComponent implements OnInit, AfterViewInit
// }
});
}
/**
* 验证组件名称
* 规则以小写字母开头长度1-20 仅限小写字母、数字和横线
*/
// validatecomponent(value: string): Observable<ErrorData[]> {
// return new Observable((observer: Observer<ErrorData[] | null>) => {
// if (!value || value.trim().length === 0) {
// observer.next([{ keyword: 'required', message: '用户名不能为空!' }]);
// return;
// }
// let isCheck: any;
// this.service.request(this.service.$api_checkUserName, { userName: value }, 'POST', true, 'FORM').subscribe((res) => {
// // 检查用户名
// isCheck = res;
// });
// setTimeout(() => {
// // 以小写字母开头长度1-20 仅限小写字母、数字和横线
// // const partern = /^[a-z][a-zA-Z0-9-]{0,30}$/;
// // 3-30个字符支持中英文、数字、符号“_”和“-”
// const partern = /^[a-zA-Z0-9_\-\u4e00-\u9fa5]{3,30}$/;
// const reg = new RegExp(partern);
// const result = reg.test(value);
// const name = this.sf?.getValue('/oldName');
// if (name === value) {
// observer.next([{ keyword: 'validateName', message: '新用户名不能与旧用户名一样' }]);
// return;
// }
// console.log(value, 'value', isCheck);
// if (!isCheck) {
// observer.next([{ keyword: 'validateName', message: '用户名已存在,请修改' }]);
// return;
// }
// if (!result) {
// observer.next([{ keyword: 'validateName', message: '请输入3-30个字符,且不能含有特殊符号!' }]);
// } else {
// observer.next([]);
// }
// observer.complete();
// }, 500);
// });
// }
// this.usernameValidator = (control: FormControl) => {
// if (control.value === this.i.name) {
// return of(null);
// }
// return control.valueChanges.pipe(
// );
// };
close() {
this.modal.destroy();
}
submitForm() {
console.log(this.sf.value, 'this.sf.value');
const params = {
...this.sf.value,
smsVerifyCode: this.sf.value.smsVerifyCode,
};
this.service.http.post(this.service.$api_get_current_user_info, params).subscribe((res) => {
// this.modal.close();
this.isVisibleView = true
this.service.http.post(this.service.$api_get_verifyPhone, params).subscribe((res) => {
console.log(res, 'submitForm');
if (res.success) {
this.service.msgSrv.success(res.msg);
// this.modal.close(true);
this.voucher = res.data.voucher
this.isVisibleView = true
} else {
this.service.msgSrv.warning(res.msg);
}
});
}
handleCancel(type: string) {
if(type === '1') {
console.log(type)
this.isVisibleView = false
} else if(type === '2') {
console.log(type)
}
}
handleOK() {
}
handleNew() {
console.log(this.voucher)
const params = {
voucher: this.voucher,
...this.sfView.value,
}
this.service.http.post(this.service.$api_get_verifyPhone, params).subscribe((res) => {
console.log(res);
if (res.success) {
this.modal.close(true);
this.service.msgSrv.success(res.msg);
} else {
this.service.msgSrv.warning(res.msg);
}

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-11-02 11:12:21
* @LastEditTime: 2021-12-13 17:43:32
* @LastEditTime: 2021-12-27 17:10:47
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \scm-ows-ui\src\app\routes\account\services\account.service.ts
@ -23,6 +23,14 @@ export class AccountService extends BaseService {
// 根据当前登录用户绑定的手机号码获取短信验证码
$api_get_current_user_smVerification = `/api/mdc/pbc/smsSend/getSmVerificationCodeByToken`;
// 获取短信验证码
$api_get_getSMVerificationCode = `/api/mdc/pbc/smsSend/getSMVerificationCode`;
// 验证手机号
$api_get_verifyPhone = `/api/mdc/cuc/userBasicInfo/forgetPassword/verifyPhone`;
// 凭证修改手机号
$api_set_voucherUpdatePhone = `/api/mdc/cuc/userBasicInfo/forgetPassword/voucherUpdatePhone`;
constructor(public injector: Injector) {
super(injector);
}