BUG fix: send register code
This commit is contained in:
parent
5f417dd0c3
commit
78e62dd1b5
|
@ -1,8 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
|
||||||
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
|
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
|
||||||
// Using global notifications
|
|
||||||
import { useKUNGalgameMessageStore } from '@/store/modules/message'
|
import { useKUNGalgameMessageStore } from '@/store/modules/message'
|
||||||
const info = useKUNGalgameMessageStore()
|
const info = useKUNGalgameMessageStore()
|
||||||
|
|
||||||
|
@ -16,34 +15,32 @@ const isSending = ref(false)
|
||||||
|
|
||||||
const countdown = ref(0)
|
const countdown = ref(0)
|
||||||
|
|
||||||
const sendCode = () => {
|
watch(
|
||||||
// If the parent component passes a false value, return directly
|
() => props.isSendCode,
|
||||||
if (!props.isSendCode) {
|
async () => {
|
||||||
return
|
if (!isSending.value) {
|
||||||
|
isSending.value = true
|
||||||
|
countdown.value = 30
|
||||||
|
|
||||||
|
const countdownInterval = setInterval(() => {
|
||||||
|
countdown.value -= 1
|
||||||
|
if (countdown.value === 0) {
|
||||||
|
clearInterval(countdownInterval)
|
||||||
|
isSending.value = false
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
// Send the verification code
|
||||||
|
await useKUNGalgameUserStore().sendCode(props.email)
|
||||||
|
|
||||||
|
info.info('AlertInfo.code.code')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
)
|
||||||
if (!isSending.value) {
|
|
||||||
isSending.value = true
|
|
||||||
countdown.value = 30
|
|
||||||
|
|
||||||
const countdownInterval = setInterval(() => {
|
|
||||||
countdown.value -= 1
|
|
||||||
if (countdown.value === 0) {
|
|
||||||
clearInterval(countdownInterval)
|
|
||||||
isSending.value = false
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
// Send the verification code
|
|
||||||
useKUNGalgameUserStore().sendCode(props.email)
|
|
||||||
|
|
||||||
info.info('AlertInfo.code.code')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button @click="sendCode" :disabled="isSending">
|
<button :disabled="isSending">
|
||||||
{{ isSending ? countdown : $tm('login.register.send') }}
|
{{ isSending ? countdown : $tm('login.register.send') }}
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -110,15 +110,14 @@ const handleSendCode = () => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If human verification is not completed
|
if (isCaptureSuccessful.value) {
|
||||||
if (!isCaptureSuccessful.value) {
|
// Change isSendCode, because Code component use watch
|
||||||
|
isSendCode.value = !isSendCode.value
|
||||||
|
isCaptureSuccessful.value = false
|
||||||
|
} else {
|
||||||
// Show human verification
|
// Show human verification
|
||||||
isShowCapture.value = true
|
isShowCapture.value = true
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark that the code has been sent
|
|
||||||
isSendCode.value = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRegister = async () => {
|
const handleRegister = async () => {
|
||||||
|
|
Loading…
Reference in a new issue