diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index 020b5dce..f263b55c 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -394,6 +394,9 @@ localTimeKey:'boeu-study-time' ,//本地存储的学习时长的key json格式 localTimeValue:0,//计算的时间 appendStudyOtherHandle:null, + cumulativeDuration:0, //非音频累计时长 + maxDuration:0, //非音频最大时长 + defaultMaxTime:1800 //非音频默认最大时间 } }, mounted() { @@ -493,11 +496,18 @@ } }); //每一分钟保存一次 - // 取消阅读的每分钟六十秒的计时 - // let $this=this; - // this.appendStudyOtherHandle = setTimeout(function() { - // $this.appendStudyOtherTime(); - // }, 1000*60); + // 取消阅读的每分钟六十秒的计时,最多是设置的时间或默认时间 + let $this=this; + this.appendStudyOtherHandle = setTimeout(function() { + $this.cumulativeDuration += 60; + if($this.cumulativeDuration <= $this.maxDuration){ + $this.appendStudyOtherTime(); + }else{ + clearTimeout(this.appendStudyOtherHandle); + $this.cumulativeDuration = 0; + $this.maxDuration = 0; + } + }, 1000*60); }, //笔记组件触发,播放指定时间 @@ -670,6 +680,11 @@ this.isAppendTime = false; this.appendStudyOtherHandle = setTimeout(function() { + // 开始之前把响应式清空 + this.maxDuration = 0; + this.cumulativeDuration = 0; + // 没有设置默认时长 + this.maxDuration = r.duration !== 0 ? r.duration : this.defaultMaxTime; $this.appendStudyOtherTime(); }, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒 //this.appendStudyTime();