|
@@ -24,10 +24,13 @@ const safeAreaInsets = systemInfo.safeAreaInsets
|
|
// 表单数据
|
|
// 表单数据
|
|
const formData = ref({
|
|
const formData = ref({
|
|
name: '',
|
|
name: '',
|
|
|
|
+ // phone 存储不带区号的手机号数字部分
|
|
phone: '',
|
|
phone: '',
|
|
verifyCode: '',
|
|
verifyCode: '',
|
|
pwd: '',
|
|
pwd: '',
|
|
code: '',
|
|
code: '',
|
|
|
|
+ // 固定区号入参
|
|
|
|
+ areaCode: '88',
|
|
})
|
|
})
|
|
|
|
|
|
// 验证码倒计时
|
|
// 验证码倒计时
|
|
@@ -36,16 +39,17 @@ const countdownTimer = ref<any>(null)
|
|
|
|
|
|
// 获取验证码
|
|
// 获取验证码
|
|
async function getVerificationCode() {
|
|
async function getVerificationCode() {
|
|
- // 验证手机号
|
|
|
|
|
|
+ // 验证手机号(不包含区号,固定 +88)
|
|
if (!formData.value.phone.trim()) {
|
|
if (!formData.value.phone.trim()) {
|
|
toast.error(t('auth.register.error.emptyPhone'))
|
|
toast.error(t('auth.register.error.emptyPhone'))
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- // 验证手机号格式
|
|
|
|
- const phoneRegex = /^1[3-9]\d{9}$/
|
|
|
|
- if (!phoneRegex.test(formData.value.phone)) {
|
|
|
|
- toast.error(t('auth.register.error.emptyPhone'))
|
|
|
|
|
|
+ // 孟加拉手机号校验:可接受本地格式 01xxxxxxxxx (11 位) 或去掉前导 0 的 1xxxxxxxxx (10 位)
|
|
|
|
+ const phoneDigits = formData.value.phone.replace(/\D/g, '')
|
|
|
|
+ const bdPhoneRegex = /^0?1\d{9}$/
|
|
|
|
+ if (!bdPhoneRegex.test(phoneDigits)) {
|
|
|
|
+ toast.error(t('auth.register.error.invalidPhone'))
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -100,7 +104,9 @@ async function handleRegister() {
|
|
// 调用注册接口
|
|
// 调用注册接口
|
|
const registerData = {
|
|
const registerData = {
|
|
name: formData.value.name,
|
|
name: formData.value.name,
|
|
|
|
+ // 发送时附带区号字段areaCode,phone字段为不带区号的手机号
|
|
phone: formData.value.phone,
|
|
phone: formData.value.phone,
|
|
|
|
+ areaCode: formData.value.areaCode,
|
|
verifyCode: formData.value.verifyCode,
|
|
verifyCode: formData.value.verifyCode,
|
|
pwd: formData.value.pwd,
|
|
pwd: formData.value.pwd,
|
|
code: formData.value.code,
|
|
code: formData.value.code,
|
|
@@ -137,10 +143,11 @@ function validateForm() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- // 验证手机号格式
|
|
|
|
- const phoneRegex = /^1[3-9]\d{9}$/
|
|
|
|
- if (!phoneRegex.test(formData.value.phone)) {
|
|
|
|
- toast.error(t('auth.register.error.emptyPhone'))
|
|
|
|
|
|
+ // 孟加拉手机号校验:支持 01xxxxxxxxx 或 1xxxxxxxxx
|
|
|
|
+ const phoneDigits = formData.value.phone.replace(/\D/g, '')
|
|
|
|
+ const bdPhoneRegex = /^0?1\d{9}$/
|
|
|
|
+ if (!bdPhoneRegex.test(phoneDigits)) {
|
|
|
|
+ toast.error(t('auth.register.error.invalidPhone'))
|
|
resolve(false)
|
|
resolve(false)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -209,13 +216,18 @@ onUnmounted(() => {
|
|
no-border
|
|
no-border
|
|
custom-class="bandhu-auth-input-field"
|
|
custom-class="bandhu-auth-input-field"
|
|
/>
|
|
/>
|
|
- <wd-input
|
|
|
|
- v-model="formData.phone"
|
|
|
|
- prop="phone"
|
|
|
|
- :placeholder="t('auth.register.phone.placeholder')"
|
|
|
|
- no-border
|
|
|
|
- custom-class="bandhu-auth-input-field"
|
|
|
|
- />
|
|
|
|
|
|
+ <view class="bandhu-auth-input-field phone-input-wrapper" style="border: none; display:flex;align-items:center;">
|
|
|
|
+ <view class="phone-area-code" style="padding:0 8rpx;font-size:28rpx;color:#333">
|
|
|
|
+ +88
|
|
|
|
+ </view>
|
|
|
|
+ <wd-input
|
|
|
|
+ v-model="formData.phone"
|
|
|
|
+ prop="phone"
|
|
|
|
+ :placeholder="t('auth.register.phone.placeholder')"
|
|
|
|
+ no-border
|
|
|
|
+ custom-class="flex-1"
|
|
|
|
+ />
|
|
|
|
+ </view>
|
|
<view class="flex items-center gap-20rpx">
|
|
<view class="flex items-center gap-20rpx">
|
|
<wd-input
|
|
<wd-input
|
|
v-model="formData.verifyCode"
|
|
v-model="formData.verifyCode"
|