diff --git a/src/components/VideoPlayer/index.vue b/src/components/VideoPlayer/index.vue index 1d553334..55f7f6c9 100644 --- a/src/components/VideoPlayer/index.vue +++ b/src/components/VideoPlayer/index.vue @@ -551,7 +551,6 @@ export default { }, currentProgress: function () { // 进度条到终点时修改播放状态 - //console.log('播放中', this.videoDom.currentTime) this.$emit('onPlayerPlaying', this.videoDom.currentTime,this.videoDom.duration) if (this.currentProgress === 1) { this.isPlaying = false; diff --git a/src/views/course/Courseware.vue b/src/views/course/Courseware.vue index f5a8993d..3b6dae88 100644 --- a/src/views/course/Courseware.vue +++ b/src/views/course/Courseware.vue @@ -621,10 +621,11 @@ export default { item.device = 2; } //转化为秒 - if(item.minute){ - item.duration=parseFloat(item.minute)*60; - } - + // if(item.minute){ + // item.duration=parseFloat(item.minute)*60; + // } + // 如果没有给一个默认值30分钟 + item.duration = item.minute ? parseFloat(item.minute) * 60 : 1800; }); this.loading = true; coueseFile.batchUpdate(this.fileList).then(rs => { diff --git a/src/views/portal/article/Detail.vue b/src/views/portal/article/Detail.vue index c96cd69d..83f5039b 100644 --- a/src/views/portal/article/Detail.vue +++ b/src/views/portal/article/Detail.vue @@ -158,7 +158,10 @@ export default { diagSync:false,//控制弹窗 isPraise:false, isFavorite: false, - setTime: null + setTime: null, + defaultMaxTime: 1800,//最大时长 + cumulativeDuration:0,//累计时长 + secondTime:15,//默认时长 }; }, created(){ @@ -178,7 +181,8 @@ export default { }, beforeDestroy(){ window.removeEventListener("scroll",this.handleScroll); - clearInterval(this.setTime); + clearTimeout(this.setTime); + this.cumulativeDuration = 0; }, methods: { banJump() { @@ -252,7 +256,8 @@ export default { this.articleDetailData=res.result; //if(this.articleDetailData.toString()!='{}'){ this.getAuthorInfo(this.articleDetailData) - let event = { + //记录查看文章 + this.$store.dispatch("userTrigger", { key: "ViewArticle",//后台的事件key 发布文章且审核通过 title: "查看文章",//事件的标题 parameters:"",//用户自定义参数 name:value,name:value @@ -264,15 +269,9 @@ export default { aid: this.userInfo.aid, //当前登录人的id aname: this.userInfo.name,//当前人的姓名 status: 1 //状态,直接写1 - } - this.$store.dispatch("userTrigger", event); - this.setTime = setTimeout(()=>{ - event.key = 'ReadArticle'; - event.title = "阅读文章"; - event.parameters='second:60';//增加60秒的学习时长 - event.content = "阅读了文章" - $this.$store.dispatch("userTrigger", event); - },61000);//1分钟后记录 + }); + //记录阅读时长 + this.sendEventData() //} }else{ this.noData = false; @@ -282,6 +281,33 @@ export default { this.$message.error("获取数据失败") }) }, + sendEventData(){ + let event = { + key: "ReadArticle",//后台的事件key 发布文章且审核通过 + title: "阅读文章",//事件的标题 + parameters:"second:" + this.secondTime,//用户自定义参数 name:value,name:value + content: "阅读了文章",//事件的内容 + source:'page', + objId: this.articleId,//关联的id + objType: "2",//关联的类型 + objInfo: this.articleDetailData.title, + aid: this.userInfo.aid, //当前登录人的id + aname: this.userInfo.name,//当前人的姓名 + status: 1 //状态,直接写1 + } + this.setTime = setTimeout(()=>{ + this.cumulativeDuration += this.secondTime + if(this.cumulativeDuration <= this.defaultMaxTime){ + this.$store.dispatch("userTrigger", event); + this.secondTime = 60 + this.sendEventData() + }else{ + this.cumulativeDuration = 0 + clearTimeout(this.setTime); + this.setTime = null + } + },this.secondTime * 1000);//15秒记录一次之后1分钟后记录 + }, //获取文章发布人的人物信息 getAuthorInfo(data){ let ids=[data.sysCreateAid] diff --git a/src/views/portal/case/Detail.vue b/src/views/portal/case/Detail.vue index 1699fa70..869bf454 100644 --- a/src/views/portal/case/Detail.vue +++ b/src/views/portal/case/Detail.vue @@ -223,7 +223,10 @@ export default { Profess: [], orgData: [], setTimeCase: null, - dataTime: sessionStorage.getItem('startTime') || 0 + dataTime: sessionStorage.getItem('startTime') || 0, + defaultMaxTime: 1800,//最大时长 + cumulativeDuration:0,//累计时长 + secondTime:15, //秒数 }; }, mounted() { @@ -263,7 +266,8 @@ export default { this.endTimeRequst(this.resolveId, recordEndTime) sessionStorage.removeItem('startTime') window.removeEventListener("scroll", this.handleScroll); - clearInterval(this.setTimeCase); + clearTimeout(this.setTimeCase); + this.cumulativeDuration = 0; }, methods: { endTimeRequst(caseId, recordEndTime) { @@ -280,7 +284,6 @@ export default { }, allRequests(id = '') { this.Intsucc(); - this.retest(); this.resolveId = id ? id : this.$route.query.id; this.$watermark.set(this.userInfo.name + this.userInfo.loginName); @@ -293,6 +296,7 @@ export default { this.getPopularity(); this.getPositive(); this.couresreso(); + this.retest(); window.addEventListener( "scroll", this.handleScroll @@ -330,6 +334,18 @@ export default { if (xmlhttp.status == 200) { clearTimeout(timer); $this.Internet = 1; + $this.$store.dispatch("userTrigger", { + key: "ViewCase",//后台的事件key 发布文章且审核通过 + title: '查看案例',//事件的标题 + parameters: "",//用户自定义参数 name:value,name:value + content: '查看了案例',//事件的内容 + objId: $this.resolveId,//关联的id + objType: "3",//关联的类型 + objInfo: $this.caseDetail?.title, + aid: $this.userInfo.aid, //当前登录人的id + aname: $this.userInfo.name,//当前人的姓名 + status: 1 //状态,直接写1 + }); $this.sendEventData(); } else { clearTimeout(timer); @@ -526,10 +542,10 @@ export default { }, sendEventData() { let event = { - key: "ViewCase",//后台的事件key 发布文章且审核通过 - title: '查看案例',//事件的标题 - parameters: "",//用户自定义参数 name:value,name:value - content: '查看了案例',//事件的内容 + key: "ReadCase",//后台的事件key 发布文章且审核通过 + title: '阅读案例',//事件的标题 + parameters: "second:" + this.secondTime,//用户自定义参数 name:value,name:value + content: '阅读了案例',//事件的内容 objId: this.resolveId,//关联的id objType: "3",//关联的类型 objInfo: this.caseDetail.title, @@ -537,15 +553,18 @@ export default { aname: this.userInfo.name,//当前人的姓名 status: 1 //状态,直接写1 } - this.$store.dispatch("userTrigger", event); - let $this = this; this.setTimeCase = setTimeout(() => { - event.key = 'ReadCase'; - event.title = '阅读案例'; - event.parameters = "second:60"; - event.content = '阅读了案例'; - $this.$store.dispatch("userTrigger", event); - }, 61000);//1分钟之后发送阅读案例事件 + this.cumulativeDuration += this.secondTime + if(this.cumulativeDuration <= this.defaultMaxTime){ + this.$store.dispatch("userTrigger", event); + this.secondTime = 60 + this.sendEventData() + }else{ + this.cumulativeDuration = 0 + clearTimeout(this.setTimeCase); + this.setTimeCase = null + } + }, this.secondTime * 1000);//15秒记录一次之后1分钟之后发送阅读案例事件 }, getCaseData() { let $this = this; diff --git a/src/views/portal/course/Index.vue b/src/views/portal/course/Index.vue index 39b0f4c0..bf8a9c1b 100644 --- a/src/views/portal/course/Index.vue +++ b/src/views/portal/course/Index.vue @@ -643,6 +643,7 @@ export default { pageIndex: 1, // 第几页 pageSize: 9,//每页多少条 openCourse: 0,//增加的公开课查询 + userId:'' }, sceneList: [], //场景 keyword: "",//查询的关键字 @@ -1375,6 +1376,7 @@ export default { let isTopList = []; // 隐藏loadMore this.moreState = 2; + this.course.userId = this.userInfo.aid await apiCoursePortal.courseSearch(this.course).then(res => { this.searching = false; if (res.status == 200) { diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index 3440d781..05aed8cf 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() { @@ -484,18 +487,25 @@ "aname":this.userInfo.name,//当前人的姓名 "status": 1 //状态 } - //静默处理 - apiStat.sendEvent(postData).then(rs=>{ - if(rs.status != 200) { - console.log(rs.message); - } - }); //每一分钟保存一次 - // 取消阅读的每分钟六十秒的计时 - // 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){ + //静默处理 + apiStat.sendEvent(postData).then(rs=>{ + if(rs.status != 200) { + console.log(rs.message); + } + }); + $this.appendStudyOtherTime(); + }else{ + clearTimeout(this.appendStudyOtherHandle); + $this.cumulativeDuration = 0; + $this.maxDuration = 0; + } + }, 1000*60); }, //笔记组件触发,播放指定时间 @@ -662,14 +672,32 @@ if (this.contentData.status < 2) { this.contentData.status = 2; //进行中 } - //以下是学习记录 - if (this.contentData.contentType > 20) { //非视频类的 + //以下是学习记录,50是scorm项目 + if (this.contentData.contentType > 20 && this.contentData.contentType !== 50) { //非视频类的 //用户的学习时长,非音视频课程学习,单独的处理 this.isAppendTime = false; this.appendStudyOtherHandle = setTimeout(function() { + // 开始之前把响应式清空 + $this.maxDuration = 0; + $this.cumulativeDuration = 0; + // 没有设置默认时长三十分钟, + $this.maxDuration = r.duration !== 0 ? r.duration * 2 : $this.defaultMaxTime; + $this.$store.dispatch("userTrigger", { + "key": "StudyCourseOther",//课程学习的key + "title": "非音视频课内容",//事件的标题 + "parameters":"second:15",//second:value 本次的学习时长 + "content": "学习课程",//事件的内容 + "objId": $this.courseInfo.id,//课程的id + "objType": "1",//类型 + "source":"page", + "objInfo": ""+$this.courseInfo.name, + "aid":$this.userInfo.aid, //当前登录人的id + "aname":$this.userInfo.name,//当前人的姓名 + "status": 1 //状态 + }); $this.appendStudyOtherTime(); - }, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒 + }, 15000); //非音视频课程学习,十五秒后记录 //this.appendStudyTime(); if (this.contentData.contentType != 50) { this.handleTimeout = setTimeout(function(){