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