Commit 521853ce authored by 杨梦雪's avatar 杨梦雪

11

parent 8e1749e3
...@@ -23,6 +23,7 @@ export function formatTime(data) { ...@@ -23,6 +23,7 @@ export function formatTime(data) {
export function intervalTime(startTime, endTime) { export function intervalTime(startTime, endTime) {
var stime = new Date(startTime); var stime = new Date(startTime);
var etime = new Date(endTime); var etime = new Date(endTime);
// console.log(stime,etime)
if(stime > etime){ if(stime > etime){
return add0(0)+':'+add0(0) return add0(0)+':'+add0(0)
} }
......
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
></el-input> ></el-input>
<!-- 短信验证码 --> <!-- 短信验证码 -->
<div class="phoneCode"> <div class="phoneCode">
<span class="code" v-show="show" @click="getCode" <span class="code" v-show="showCode" @click="getCode"
>获取验证码</span >获取验证码</span
> >
<span v-show="!show" class="count">{{ codeTime }} s</span> <span v-show="!showCode" class="count">{{ count }} s</span>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
...@@ -86,7 +86,9 @@ ...@@ -86,7 +86,9 @@
import { passwordCode } from "r/index/register"; import { passwordCode } from "r/index/register";
import { changePassCode } from "r/index/login"; import { changePassCode } from "r/index/login";
import { mobileCheck } from "@/common/utils.js"; import { mobileCheck } from "@/common/utils.js";
import {parseTime} from "common/utils"; import { parseTime } from "common/utils";
import { intervalTime } from "store/time";
import { timeSpan } from "common/utils";
export default { export default {
name: "index-reset", name: "index-reset",
...@@ -100,11 +102,11 @@ export default { ...@@ -100,11 +102,11 @@ export default {
}; };
return { return {
// 手机验证短信 // 手机验证短信
show: true, showCode: true,
count: "", count: "",
timer: null, timer: null,
isShowPwd: true, // 控制密码显示隐藏 isShowPwd: true, // 控制密码显示隐藏
codeTime:'',//手机验证码倒计时时间 codeTime: "", //手机验证码倒计时时间
resetForm: { resetForm: {
phone: "", phone: "",
code: "", code: "",
...@@ -155,12 +157,10 @@ export default { ...@@ -155,12 +157,10 @@ export default {
{ {
trigger: "blur", trigger: "blur",
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
var passwordreg =/^[a-zA-Z0-9]{6,12}$/ var passwordreg = /^[a-zA-Z0-9]{6,12}$/;
// /(?=.*\d)(?=.*[a-zA-Z]).{6,12}/; // /(?=.*\d)(?=.*[a-zA-Z]).{6,12}/;
if (!passwordreg.test(value)) { if (!passwordreg.test(value)) {
callback( callback(new Error("请输入6-12位,包含数字/字母,"));
new Error("请输入6-12位,包含数字/字母,")
);
} else { } else {
callback(); callback();
} }
...@@ -193,34 +193,56 @@ export default { ...@@ -193,34 +193,56 @@ export default {
if (!this.resetForm.phone) { if (!this.resetForm.phone) {
return this.$message.error("请输入手机号"); return this.$message.error("请输入手机号");
} }
// 接口获得验证码
passwordCode({
phone: this.resetForm.phone,
}).then((res) => {
console.log(res, "passwordCode");
if (res.data.code != 200) {
return this.$message.error(res.data.message);
}
this.$message.success(res.data.message);
// this.codeTime = parseTime(res.data.data.now);
this.codeTime = res.data.data.now * 1000;
window.localStorage.setItem("codeTime", this.codeTime);
this.time(this.codeTime);
});
},
time(code) {
let nowdata = new Date().getTime();
// console.log(nowdata);
let codeTime = code;
// console.log(codeTime);
let time = intervalTime(nowdata, codeTime);
console.log(time, "time");
// var min = time.split(":")[1];
// var sec = time.split(":")[2];
// let s = Number(min * 60) + Number(sec);
// console.log(s); //130
// let aa = timeSpan(nowdata, codeTime);
// 倒计时60s // 倒计时60s
const TIME_COUNT = 60; const TIME_COUNT = 60;
if (!this.timer) { if (!this.timer) {
this.count = TIME_COUNT; this.count = TIME_COUNT;
this.show = false; this.showCode = false;
this.timer = setInterval(() => { this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) { if (
this.count > 0 &&
this.count <= TIME_COUNT &&
nowdata < codeTime&&
codeTime
) {
this.count--; this.count--;
} else { } else {
this.show = true; this.showCode = true;
clearInterval(this.timer); clearInterval(this.timer);
this.timer = null; this.timer = null;
} }
}, 1000); }, 1000);
} }
// 接口获得验证码
passwordCode({
phone: this.resetForm.phone,
}).then((res) => {
console.log(res,'passwordCode');
if (res.data.code != 200) {
return this.$message.error(res.data.message);
}
this.$message.success(res.data.message);
this.codeTime=parseTime(res.data.data.now)
});
}, },
// 表单验证 // 表单验证
submitForm() { submitForm() {
this.$refs["resetFormRef"].validate((valid) => { this.$refs["resetFormRef"].validate((valid) => {
...@@ -371,14 +393,14 @@ export default { ...@@ -371,14 +393,14 @@ export default {
height: 20px; height: 20px;
font-size: 22px; font-size: 22px;
font-weight: 500; font-weight: 500;
color:var(--color); color: var(--color);
line-height: 20px; line-height: 20px;
} }
.line { .line {
width: 83px; width: 83px;
height: 3px; height: 3px;
background:var(--color); background: var(--color);
border-radius: 2px; border-radius: 2px;
} }
...@@ -407,7 +429,7 @@ export default { ...@@ -407,7 +429,7 @@ export default {
.code { .code {
font-size: 14px; font-size: 14px;
font-weight: 600; font-weight: 600;
color:var(--color); color: var(--color);
} }
} }
...@@ -448,7 +470,7 @@ export default { ...@@ -448,7 +470,7 @@ export default {
.el-button { .el-button {
width: 100%; width: 100%;
height: 60px; height: 60px;
background:var(--color); background: var(--color);
border-radius: 4px; border-radius: 4px;
opacity: 0.8; opacity: 0.8;
line-height: 50px; line-height: 50px;
......
...@@ -16,7 +16,6 @@ module.exports = { ...@@ -16,7 +16,6 @@ module.exports = {
.set('r', resolve('src/request')) .set('r', resolve('src/request'))
.set('config', resolve('src/config')) .set('config', resolve('src/config'))
.set('common', resolve('src/common')) .set('common', resolve('src/common'))
.set('store', resolve('src/store')) .set('store', resolve('src/store'))
}, },
// devServer: { // devServer: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment