2
0

fix:注册界面及相关功能

This commit is contained in:
zhongzm
2024-11-29 09:04:06 +08:00
parent a3a6aeb40e
commit 650a180778
10 changed files with 222 additions and 33 deletions

View File

@@ -1,12 +1,13 @@
import { computed } from 'vue';
import { useCountDown, useLoading } from '@sa/hooks';
import { $t } from '@/locales';
import { REG_PHONE } from '@/constants/reg';
import {REG_EMAIL} from '@/constants/reg';
import {useAuthStore} from "@/store/modules/auth";
export function useCaptcha() {
const { loading, startLoading, endLoading } = useLoading();
const { count, start, stop, isCounting } = useCountDown(10);
const authStore = useAuthStore();
const label = computed(() => {
let text = $t('page.login.codeLogin.getCode');
@@ -23,14 +24,14 @@ export function useCaptcha() {
return text;
});
function isPhoneValid(phone: string) {
if (phone.trim() === '') {
function isEmailValid(email: string) {
if (email.trim() === '') {
$message?.error?.($t('form.phone.required'));
return false;
}
if (!REG_PHONE.test(phone)) {
if (!REG_EMAIL.test(email)) {
$message?.error?.($t('form.phone.invalid'));
return false;
@@ -38,17 +39,20 @@ export function useCaptcha() {
return true;
}
async function getCaptcha(phone: string) {
const valid = isPhoneValid(phone);
//获取验证码方法
async function getCaptcha(email: string) {
console.log(email)
//const valid = isPhoneValid(phone);
const valid = isEmailValid(email);
if (!valid || loading.value) {
return;
}
startLoading();
// request
await authStore.captcha(
email,
);
await new Promise(resolve => {
setTimeout(resolve, 500);
});