You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
moredoc/web/components/FormFindPasswordStepOne.vue

116 lines
3.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="com-form-find-password-step-one">
<el-form label-position="top" label-width="80px" :model="user">
<el-form-item label="电子邮箱">
<el-input
v-model="user.email"
placeholder="请输入您注册账户时的电子邮箱"
></el-input>
</el-form-item>
<el-form-item v-if="captcha.enable" label="验证码">
<div v-if="captcha.type == 'audio'">
<el-row :gutter="15">
<el-col :span="20">
<audio controls="controls" :src="captcha.captcha"></audio>
</el-col>
<el-col :span="4">
<el-tooltip placement="top" content="刷新语音验证码">
<el-button
icon="el-icon-refresh"
class="btn-audio-refresh"
@click="loadCaptcha"
></el-button>
</el-tooltip>
</el-col>
</el-row>
</div>
<div v-else>
<el-tooltip placement="right" content="点击可刷新验证码">
<img :src="captcha.captcha" class="pointer" @click="loadCaptcha" />
</el-tooltip>
</div>
<el-input v-model="user.captcha" placeholder="请输入验证码"></el-input>
</el-form-item>
<el-form-item>
<el-button
type="primary"
class="btn-block"
icon="el-icon-check"
@click="execFindPassword"
:loading="loading"
:disabled="disabled"
></el-button
>
<nuxt-link to="/register" title="" class="el-link el-link--default"
></nuxt-link
>
<nuxt-link
to="/login"
title="登录账户"
class="el-link el-link--default float-right"
></nuxt-link
>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { getUserCaptcha, findPasswordStepOne } from '~/api/user'
export default {
name: 'FormFindPasswordStepOne',
props: {
redirect: {
type: String,
default: '',
},
},
data() {
return {
user: {
email: '',
captcha: '',
captcha_id: '',
},
captcha: {
enable: false,
},
loading: false,
disabled: false,
}
},
created() {
this.loadCaptcha()
},
methods: {
async execFindPassword() {
this.loading = true
const res = await findPasswordStepOne(this.user)
if (res.status === 200) {
this.$message.success('')
this.disabled = true
} else {
this.loadCaptcha()
this.$message.error(res.data.message || '')
}
this.loading = false
},
async loadCaptcha() {
const res = await getUserCaptcha({ type: 'find_password', t: Date.now() })
if (res.data.enable) {
// 启用了验证码
this.user = {
...this.user,
captcha_id: res.data.id,
}
this.captcha = res.data
}
},
},
}
</script>
<style scoped>
.btn-audio-refresh {
vertical-align: -webkit-baseline-middle;
}
</style>