开始设计验证手机号

This commit is contained in:
Linzm committed 2025-06-23 11:00:56 +08:00
1 parent 340b70f71e
commit e0e922b6d6
1 file changed
+31 -15
+31 -15
View File
@@ -88,8 +88,39 @@ function goToPreview() {
return return
} }
isLoading.value = true isLoading.value = true
if (trialCode.value) {
trialPhone()
} else {
getPid() getPid()
} }
}
const trialPhone = async () => {
if (!mobile.value) {
showToast('请输入手机号');
return;
}
const mobileReg = /^1[3-9]\d{9}$/;
if (!mobileReg.test(mobile.value)) {
showToast('请输入正确的手机号');
return;
}
await badgeApi.trialPhone({
phone: mobile.value
}).then((res: any) => {
const timestamp = Date.now()
const payload = JSON.stringify({ userId: res, timestamp })
userId.value = Encrypt(payload)
localStorage.set('userId', userId.value)
getPid()
}).catch((err) => {
showToast({
message: err.message,
duration: 2000,
})
}).finally(() => {
})
}
const picture = ref(null) const picture = ref(null)
function getbase64Data(data) { function getbase64Data(data) {
picture.value = data; picture.value = data;
@@ -348,21 +379,6 @@ const onBlur = async () => {
showToast('请输入正确的手机号'); showToast('请输入正确的手机号');
return; return;
} }
await badgeApi.trialPhone({
phone: mobile.value
}).then((res: any) => {
const timestamp = Date.now()
const payload = JSON.stringify({ userId: res, timestamp })
userId.value = Encrypt(payload)
localStorage.set('userId', userId.value)
}).catch((err) => {
showToast({
message: err.message,
duration: 2000,
})
}).finally(() => {
})
} }
const key = CryptoJS.enc.Utf8.parse("123abcdefpua2025"); const key = CryptoJS.enc.Utf8.parse("123abcdefpua2025");
const iv = CryptoJS.enc.Utf8.parse('DYgjCEIMVrj2W9xN'); const iv = CryptoJS.enc.Utf8.parse('DYgjCEIMVrj2W9xN');