2828 <a-button disabled class =" btn" type =" primary" :loading =" loading" html-type =" submit" size =" large" long >立即登录</a-button >
2929 </a-space >
3030 </a-form-item >
31+ <Verify
32+ ref =" VerifyRef"
33+ :captcha-type =" captchaType"
34+ :mode =" captchaMode"
35+ :img-size =" { width: '330px', height: '155px' }"
36+ @success =" getCaptcha"
37+ />
3138 </a-form >
3239</template >
3340
3441<script setup lang="ts">
35- // import { getEmailCaptcha } from '@/apis'
3642import { type FormInstance , Message } from ' @arco-design/web-vue'
43+ import type { BehaviorCaptchaReq } from ' @/apis'
44+ // import { type BehaviorCaptchaReq, getEmailCaptcha } from '@/apis'
3745import { useTabsStore , useUserStore } from ' @/stores'
3846import * as Regexp from ' @/utils/regexp'
3947
@@ -64,7 +72,7 @@ const handleLogin = async () => {
6472 await userStore .emailLogin (form )
6573 tabsStore .reset ()
6674 const { redirect, ... othersQuery } = router .currentRoute .value .query
67- router .push ({
75+ await router .push ({
6876 path: (redirect as string ) || ' /' ,
6977 query: {
7078 ... othersQuery ,
@@ -78,6 +86,19 @@ const handleLogin = async () => {
7886 }
7987}
8088
89+ const VerifyRef = ref <InstanceType <any >>()
90+ const captchaType = ref (' blockPuzzle' )
91+ const captchaMode = ref (' pop' )
92+ const captchaLoading = ref (false )
93+
94+ // 弹出行为验证码
95+ const onCaptcha = async () => {
96+ if (captchaLoading .value ) return
97+ const isInvalid = await formRef .value ?.validateField (' email' )
98+ if (isInvalid ) return
99+ VerifyRef .value .show ()
100+ }
101+
81102const captchaTimer = ref ()
82103const captchaTime = ref (60 )
83104const captchaBtnName = ref (' 获取验证码' )
@@ -90,18 +111,13 @@ const resetCaptcha = () => {
90111 captchaDisable .value = false
91112}
92113
93- const captchaLoading = ref (false )
94114// 获取验证码
95- const onCaptcha = async () => {
96- if (captchaLoading .value ) return
97- const isInvalid = await formRef .value ?.validateField (' email' )
98- if (isInvalid ) return
115+ // eslint-disable-next-line unused-imports/no-unused-vars
116+ const getCaptcha = async (captchaReq : BehaviorCaptchaReq ) => {
99117 try {
100118 captchaLoading .value = true
101119 captchaBtnName .value = ' 发送中...'
102- // await getEmailCaptcha({
103- // email: form.email
104- // })
120+ // await getEmailCaptcha(form.email, captchaReq)
105121 captchaLoading .value = false
106122 captchaDisable .value = true
107123 captchaBtnName .value = ` 获取验证码(${(captchaTime .value -= 1 )}s) `
0 commit comments