|
|
|
@ -184,6 +184,7 @@ export default { |
|
|
|
|
loading:false, |
|
|
|
|
sss:1, |
|
|
|
|
popContainer:false, |
|
|
|
|
timestamp:'', |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -243,6 +244,13 @@ export default { |
|
|
|
|
let projectId = this.getQueryVariable('projectId') |
|
|
|
|
let assessmentId = this.getQueryVariable('assessmentId') |
|
|
|
|
let classId = this.getQueryVariable('classId') |
|
|
|
|
let stopTime = this.getQueryVariable('stopTime') |
|
|
|
|
let timestamp = +stopTime; |
|
|
|
|
if (timestamp != null){ |
|
|
|
|
sessionStorage.setItem('timestamp', timestamp) |
|
|
|
|
}else{ |
|
|
|
|
sessionStorage.setItem('timestamp', null) |
|
|
|
|
} |
|
|
|
|
if (token != null){ |
|
|
|
|
sessionStorage.setItem('token', token) |
|
|
|
|
sessionStorage.setItem('cid', cid) |
|
|
|
@ -379,14 +387,16 @@ export default { |
|
|
|
|
getProjectDetail(params).then((data)=>{ |
|
|
|
|
if(data.status == 200){ |
|
|
|
|
this.globalTimer = ""; |
|
|
|
|
this.countVal = ""; |
|
|
|
|
this.day = "00"; |
|
|
|
|
this.seconds = "00"; |
|
|
|
|
this.minutes = "00"; |
|
|
|
|
this.hour = "00"; |
|
|
|
|
let stopTime = sessionStorage.getItem('timestamp') |
|
|
|
|
let timestamp = +stopTime; |
|
|
|
|
this.countVal = timestamp; |
|
|
|
|
// this.day = "00"; |
|
|
|
|
// this.seconds = "00"; |
|
|
|
|
// this.minutes = "00"; |
|
|
|
|
// this.hour = "00"; |
|
|
|
|
this.sss = 1; |
|
|
|
|
this.hintOpen = data.data.projectManage.hintOpen |
|
|
|
|
this.startCountFn(); |
|
|
|
|
this.hintOpen = data.data.projectManage.hintOpen; |
|
|
|
|
this.countDown(timestamp); |
|
|
|
|
let projectId = this.getQueryVariable('projectId') |
|
|
|
|
if(projectId != null){ |
|
|
|
|
//获取当前时间 |
|
|
|
@ -511,14 +521,17 @@ export default { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//开始计时 |
|
|
|
|
|
|
|
|
|
//开始计时 |
|
|
|
|
startCountFn() { |
|
|
|
|
if (!this.isStart) { |
|
|
|
|
this.countVal = this.countVal ? this.countVal : 0; |
|
|
|
|
// this.countVal = this.countVal ? this.countVal : 0; |
|
|
|
|
this.globalTimer = setInterval(() => { |
|
|
|
|
if(this.sss == 0){ |
|
|
|
|
this.globalTimer = null; |
|
|
|
|
clearInterval(this.globalTimer); |
|
|
|
|
}else if (this.timestamp){ |
|
|
|
|
this.counterFn(this.countVal--); |
|
|
|
|
}else{ |
|
|
|
|
this.counterFn(this.countVal++); |
|
|
|
|
} |
|
|
|
@ -526,22 +539,57 @@ export default { |
|
|
|
|
this.isStart = true; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//倒计时 |
|
|
|
|
countDown(timestamp){ |
|
|
|
|
this.timestamp = timestamp |
|
|
|
|
console.log(this.timestamp) |
|
|
|
|
this.sss = 1; |
|
|
|
|
this.globalTimer = null; |
|
|
|
|
clearInterval(this.globalTimer); |
|
|
|
|
this.startCountFn() |
|
|
|
|
}, |
|
|
|
|
counterFn(counterTime) { |
|
|
|
|
let leave1 = counterTime % (24 * 3600 * 1); //计算天数后剩余的毫秒数 |
|
|
|
|
let leave2 = leave1 % (3600 * 1); //计算小时数后剩余的毫秒数 |
|
|
|
|
let leave3 = leave2 % (60 * 1); //计算分钟数后剩余的毫秒数 |
|
|
|
|
let day = Math.floor(counterTime / (24 * 3600 * 1)); //计算相差天数 |
|
|
|
|
let hour = Math.floor(leave1 / (3600 * 1)); //计算相差小时 |
|
|
|
|
let minutes = Math.floor(leave2 / (60 * 1)); //计算相差分钟 |
|
|
|
|
let seconds = Math.round(leave3 / 1); //计算相差秒 |
|
|
|
|
day = day >= 10 ? day : "0" + day; |
|
|
|
|
hour = hour >= 10 ? hour : "0" + hour; |
|
|
|
|
minutes = minutes >= 10 ? minutes : "0" + minutes; |
|
|
|
|
seconds = seconds >= 10 ? seconds : "0" + seconds; |
|
|
|
|
this.day = day; |
|
|
|
|
this.hour = hour; |
|
|
|
|
this.minutes = minutes; |
|
|
|
|
this.seconds = seconds; |
|
|
|
|
if (this.timestamp){ |
|
|
|
|
let countDown = (new Date(counterTime).getTime() - new Date().getTime()) / 1000 |
|
|
|
|
if (countDown > 0) { |
|
|
|
|
let d = Math.floor(countDown / (60 * 60 * 24)); |
|
|
|
|
let h = Math.floor(countDown / (60 * 60)); |
|
|
|
|
let m = Math.floor(countDown % (60 * 60) / 60); |
|
|
|
|
let s = Math.floor(countDown % (60 * 60) % 60); |
|
|
|
|
this.day = `${d > 9 ? d : `0${d}`}`; |
|
|
|
|
this.hour = `${h > 9 ? h : `0${h}`}`; |
|
|
|
|
this.minutes = `${m > 9 ? m : `0${m}`}`; |
|
|
|
|
this.seconds = `${s > 9 ? s : `0${s}`}`; |
|
|
|
|
} else { |
|
|
|
|
this.$alert('考核结束,已自动交卷', '提示', { |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
callback: action => { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.Submit() |
|
|
|
|
this.day = '00'; |
|
|
|
|
this.hour = '00'; |
|
|
|
|
this.minutes = '00'; |
|
|
|
|
this.seconds = '00'; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
let leave1 = counterTime % (24 * 3600 * 1); //计算天数后剩余的毫秒数 |
|
|
|
|
let leave2 = leave1 % (3600 * 1); //计算小时数后剩余的毫秒数 |
|
|
|
|
let leave3 = leave2 % (60 * 1); //计算分钟数后剩余的毫秒数 |
|
|
|
|
let day = Math.floor(counterTime / (24 * 3600 * 1)); //计算相差天数 |
|
|
|
|
let hour = Math.floor(leave1 / (3600 * 1)); //计算相差小时 |
|
|
|
|
let minutes = Math.floor(leave2 / (60 * 1)); //计算相差分钟 |
|
|
|
|
let seconds = Math.round(leave3 / 1); //计算相差秒 |
|
|
|
|
day = day >= 10 ? day : "0" + day; |
|
|
|
|
hour = hour >= 10 ? hour : "0" + hour; |
|
|
|
|
minutes = minutes >= 10 ? minutes : "0" + minutes; |
|
|
|
|
seconds = seconds >= 10 ? seconds : "0" + seconds; |
|
|
|
|
this.day = day; |
|
|
|
|
this.hour = hour; |
|
|
|
|
this.minutes = minutes; |
|
|
|
|
this.seconds = seconds; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//重新开始 |
|
|
|
|
reload() { |
|
|
|
@ -602,9 +650,9 @@ export default { |
|
|
|
|
getCookie(cookie_name) { |
|
|
|
|
//获取cookie中指定key的value |
|
|
|
|
var allcookies = document.cookie; //索引长度,开始索引的位置 |
|
|
|
|
var cookie_pos = allcookies.indexOf(cookie_name); // 如果找到了索引,就代表cookie存在,否则不存在 |
|
|
|
|
var cookie_pos = allcookies.indexOf(cookie_name); //如果找到了索引,就代表cookie存在,否则不存在 |
|
|
|
|
if (cookie_pos != -1) { |
|
|
|
|
// 把cookie_pos放在值的开始,只要给值加1即可 |
|
|
|
|
//把cookie_pos放在值的开始,只要给值加1即可 |
|
|
|
|
//计算取cookie值得开始索引,加的1为“=” |
|
|
|
|
cookie_pos = cookie_pos + cookie_name.length + 1; //计算取cookie值得结束索引 |
|
|
|
|
var cookie_end = allcookies.indexOf(";", cookie_pos); |
|
|
|
|