|
|
@@ -266,26 +266,24 @@
|
|
|
/*=================================== 学习定时器 ===================================*/
|
|
|
// 初始化定时器
|
|
|
initTimer() {
|
|
|
- let self = this;
|
|
|
- if(this.newData.coursewares[this.checkLearningIndex].learnedDuration == this.newData.coursewares[this.checkLearningIndex].minLearningDuration){
|
|
|
+ // 先清除旧计时器,防止孤儿计时器在切换窗口时复活写入错误数据
|
|
|
+ this.clearTimer();
|
|
|
+ const idx = this.checkLearningIndex;
|
|
|
+ const courseware = this.newData.coursewares[idx];
|
|
|
+ if(courseware.learnedDuration >= courseware.minLearningDuration){
|
|
|
return
|
|
|
}
|
|
|
this.studyTimer = new StudyTimer({
|
|
|
- initialSeconds: self.newData.coursewares[self.checkLearningIndex].learnedDuration,
|
|
|
- maxSeconds: self.newData.coursewares[self.checkLearningIndex].minLearningDuration,
|
|
|
+ initialSeconds: courseware.learnedDuration,
|
|
|
+ maxSeconds: courseware.minLearningDuration,
|
|
|
onTick: (elapsedSeconds) => {
|
|
|
- //每次计时
|
|
|
- this.$set(self.newData.coursewares[self.checkLearningIndex],'learnedDuration',elapsedSeconds);
|
|
|
- //心跳判断
|
|
|
+ this.$set(this.newData.coursewares[idx],'learnedDuration',elapsedSeconds);
|
|
|
if (elapsedSeconds % this.heartbeatValue === 0) {
|
|
|
- //调用心跳方法
|
|
|
this.examUserCoursewareLearningReportProgress();
|
|
|
}
|
|
|
},
|
|
|
onMaxTimeReached: (elapsedSeconds) => {
|
|
|
- //达到最大值
|
|
|
- this.$set(self.newData.coursewares[self.checkLearningIndex],'learnedDuration',elapsedSeconds);
|
|
|
- //调用心跳方法
|
|
|
+ this.$set(this.newData.coursewares[idx],'learnedDuration',elapsedSeconds);
|
|
|
this.examUserCoursewareLearningReportProgress();
|
|
|
}
|
|
|
});
|
|
|
@@ -352,14 +350,8 @@
|
|
|
},
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
- if (this.studyTimer) {
|
|
|
- this.studyTimer.destroy();
|
|
|
- this.studyTimer = null;
|
|
|
- }
|
|
|
- if (this.countdownTimer) {
|
|
|
- this.countdownTimer.destroy();
|
|
|
- this.countdownTimer = null;
|
|
|
- }
|
|
|
+ this.clearTimer();
|
|
|
+ this.clearCountdown();
|
|
|
},
|
|
|
}
|
|
|
</script>
|