车辆对接
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user