|
@@ -1,5 +1,5 @@
|
|
<template>
|
|
<template>
|
|
- <div>
|
|
|
|
|
|
+ <div class="mt-3">
|
|
<v-form ref="emailRef" style="width: 100%;">
|
|
<v-form ref="emailRef" style="width: 100%;">
|
|
<v-text-field
|
|
<v-text-field
|
|
v-model="query.email"
|
|
v-model="query.email"
|
|
@@ -21,7 +21,8 @@
|
|
:rules="[v=> !!v || '请输入邮箱收到的验证码']"
|
|
:rules="[v=> !!v || '请输入邮箱收到的验证码']"
|
|
>
|
|
>
|
|
<template #append-inner>
|
|
<template #append-inner>
|
|
- <span class="login-code" @click="handleCode">{{ $t('login.getSmsCode') }}</span>
|
|
|
|
|
|
+ <span v-if="showCode" class="login-code" @click="handleCode">{{ $t('login.getSmsCode') }}</span>
|
|
|
|
+ <span v-else class="disable">{{ $t('login.retrieveAgain') }}{{ count }}s</span>
|
|
</template>
|
|
</template>
|
|
</v-text-field>
|
|
</v-text-field>
|
|
</v-form>
|
|
</v-form>
|
|
@@ -57,6 +58,14 @@
|
|
<v-btn color="primary" style="width: 100%;" @click="handleSubmit" :loading="loading">确认修改</v-btn>
|
|
<v-btn color="primary" style="width: 100%;" @click="handleSubmit" :loading="loading">确认修改</v-btn>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <Verify
|
|
|
|
+ v-if="props.openVerify"
|
|
|
|
+ ref="entEditPasswordVerify"
|
|
|
|
+ captchaType="blockPuzzle"
|
|
|
|
+ :imgSize="{ width: '400px', height: '200px' }"
|
|
|
|
+ mode="pop"
|
|
|
|
+ @success="verifySuccess"
|
|
|
|
+ />
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
@@ -65,17 +74,19 @@ import { ref, reactive, computed } from 'vue'
|
|
import { entResetPassword, getEmailCode } from '@/api/common/index'
|
|
import { entResetPassword, getEmailCode } from '@/api/common/index'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import Snackbar from '@/plugins/snackbar'
|
|
import { checkEmail } from '@/utils/validate'
|
|
import { checkEmail } from '@/utils/validate'
|
|
|
|
+import Verify from '@/components/Verifition'
|
|
|
|
+import { setCodeTime } from '@/utils/code'
|
|
import { useRouter } from 'vue-router'; const router = useRouter()
|
|
import { useRouter } from 'vue-router'; const router = useRouter()
|
|
|
|
|
|
-const emit = defineEmits(['cancel', 'getCode'])
|
|
|
|
|
|
+// const emit = defineEmits(['cancel'])
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
phone: {
|
|
phone: {
|
|
type: String,
|
|
type: String,
|
|
default: ''
|
|
default: ''
|
|
},
|
|
},
|
|
- captchaVerification: {
|
|
|
|
- type: String,
|
|
|
|
- default: ''
|
|
|
|
|
|
+ openVerify: { // 是否开启人机验证
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false
|
|
},
|
|
},
|
|
showCancelBtn: {
|
|
showCancelBtn: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
@@ -122,28 +133,58 @@ const confirmPassword = computed(() => {
|
|
// emit('cancel')
|
|
// emit('cancel')
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
+
|
|
|
|
+const showCode = ref(true)
|
|
|
|
+const count = ref(0)
|
|
|
|
+const timer = ref(null)
|
|
const handleCode = async () => {
|
|
const handleCode = async () => {
|
|
if (!query.email || !checkEmail(query.email)) {
|
|
if (!query.email || !checkEmail(query.email)) {
|
|
Snackbar.warning('请输入企业邮箱')
|
|
Snackbar.warning('请输入企业邮箱')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- emit('getCode')
|
|
|
|
|
|
+ if (props.openVerify && !captchaVerification.value) {
|
|
|
|
+ getCode()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
await getEmailCode(query.email)
|
|
await getEmailCode(query.email)
|
|
|
|
+ count.value = 60
|
|
|
|
+ setTime()
|
|
Snackbar.success('已发送验证码,请注意查看!')
|
|
Snackbar.success('已发送验证码,请注意查看!')
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const setTime = () => {
|
|
|
|
+ showCode.value = false
|
|
|
|
+ timer.value = setInterval(() => {
|
|
|
|
+ let number = count.value
|
|
|
|
+ if (number > 0 && number <= 60) {
|
|
|
|
+ count.value--
|
|
|
|
+ setCodeTime(number - 1)
|
|
|
|
+ } else {
|
|
|
|
+ showCode.value = true
|
|
|
|
+ clearInterval(timer.value)
|
|
|
|
+ timer.value = null
|
|
|
|
+ }
|
|
|
|
+ }, 1000)
|
|
|
|
+}
|
|
|
|
+const autoTimer = () => {
|
|
|
|
+ count.value = 0
|
|
|
|
+ if(!count.value) return
|
|
|
|
+ setTime()
|
|
|
|
+}
|
|
|
|
+autoTimer()
|
|
|
|
+
|
|
// 修改
|
|
// 修改
|
|
const handleSubmit = async () => {
|
|
const handleSubmit = async () => {
|
|
const emailValid = await emailRef.value.validate()
|
|
const emailValid = await emailRef.value.validate()
|
|
const passwordValid = await passwordRef.value.validate()
|
|
const passwordValid = await passwordRef.value.validate()
|
|
if (!emailValid.valid || !passwordValid.valid) return
|
|
if (!emailValid.valid || !passwordValid.valid) return
|
|
- if (!props.captchaVerification) {
|
|
|
|
- emit('getCode')
|
|
|
|
|
|
+ if (!captchaVerification.value) {
|
|
|
|
+ getCode()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
const data = {
|
|
const data = {
|
|
...query,
|
|
...query,
|
|
- captchaVerification: props.captchaVerification,
|
|
|
|
|
|
+ captchaVerification: captchaVerification.value,
|
|
}
|
|
}
|
|
loading.value = true
|
|
loading.value = true
|
|
// const api = props.isReset ? resetPassword : updatePassword
|
|
// const api = props.isReset ? resetPassword : updatePassword
|
|
@@ -153,12 +194,26 @@ const handleSubmit = async () => {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
router.push({ path: '/login', query: { entLogin: true } })
|
|
router.push({ path: '/login', query: { entLogin: true } })
|
|
}, 1000);
|
|
}, 1000);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ Snackbar.warning(error?.msg || error)
|
|
} finally {
|
|
} finally {
|
|
loading.value = false
|
|
loading.value = false
|
|
- // handleClose()
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+// 获取验证码
|
|
|
|
+const entEditPasswordVerify = ref()
|
|
|
|
+const getCode = async () => {
|
|
|
|
+ // 弹出验证码 // 已开启:则展示验证码;只有完成验证码的情况,才进行登录
|
|
|
|
+ entEditPasswordVerify.value.show()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const captchaVerification = ref(false)
|
|
|
|
+const verifySuccess = (params) => {
|
|
|
|
+ captchaVerification.value = params.captchaVerification
|
|
|
|
+ handleCode()
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
@@ -169,4 +224,13 @@ const handleSubmit = async () => {
|
|
font-size: 12px;
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
+.disable {
|
|
|
|
+ width: 72px;
|
|
|
|
+ color: grey;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+}
|
|
|
|
+.phone-number {
|
|
|
|
+ width: 34px;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|