fix:bug解决
This commit is contained in:
@@ -4,11 +4,11 @@ import { fetchProfile } from '@/api/profile'
|
||||
import { useSmsCode } from '@/hooks/use-sms-code'
|
||||
import { SMS_CODE_SCENE } from '@/types/api'
|
||||
import { getErrorMessage } from '@/utils/api-error'
|
||||
import { isValidPhone, isValidSmsCode } from '@/utils/validate'
|
||||
import { isSamePhone, isValidPhone, isValidSmsCode, normalizePhoneDigits } from '@/utils/validate'
|
||||
import { verifyOldPhone } from './change-phone.api'
|
||||
|
||||
function maskPhone(phone: string): string {
|
||||
const digits = phone.replace(/\D/g, '')
|
||||
const digits = normalizePhoneDigits(phone)
|
||||
if (digits.length < 7) return phone
|
||||
return digits.replace(/(\d{3})\d{4}(\d+)/, '$1****$2')
|
||||
}
|
||||
@@ -38,27 +38,31 @@ export function useChangePhoneVerify() {
|
||||
}
|
||||
}
|
||||
|
||||
function ensureInputMatchesBoundPhone(): boolean {
|
||||
const bound = boundPhone.value.trim()
|
||||
if (!bound) {
|
||||
uni.showToast({ title: '正在加载账号手机号,请稍后', icon: 'none' })
|
||||
void loadBoundPhone()
|
||||
return false
|
||||
}
|
||||
if (!isValidPhone(phone.value)) {
|
||||
uni.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (!isSamePhone(phone.value, bound)) {
|
||||
uni.showToast({ title: '请输入当前账号绑定的原手机号', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function onSendCode() {
|
||||
if (!ensureInputMatchesBoundPhone()) return
|
||||
sendCode(phone.value)
|
||||
}
|
||||
|
||||
function onUnavailablePhone() {
|
||||
uni.showModal({
|
||||
title: '原手机号不可用',
|
||||
content: '如原手机号已停用,请联系在线客服协助处理。',
|
||||
confirmText: '联系客服',
|
||||
success: (res) => {
|
||||
if (!res.confirm) return
|
||||
uni.navigateTo({ url: '/pages/mine/support/index' })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function nextStep() {
|
||||
if (!isValidPhone(phone.value)) {
|
||||
uni.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!ensureInputMatchesBoundPhone()) return
|
||||
if (!isValidSmsCode(code.value)) {
|
||||
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
||||
return
|
||||
@@ -93,7 +97,6 @@ export function useChangePhoneVerify() {
|
||||
seconds,
|
||||
subtitle,
|
||||
onSendCode,
|
||||
onUnavailablePhone,
|
||||
nextStep,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user