From 6936835a1a6c65271ecd925112671d5b54e6fe19 Mon Sep 17 00:00:00 2001 From: zjl Date: Mon, 16 Dec 2024 14:56:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95=E3=80=81?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login/LoginForm.vue | 30 +++++++++++++++++++++++++++--- src/views/login/PhoneForm.vue | 10 +++------- src/views/login/index.vue | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/views/login/LoginForm.vue b/src/views/login/LoginForm.vue index 765c2e6..ce8bf19 100644 --- a/src/views/login/LoginForm.vue +++ b/src/views/login/LoginForm.vue @@ -104,20 +104,29 @@ const captchaImg = ref(''); // 动态加载滑块验证码组件 + /** + * 定义表单参数 + */ interface FormState { username: string; password: string; code: string; key: string; } + + /** + * 定义参数 + */ const message = useMessage(); const emit = defineEmits(['backLogin']); const formRef = ref(); - const loading = ref(false); const autoLogin = ref(true); const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME; + /** + * 定义表单提交参数 + */ const formInline = reactive({ username: '', password: '', @@ -125,16 +134,21 @@ key: '', }); + /** + * 定义验证规则 + */ const rules: FormRules = { username: { required: true, message: '请输入登录账号', trigger: 'blur' }, password: { required: true, message: '请输入密码', trigger: 'blur' }, code: { required: true, message: '请输入验证码', trigger: 'blur' }, }; - const userStore = useUserStore(); + /** + * 执行表单提交 + */ + const userStore = useUserStore(); const router = useRouter(); const route = useRoute(); - const handleSubmit = () => { if (!formRef.value) return; formRef.value @@ -171,15 +185,25 @@ }); }; + /** + * 获取验证码 + */ const getCaptcha = async () => { let { key, captcha } = await getInfoCaptcha(); formInline.key = key; captchaImg.value = captcha; }; + + /** + * 执行去注册 + */ const goRegister = () => { emit('backLogin', false); }; + /** + * 获取验证码 + */ getCaptcha(); diff --git a/src/views/login/PhoneForm.vue b/src/views/login/PhoneForm.vue index 1f904a7..e147ed9 100644 --- a/src/views/login/PhoneForm.vue +++ b/src/views/login/PhoneForm.vue @@ -54,6 +54,9 @@ const captchaImg = ref(''); // 动态加载滑块验证码组件 + /** + * 定义表单参数 + */ interface FormState { username: string; password: string; @@ -154,13 +157,6 @@ } }); }; - - const getCaptcha = async () => { - let { key, captcha } = await getInfoCaptcha(); - formInline.key = key; - captchaImg.value = captcha; - }; - getCaptcha();