From 15ed2923ad858ac25daa05af5ddcbf3ffd3c2abe Mon Sep 17 00:00:00 2001 From: zhangsir Date: Thu, 9 May 2024 16:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E4=B8=BA=E8=BF=94=E5=9B=9E=E5=80=BC=E5=8F=AF=E7=82=B9?= =?UTF-8?q?=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/study/exam.vue | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pages/study/exam.vue b/pages/study/exam.vue index 88a2a0b..1720c9c 100644 --- a/pages/study/exam.vue +++ b/pages/study/exam.vue @@ -31,7 +31,7 @@ - + @@ -65,6 +65,7 @@ export default { data() { return { + thisTrue: true, studyId:'', examId:'', ctype:10, @@ -92,8 +93,8 @@ if(this.examId){ this.loadExamInfo(); } - this.debouncedPresent = this.throttle(this.present, 30000); - this.confirmStop = this.throttle(this.submitTest,30000) + // this.debouncedPresent = this.debounce(this.present, 500); + // this.confirmStop = this.debounce(this.submitTest,500) }, methods: { changeTimer(){ @@ -232,9 +233,9 @@ } } }, - // confirmStop(){ - // this.submitTest() - // }, + confirmStop(){ + this.submitTest() + }, cancelStop(){ //应该返回课程面页 this.confirmFinish(); @@ -343,7 +344,9 @@ var dateDiff = now.getTime() - this.startTime.getTime();//时间差的毫秒数 var minutes=Math.floor(dateDiff/(1000))//计算相差秒数,分钟记录的太大,经常为0 postData.testDuration=minutes; + this.thisTrue = false apiCourseStudy.saveExam(postData).then(res=>{ + this.thisTrue = true if(res.status == 200) { this.studyItemId=res.result.studyItemId; this.scoreShow=true; @@ -352,14 +355,14 @@ } }) }, - throttle(func, delay) { - let lastExecTime = 0; + debounce(func, delay) { + let timerId; return function (...args) { - const now = Date.now(); - if (now - lastExecTime >= delay) { + if (timerId) clearTimeout(timerId); + timerId = setTimeout(() => { func.apply(this, args); - lastExecTime = now; - } + timerId = null; + }, delay); }; }, present(){