Skip to content

Commit 2735dcf

Browse files
committed
fix: 补充重构邮箱登录后遗漏的行为验证码
1 parent 449e512 commit 2735dcf

File tree

2 files changed

+39
-23
lines changed

2 files changed

+39
-23
lines changed

src/views/login/components/email/index.vue

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@
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'
3642
import { type FormInstance, Message } from '@arco-design/web-vue'
43+
import type { BehaviorCaptchaReq } from '@/apis'
44+
// import { type BehaviorCaptchaReq, getEmailCaptcha } from '@/apis'
3745
import { useTabsStore, useUserStore } from '@/stores'
3846
import * 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+
81102
const captchaTimer = ref()
82103
const captchaTime = ref(60)
83104
const 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)`

src/views/login/components/phone/index.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@
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>
32-
<Verify
33-
ref="VerifyRef"
34-
:captcha-type="captchaType"
35-
:mode="captchaMode"
36-
:img-size="{ width: '330px', height: '155px' }"
37-
@success="getCaptcha"
38-
/>
3939
</template>
4040

4141
<script setup lang="ts">
42-
// import { getSmsCaptcha } from '@/apis'
4342
import { type FormInstance, Message } from '@arco-design/web-vue'
43+
import type { BehaviorCaptchaReq } from '@/apis'
44+
// import { type BehaviorCaptchaReq, getSmsCaptcha } from '@/apis'
4445
import { useTabsStore, useUserStore } from '@/stores'
4546
import * as Regexp from '@/utils/regexp'
4647
@@ -71,7 +72,7 @@ const handleLogin = async () => {
7172
await userStore.phoneLogin(form)
7273
tabsStore.reset()
7374
const { redirect, ...othersQuery } = router.currentRoute.value.query
74-
router.push({
75+
await router.push({
7576
path: (redirect as string) || '/',
7677
query: {
7778
...othersQuery,
@@ -110,13 +111,12 @@ const resetCaptcha = () => {
110111
}
111112
112113
// 获取验证码
113-
const getCaptcha = async () => {
114+
// eslint-disable-next-line unused-imports/no-unused-vars
115+
const getCaptcha = async (captchaReq: BehaviorCaptchaReq) => {
114116
try {
115117
captchaLoading.value = true
116118
captchaBtnName.value = '发送中...'
117-
// await getSmsCaptcha({
118-
// phone: form.phone
119-
// })
119+
// await getSmsCaptcha(form.phone, captchaReq)
120120
captchaLoading.value = false
121121
captchaDisable.value = true
122122
captchaBtnName.value = `获取验证码(${(captchaTime.value -= 1)}s)`

0 commit comments

Comments
 (0)