diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index f09f3160..dc1672a2 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -1643,65 +1643,10 @@ let endTime = new Date().getTime(); this.appentInterval = 60 let totalTime = Math.round((endTime - this.appendStartTime) / 1000); - // this.appendStudyTime(); - // this.saveStudyDuration(totalTime); - this.uploadStudyTime(totalTime); + this.appendStudyTime(); + this.saveStudyDuration(totalTime); }, this.appentInterval * 1000); }, - //追加学习时长, flag是否提交到后台 - // appendStudyTime() { - // //console.log('开始追加学习时长',this.isAppendTime); - // if (this.studyId == '') { - // return; - // } - // if (!this.contentData.id) { - // return; - // } - // if (!this.isAppendTime) { - // this.appendStartTime = null; - // return; - // } - - // if (this.appendHandle != null) { - // window.clearTimeout(this.appendHandle); - // } - // //首先从本地读取 - // let duration = studyUtil.getStudyDuration(); - // //console.log('追加学习时长,当前本地积累的学习时长='+duration); - // //追加学习长 - // let $this = this; - // if (this.appendStartTime == null) { - // this.appendStartTime = new Date(); - // this.appendHandle = setTimeout(function() { - // $this.appendStudyTime(); - // }, $this.appentInterval); //设置定时追加学习时长 - // //保存之前的 - // if (duration >= 60 ) { - // this.saveStudyDuration(duration); - // } - // return; - // } - // //如果当前追加开始时间不为空 - // let now = new Date(); - // let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数 - // // console.log(m/1000,'时间'); - - // let sen = Math.round(m / 1000); //计算秒数 - // // console.log('定时器时间',sen); - // // 每次添加的是定时器计时的时间 - // duration = duration + sen;//追加的是秒 - // if (duration >= 60) { //一分钟保存一次 - // this.saveStudyDuration(duration); - // } else { - // studyUtil.setStudyDuration(duration); //添加到本地存储中 - // } - // //重新覆盖时间 - // this.appendStartTime = new Date(); - // //启动下次追加学习时长 - // this.appendHandle = setTimeout(function() { - // $this.appendStudyTime(); - // }, $this.appentInterval); - // }, finishStudyItem() { //设置完成学习的内容,针对于音视频的内容 if (!this.contentData.studyItemId) { @@ -1785,83 +1730,6 @@ } // } }, - uploadStudyTime(duration){ - // appendStudyTime() - // 暂停的时候重新从十五秒开始计时 - if(!this.appendStartTime){ - this.appentInterval = 15 - } - //重新覆盖时间 - this.appendStartTime = new Date().getTime(); - //console.log('开始追加学习时长',this.isAppendTime); - if (this.studyId == '') { - return; - } - if (!this.contentData.id) { - return; - } - if (!this.isAppendTime) { - return; - } - this.appendHandle && window.clearTimeout(this.appendHandle); - //启动下次追加学习时长 - this.appendHandle = setTimeout(() => { - let endTime = new Date().getTime(); - this.appentInterval = 60 - let totalTime = Math.round((endTime - this.appendStartTime) / 1000); - // this.appendStudyTime(); - // this.saveStudyDuration(totalTime); - this.uploadStudyTime(totalTime); - }, this.appentInterval * 1000); - - // saveStudyDuration() - if (duration > 0) { - //发送用户学习事件 - //console.log('保存到后台学习时长='+duration); - let postData={ - "key": "StudyCourse",//课程学习的key - "title": "学习课程",//事件的标题 - "parameters":"second:"+duration,//second:value,total:value 本次的学习时长 - "content": "学习课程【"+this.courseInfo.name+"】",//事件的内容 - "objId": this.courseInfo.id,//课程的id - "objType": "1",//类型 - "source":"page", - "objInfo": ""+this.courseInfo.name, - "aid":this.userInfo.aid, //当前登录人的id - "aname":this.userInfo.name,//当前人的姓名 - "status": 1, //状态 - "contentId": this.contentData.id, - } - if(this.resType == 10){ - postData.progress = this.sendEventProgress; - } - //静默处理 - apiStat.sendEvent(postData).then(rs=>{ - if(rs.status == 200) { - // this.appendStartTime = new Date();//重新计时 - // studyUtil.clearStudyDuration(); //清除本地存储 - } else { - console.log(rs.message); - } - }); - let postAppendData = { - id: this.appentId, - studyId: this.studyId, - courseId: this.courseInfo.id, - contentId: this.contentData.id, - studyInfo: this.courseInfo.name +"-" +this.contentData.contentName, - duration: duration - }; - apiStudy.appendStudyTime(postAppendData).then(rs => { - if (rs.status == 200) { - this.appentId = rs.result; - studyUtil.clearStudyDuration(); //清除本地存储 - } else { - console.log(rs.message); - } - }); - } - } }, }