diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index c6aecf02..a712c802 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -329,6 +329,7 @@ notetab: 1, localTimeKey:'boeu-study-time' ,//本地存储的学习时长的key json格式 localTimeValue:0,//计算的时间 + appendStudyOtherHandle:null, } }, mounted() { @@ -372,6 +373,40 @@ } }, methods: { + //非音视频课学习时长的增加,每一分钟保存一次 + appendStudyOtherTime() { + //console.log('开始追加学习时长',this.isAppendTime); + if (this.studyId == '') { + return; + } + if (!this.contentData.id) { + return; + } + let postData={ + "key": "StudyCourseOther",//课程学习的key + "title": "非音视频课内容",//事件的标题 + "parameters":"second:60",//second:value 本次的学习时长 + "content": "学习课程【"+this.courseInfo.name+"】",//事件的内容 + "objId": this.contentData.id,//课程的内容id + "objType": "1",//类型 + "source":"page", + "objInfo": ""+this.contentData.contentName, + "aid":this.userInfo.aid, //当前登录人的id + "aname":this.userInfo.name,//当前人的姓名 + "status": 1 //状态 + } + //静默处理 + apiStat.sendEvent(postData).then(rs=>{ + if(rs.status != 200) { + console.log(rs.message); + } + }); + //每一分钟保存一次 + this.appendStudyOtherHandle = setTimeout(function() { + $this.appendStudyOtherTime(); + }, 1000*60); + + }, //关注功能 toFollow(item) { apiFollow.save(item.teacherId).then(res => { @@ -529,8 +564,16 @@ this.contentData.status = 2; //进行中 } if (this.contentData.contentType > 20) { //非视频类的 - //用户的学习时长,只是视听课的学习时长,所以这里不要追加学习时长 + //用户的学习时长,非音视频课程学习,单独的处理 this.isAppendTime = false; + + if(this.appendStudyOtherHandle!=null){ + windows.clearTimeout(this.appendStudyOtherHandle); + } + + this.appendStudyOtherHandle = setTimeout(function() { + $this.appendStudyOtherTime(); + }, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒 //this.appendStudyTime(); this.handleTimeout = setTimeout(function() { $this.saveStudyInfo(); @@ -1034,7 +1077,7 @@ saveStudyDuration(duration) { //保存本地存储的学习时长 if (duration > 0) { //发送用户学习事件 - console.log('保存到后台学习时长='+duration); + //console.log('保存到后台学习时长='+duration); let postData={ "key": "StudyCourse",//课程学习的key "title": "学习课程",//事件的标题 @@ -1042,7 +1085,7 @@ "content": "学习课程【"+this.courseInfo.name+"】",//事件的内容 "objId": this.courseInfo.id,//课程的id "objType": "1",//类型 - "source":"页面事件", + "source":"page", "objInfo": ""+this.courseInfo.name, "aid":this.userInfo.aid, //当前登录人的id "aname":this.userInfo.name,//当前人的姓名 @@ -1079,7 +1122,7 @@ }, //结束追加学习时长 stopStudyTime(){ - console.log('停止追加学习时长'); + //console.log('停止追加学习时长'); this.isAppendTime=false; if (this.appendHandle != null) { window.clearTimeout(this.appendHandle); @@ -1104,7 +1147,7 @@ } //首先从本地读取 let duration = studyUtil.getStudyDuration(); - console.log('追加学习时长,当前本地积累的学习时长='+duration); + //console.log('追加学习时长,当前本地积累的学习时长='+duration); //追加学习长 let $this = this; if (this.appendStartTime == null) {