Commit 546ff08a authored by 杨梦雪's avatar 杨梦雪
parents 0aa4df0d 803edfa1
......@@ -10,30 +10,28 @@ export function djTime(data) {
}
export function formatTime(data) {
var time = new Date(data);
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var ss = time.getSeconds();
let time = new Date(data);
let y = time.getFullYear();
let m = time.getMonth() + 1;
let d = time.getDate();
let h = time.getHours();
let mm = time.getMinutes();
let ss = time.getSeconds();
return (y + "-" + add0(m) + "-" + add0(d) + " " + add0(h) + ":" + add0(mm) + ":" + add0(ss));
}
//计算两个时间之间的时间差 多少天时分
//计算两个时间之间的时间差-多少
export function intervalTime(startTime, endTime) {
var stime = new Date(startTime);
var etime = new Date(endTime);
// console.log(stime,etime)
let stime = new Date(startTime);
let etime = new Date(endTime);
if(stime > etime){
return add0(0)+':'+add0(0)
}
var y = etime.getFullYear() - stime.getFullYear();
var m = etime.getMonth() + 1 - (stime.getMonth() + 1);
var d = etime.getDate() - stime.getDate();
var h = etime.getHours() - stime.getHours();
var mm = etime.getMinutes() - stime.getMinutes();
var ss = etime.getSeconds() - stime.getSeconds();
var time = y*365*24*60*60 + m*30*24*60*60 + d*24*60*60 + h*60*60 + mm*60 + ss
time = add0(parseInt(time/60))+':'+add0(time%60)
let y = etime.getFullYear() - stime.getFullYear();
let m = etime.getMonth() + 1 - (stime.getMonth() + 1);
let d = etime.getDate() - stime.getDate();
let h = etime.getHours() - stime.getHours();
let mm = etime.getMinutes() - stime.getMinutes();
let ss = etime.getSeconds() - stime.getSeconds();
let time = y*365*24*60*60 + m*30*24*60*60 + d*24*60*60 + h*60*60 + mm*60 + ss
return time;
}
......@@ -86,6 +86,7 @@
import { registerCode, setAccountInfo } from "r/index/register";
import { mobileCheck, checkStrong } from "@/common/utils.js";
import { validatePassword } from "@/common/validator";
import { intervalTime } from "store/time";
export default {
name: "index-register",
......@@ -177,7 +178,12 @@ export default {
};
},
created() {
// this.$emit("getStatus", false);
const endTime = window.localStorage.getItem('register_code_time');
const phone = window.localStorage.getItem('register_code_phone');
if(endTime && Number(endTime)>new Date().getTime()){
this.registerForm.phone = phone;
this.intervalHandle(new Date(),Number(endTime));
}
},
methods: {
// 去注册
......@@ -188,18 +194,16 @@ export default {
changePwdStatus() {
this.isShowPwd = !this.isShowPwd;
},
// 获取手机验证短信
getCode() {
if (!this.registerForm.phone) {
return this.$message.error("请输入手机号");
}
// 倒计时60s
const TIME_COUNT = 60;
// 定时器倒计时
intervalHandle(startTime, endTime){
// 时间差
const timeLag = intervalTime(startTime, endTime);
console.log(timeLag)
if (!this.timer) {
this.count = TIME_COUNT;
this.count = timeLag;
this.show = false;
this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) {
if (this.count > 0 && this.count <= timeLag) {
this.count--;
} else {
this.show = true;
......@@ -208,6 +212,12 @@ export default {
}
}, 1000);
}
},
// 获取手机验证短信
getCode() {
if (!this.registerForm.phone) {
return this.$message.error("请输入手机号");
}
// 接口获得验证码
registerCode({
phone: this.registerForm.phone,
......@@ -217,6 +227,9 @@ export default {
return this.$message.error(res.data.message);
}
this.$message.success(res.data.message);
window.localStorage.setItem('register_code_time', res.data.data.now*1000);
window.localStorage.setItem('register_code_phone', this.registerForm.phone);
this.intervalHandle(new Date(), res.data.data.now*1000);
});
},
......
......@@ -193,7 +193,6 @@ export default {
if (!this.resetForm.phone) {
return this.$message.error("请输入手机号");
}
// 接口获得验证码
passwordCode({
phone: this.resetForm.phone,
......
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