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.

147 lines
4.0 KiB

<!--
* @Author: your name
* @Date: 2021-10-19 14:45:23
* @LastEditTime: 2021-10-19 16:25:16
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /data-show/src/views/Login/forgetPWD/index.vue
-->
<template>
<div class="fpwd-outter">
<span class="fpw-label">忘记密码</span>
<a-form-model layout="horizontal" :model="form" :rules="rules" ref="forgetForm">
<a-form-model-item label="手机号码" prop="phone">
<a-input v-model="form.phone" placeholder="手机号码" />
</a-form-model-item>
<a-form-model-item label="验证码" prop="code">
<a-input v-model="form.code" placeholder="验证码">
<span class="fp-s1" slot="suffix" v-if="showCode" @click="countdown">发送验证码</span>
<span class="fp-s1" slot="suffix" v-else>{{count}}</span>
</a-input>
</a-form-model-item>
</a-form-model>
<div class="fpw-d1">
<span class="ss1" @click="reLogin">想起来了,去登录</span>
</div>
<div class="fpwd-footer" @click="onNext">
</div>
</div>
</template>
<script>
export default {
name: "forgetPWD",
data() {
const validatePhone = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入手机号"));
} else {
let reg = /^1\d{10}$/;
if (!reg.test(value)) {
callback(new Error("请输入正确的手机号"));
} else {
callback();
}
}
};
const validateCode = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入验证码"));
} else {
callback();
}
};
return {
showCode: true,
timer: null,
count: 0,
form: {
phone: "",
code: "",
},
rules: {
phone: [{ validator: validatePhone, trigger: "change" }],
code: [{ validator: validateCode, trigger: "change" }],
},
};
},
methods: {
// 倒计时
countdown() {
const TIME_COUNT = 60;
if (!this.timer) {
this.count = TIME_COUNT;
this.showCode = false;
this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) {
this.count--;
} else {
this.showCode = true;
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
}
},
// 返回登录
reLogin() {
this.$emit("reLogin");
},
// 下一步
onNext() {
this.$refs.forgetForm.validate((valid) => {
if (valid) {
alert("submit!");
} else {
console.log("error submit!!");
return false;
}
});
}
},
};
</script>
<style lang="less" scoped>
.fpw-label {
display: block;
font-size: 36px;
color: #3373cc;
font-weight: bold;
text-align: center;
width: 100%;
margin-bottom: 20px;
}
.fpwd-outter {
width: 380px;
margin: 0 auto;
margin-top: 80px;
}
.fp-s1 {
cursor: pointer;
color: #698198;
}
.fpw-d1 {
.ss1 {
color: #3373cc;
font-size: 16px;
cursor: pointer;
}
}
.fpwd-footer {
position: absolute;
width: 354px;
height: 64px;
background-image: url("../../../assets/images/login/img_dlan_nor.png");
bottom: 0px;
left: 50%;
transform: translate(-50%);
cursor: pointer;
color: #63aecc;
font-size: 24px;
text-align: center;
line-height: 64px;
}
</style>