111
This commit is contained in:
@@ -22,18 +22,14 @@
|
|||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const emit = defineEmits(['submit-email-code'])
|
const emit = defineEmits(['submit-email-code', 'resend-email-code'])
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
email: { type: String, required: true },
|
email: { type: String, required: true },
|
||||||
type: {
|
|
||||||
type: String as () => 'LOGIN' | 'REGISTER' | 'FORGET_PWD',
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
password: { type: String, default: '' },
|
password: { type: String, default: '' },
|
||||||
isShowOtherLogin: { type: Boolean, default: true }
|
isShowOtherLogin: { type: Boolean, default: true }
|
||||||
})
|
})
|
||||||
const code = ref('')
|
const code = ref('')
|
||||||
const time = ref(60)
|
const time = ref(0)
|
||||||
const timeStr = computed(() => CountDown(time.value))
|
const timeStr = computed(() => CountDown(time.value))
|
||||||
const timeout = ref(null)
|
const timeout = ref(null)
|
||||||
const setTime = (s = 120) => {
|
const setTime = (s = 120) => {
|
||||||
@@ -55,7 +51,8 @@
|
|||||||
clearTime()
|
clearTime()
|
||||||
})
|
})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
onSendCode()
|
// onSendCode()
|
||||||
|
setTime()
|
||||||
})
|
})
|
||||||
const inputCodeRef = ref(null)
|
const inputCodeRef = ref(null)
|
||||||
const resetCode = () => {
|
const resetCode = () => {
|
||||||
@@ -68,19 +65,9 @@
|
|||||||
console.warn('请输入邮箱')
|
console.warn('请输入邮箱')
|
||||||
return Promise.reject('请输入邮箱')
|
return Promise.reject('请输入邮箱')
|
||||||
}
|
}
|
||||||
// const data = {
|
emit('resend-email-code', () => {
|
||||||
// email,
|
setTime()
|
||||||
// type: props.type
|
})
|
||||||
// }
|
|
||||||
// if (props.type === 'LOGIN') {
|
|
||||||
// data['password'] = md5(props.password)
|
|
||||||
// }
|
|
||||||
// const res = await SendVerificationCode(data)
|
|
||||||
// if (!res) {
|
|
||||||
// ElMessage.error(t('Login.sendCodeError'))
|
|
||||||
// return Promise.reject('发送验证码失败')
|
|
||||||
// }
|
|
||||||
setTime()
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
const onResend = () => {
|
const onResend = () => {
|
||||||
|
|||||||
@@ -43,11 +43,11 @@
|
|||||||
@login="onLogin"
|
@login="onLogin"
|
||||||
@register="onRegister"
|
@register="onRegister"
|
||||||
@submit-email-code="onSubmitEmailCode"
|
@submit-email-code="onSubmitEmailCode"
|
||||||
|
@resend-email-code="onResendEmailCode"
|
||||||
@back="onBack"
|
@back="onBack"
|
||||||
:name="data.name"
|
:name="data.name"
|
||||||
:email="data.email"
|
:email="data.email"
|
||||||
:password="data.password"
|
:password="data.password"
|
||||||
type="FORGET_PWD"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -128,26 +128,24 @@
|
|||||||
myEvent.remove('openLoginDialog', open)
|
myEvent.remove('openLoginDialog', open)
|
||||||
})
|
})
|
||||||
|
|
||||||
const onLogin = (res: any) => {
|
const onLogin = async (res: any) => {
|
||||||
AccountSendLoginCode({
|
await AccountSendLoginCode({
|
||||||
email: res.email,
|
email: res.email,
|
||||||
password: md5(res.password)
|
password: md5(res.password)
|
||||||
}).then((v) => {
|
|
||||||
data.value = res
|
|
||||||
data.value.type = TabNames.login
|
|
||||||
currentTab.value = TabNames.email_verify
|
|
||||||
})
|
})
|
||||||
|
data.value = res
|
||||||
|
data.value.type = TabNames.login
|
||||||
|
currentTab.value = TabNames.email_verify
|
||||||
}
|
}
|
||||||
const onRegister = (res: any) => {
|
const onRegister = async (res: any) => {
|
||||||
const value = {
|
const value = {
|
||||||
email: res.email,
|
email: res.email,
|
||||||
operationType: 'REGISTER'
|
operationType: 'REGISTER'
|
||||||
}
|
}
|
||||||
AccountSendVerifyCode(value).then((v) => {
|
await AccountSendVerifyCode(value)
|
||||||
data.value = res
|
data.value = res
|
||||||
data.value.type = TabNames.register
|
data.value.type = TabNames.register
|
||||||
currentTab.value = TabNames.email_verify
|
currentTab.value = TabNames.email_verify
|
||||||
})
|
|
||||||
}
|
}
|
||||||
const onSubmitEmailCode = (code: string) => {
|
const onSubmitEmailCode = (code: string) => {
|
||||||
const value = {
|
const value = {
|
||||||
@@ -167,6 +165,14 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const onResendEmailCode = async (callback: () => void) => {
|
||||||
|
if (data.value.type === TabNames.login) {
|
||||||
|
await onLogin(data.value)
|
||||||
|
} else if (data.value.type === TabNames.register) {
|
||||||
|
await onRegister(data.value)
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<div class="verify-box" v-if="index === 1">
|
<div class="verify-box" v-if="index === 1">
|
||||||
<email-verify
|
<email-verify
|
||||||
type="FORGOT_PWD"
|
|
||||||
:email="formData.email"
|
:email="formData.email"
|
||||||
@submit-email-code="onVerifyCode"
|
@submit-email-code="onVerifyCode"
|
||||||
|
@resend-email-code="SendVerifyCode"
|
||||||
:is-show-other-login="false"
|
:is-show-other-login="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,10 +104,7 @@
|
|||||||
const onSubmit1 = () => {
|
const onSubmit1 = () => {
|
||||||
form1Ref.value?.validate?.((valid) => {
|
form1Ref.value?.validate?.((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
AccountSendVerifyCode({
|
SendVerifyCode().then(() => {
|
||||||
email: formData.email,
|
|
||||||
operationType: 'FORGOT_PWD'
|
|
||||||
}).then(() => {
|
|
||||||
index.value = 1
|
index.value = 1
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -115,12 +112,18 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const SendVerifyCode = async () => {
|
||||||
|
await AccountSendVerifyCode({
|
||||||
|
email: formData.email,
|
||||||
|
operationType: 'FORGET_PWD'
|
||||||
|
})
|
||||||
|
}
|
||||||
const onVerifyCode = (code: string) => {
|
const onVerifyCode = (code: string) => {
|
||||||
if (!code) return
|
if (!code) return
|
||||||
AccountVerifyCode({
|
AccountVerifyCode({
|
||||||
email: formData.email,
|
email: formData.email,
|
||||||
emailVerifyCode: code,
|
emailVerifyCode: code,
|
||||||
operationType: 'FORGOT_PWD'
|
operationType: 'FORGET_PWD'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
formData.code = code
|
formData.code = code
|
||||||
index.value = 2
|
index.value = 2
|
||||||
|
|||||||
Reference in New Issue
Block a user