fix(core): 统一电话号码字段名称从 phonenumber 改为 phone
This commit is contained in:
@@ -2,12 +2,12 @@ import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
* @param phonenumber 手机号
|
||||
* @param phone 手机号
|
||||
* @returns void
|
||||
*/
|
||||
export function sendSmsCode(phonenumber: string) {
|
||||
export function sendSmsCode(phone: string) {
|
||||
return requestClient.get<void>('/resource/sms/code', {
|
||||
params: { phonenumber },
|
||||
params: { phone },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface User {
|
||||
loginDate: string;
|
||||
loginIp: string;
|
||||
nick: string;
|
||||
phonenumber: string;
|
||||
phone: string;
|
||||
remark: string;
|
||||
roles: Role[];
|
||||
sex: string;
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface User {
|
||||
nick: string;
|
||||
userType: string;
|
||||
email: string;
|
||||
phonenumber: string;
|
||||
phone: string;
|
||||
sex: string;
|
||||
avatar: string;
|
||||
status: string;
|
||||
|
||||
@@ -65,7 +65,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
||||
componentProps: {
|
||||
placeholder: $t('authentication.mobile'),
|
||||
},
|
||||
fieldName: 'phoneNumber',
|
||||
fieldName: 'phone',
|
||||
label: $t('authentication.mobile'),
|
||||
rules: z
|
||||
.string()
|
||||
@@ -89,7 +89,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
||||
codeLength: CODE_LENGTH,
|
||||
placeholder: $t('authentication.code'),
|
||||
handleSendCode: async () => {
|
||||
const { valid, value } = await form.validateField('phoneNumber');
|
||||
const { valid, value } = await form.validateField('phone');
|
||||
if (!valid) {
|
||||
// 必须抛异常 不能直接return
|
||||
throw new Error('未填写手机号');
|
||||
@@ -114,7 +114,7 @@ async function handleLogin(values: LoginCodeParams) {
|
||||
try {
|
||||
const requestParams: any = {
|
||||
tenantId: values.tenantId,
|
||||
phonenumber: values.phoneNumber,
|
||||
phone: values.phone,
|
||||
smsCode: values.code,
|
||||
grantType: 'sms',
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ const [BasicForm, formApi] = useVbenForm({
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'phonenumber',
|
||||
fieldName: 'phone',
|
||||
label: '电话',
|
||||
rules: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的电话'),
|
||||
},
|
||||
@@ -106,7 +106,7 @@ onMounted(() => {
|
||||
'userId',
|
||||
'nick',
|
||||
'email',
|
||||
'phonenumber',
|
||||
'phone',
|
||||
'sex',
|
||||
]);
|
||||
formApi.setValues(data);
|
||||
|
||||
@@ -61,7 +61,7 @@ const poetrySrc = computed(() => {
|
||||
{{ profile.user.userName }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="手机号码">
|
||||
{{ profile.user.phonenumber || '未绑定手机号' }}
|
||||
{{ profile.user.phone || '未绑定手机号' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="邮箱">
|
||||
{{ profile.user.email || '未绑定邮箱' }}
|
||||
|
||||
@@ -9,7 +9,7 @@ export const querySchema: FormSchemaGetter = () => [
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'phonenumber',
|
||||
fieldName: 'phone',
|
||||
label: '手机号码',
|
||||
},
|
||||
];
|
||||
@@ -30,7 +30,7 @@ export const columns: VxeGridProps['columns'] = [
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
field: 'phonenumber',
|
||||
field: 'phone',
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
|
||||
@@ -308,7 +308,7 @@ function handleSubmit() {
|
||||
<div class="flex flex-col items-baseline text-[12px]">
|
||||
<div>{{ row.nick }}</div>
|
||||
<div class="opacity-50">
|
||||
{{ row.phonenumber || '暂无手机号' }}
|
||||
{{ row.phone || '暂无手机号' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -340,7 +340,7 @@ function handleSubmit() {
|
||||
{{ row.nick }}
|
||||
</div>
|
||||
<div class="opacity-50">
|
||||
{{ row.phonenumber || '暂无手机号' }}
|
||||
{{ row.phone || '暂无手机号' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -48,7 +48,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
submit: [{ code: string; phoneNumber: string; tenantId: string }];
|
||||
submit: [{ code: string; phone: string; tenantId: string }];
|
||||
}>();
|
||||
|
||||
const router = useRouter();
|
||||
@@ -71,7 +71,7 @@ async function handleSubmit() {
|
||||
emit('submit', {
|
||||
tenantId: values?.tenantId,
|
||||
code: values?.code,
|
||||
phoneNumber: values?.phoneNumber,
|
||||
phone: values?.phone,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ interface LoginAndRegisterParams {
|
||||
interface LoginCodeParams {
|
||||
tenantId: string;
|
||||
code: string;
|
||||
phoneNumber: string;
|
||||
phone: string;
|
||||
}
|
||||
|
||||
interface LoginEmits {
|
||||
|
||||
@@ -15,7 +15,7 @@ const loading = ref(false);
|
||||
const CODE_LENGTH = 6;
|
||||
const loginRef =
|
||||
useTemplateRef<InstanceType<typeof AuthenticationCodeLogin>>('loginRef');
|
||||
function sendCodeApi(phoneNumber: string) {
|
||||
function sendCodeApi(phone: string) {
|
||||
message.loading({
|
||||
content: $t('page.auth.sendingCode'),
|
||||
duration: 0,
|
||||
@@ -24,11 +24,11 @@ function sendCodeApi(phoneNumber: string) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
message.success({
|
||||
content: $t('page.auth.codeSentTo', [phoneNumber]),
|
||||
content: $t('page.auth.codeSentTo', [phone]),
|
||||
duration: 3,
|
||||
key: 'sending-code',
|
||||
});
|
||||
resolve({ code: '123456', phoneNumber });
|
||||
resolve({ code: '123456', phone });
|
||||
}, 3000);
|
||||
});
|
||||
}
|
||||
@@ -39,7 +39,7 @@ const formSchema = computed((): VbenFormSchema[] => {
|
||||
componentProps: {
|
||||
placeholder: $t('authentication.mobile'),
|
||||
},
|
||||
fieldName: 'phoneNumber',
|
||||
fieldName: 'phone',
|
||||
label: $t('authentication.mobile'),
|
||||
rules: z
|
||||
.string()
|
||||
@@ -68,14 +68,14 @@ const formSchema = computed((): VbenFormSchema[] => {
|
||||
loading.value = false;
|
||||
throw new Error('formApi is not ready');
|
||||
}
|
||||
await formApi.validateField('phoneNumber');
|
||||
const isPhoneReady = await formApi.isFieldValid('phoneNumber');
|
||||
await formApi.validateField('phone');
|
||||
const isPhoneReady = await formApi.isFieldValid('phone');
|
||||
if (!isPhoneReady) {
|
||||
loading.value = false;
|
||||
throw new Error('Phone number is not Ready');
|
||||
}
|
||||
const { phoneNumber } = await formApi.getValues();
|
||||
await sendCodeApi(phoneNumber);
|
||||
const { phone } = await formApi.getValues();
|
||||
await sendCodeApi(phone);
|
||||
loading.value = false;
|
||||
},
|
||||
placeholder: $t('authentication.code'),
|
||||
|
||||
@@ -18,7 +18,7 @@ const [Form] = useVbenForm({
|
||||
},
|
||||
labelClass: 'w-2/6',
|
||||
},
|
||||
fieldMappingTime: [['field4', ['phoneType', 'phoneNumber'], null]],
|
||||
fieldMappingTime: [['field4', ['phoneType', 'phone'], null]],
|
||||
// 提交函数
|
||||
handleSubmit: onSubmit,
|
||||
// 垂直布局,label和input在不同行,值为vertical
|
||||
|
||||
Reference in New Issue
Block a user