From 381fcd9130a37f83da110cec1324b306c58a5e77 Mon Sep 17 00:00:00 2001 From: nisen Date: Thu, 16 Nov 2023 17:31:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=87=E7=AB=A0=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=A4=9A=E4=B8=89=E5=8D=81=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/resource/articeDetail.vue | 58 ++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/pages/resource/articeDetail.vue b/pages/resource/articeDetail.vue index e059597..8919362 100644 --- a/pages/resource/articeDetail.vue +++ b/pages/resource/articeDetail.vue @@ -49,7 +49,11 @@ // 字符串的形式 p: 'word-break:break-all;font-size: 28upx;letter-spacing:1rpx; line-height: 1.6;margin-bottom:25px', span: 'word-break:break-all;font-size: 28upx;letter-spacing:1rpx; line-height: 1.6' - } + }, + secondTime: 15,//默认时长 + cumulativeDuration: 0, + setTime: null, + defaultMaxTime: 1800,//最大时长 } }, @@ -74,15 +78,22 @@ source:"h5", } apiStat.sendEvent(event); + this.sendEventData() // this.$store.dispatch("userTrigger", event); - this.setTime = setTimeout(()=>{ - event.key = 'ReadArticle'; - event.title = "阅读文章"; - event.parameters='second:60';//增加60秒的学习时长 - event.content = "阅读了文章" - apiStat.sendEvent(event); - // $this.$store.dispatch("userTrigger", event); - },61000);//1分钟后记录 + // this.setTime = setTimeout(()=>{ + // event.key = 'ReadArticle'; + // event.title = "阅读文章"; + // event.parameters='second:60';//增加60秒的学习时长 + // event.content = "阅读了文章" + // apiStat.sendEvent(event); + // // $this.$store.dispatch("userTrigger", event); + // },61000);//1分钟后记录 + + }, + destroyed() { + if(this.setTime){ + clearTimeout(this.setTime); + } }, onReachBottom(){ this.getDetail() @@ -91,6 +102,35 @@ ...mapGetters(['userInfo']) }, methods: { + // 发送计时 + sendEventData(){ + let event = { + key: "ReadArticle",//后台的事件key 发布文章且审核通过 + title: "阅读文章",//事件的标题 + parameters:"second:" + this.secondTime,//用户自定义参数 name:value,name:value + content: "阅读了文章",//事件的内容 + source:'page', + objId: this.id,//关联的id + objType: "2",//关联的类型 + objInfo: this.detail.title, + aid: this.userInfo.aid, //当前登录人的id + aname: this.userInfo.name,//当前人的姓名 + status: 1 ,//状态,直接写1 + source:"h5", + } + this.setTime = setTimeout(()=>{ + this.cumulativeDuration += this.secondTime + if(this.cumulativeDuration <= this.defaultMaxTime){ + apiStat.sendEvent(event); + this.secondTime = 60 + this.sendEventData() + }else{ + this.cumulativeDuration = 0 + clearTimeout(this.setTime); + this.setTime = null + } + },this.secondTime * 1000);//15秒记录一次之后1分钟后记录 + }, getDetail(){ uni.showLoading({title:'加载中...'}); let $this=this; From 6f05888db74feaa2b1e00e429d9684522c91137e Mon Sep 17 00:00:00 2001 From: nisen Date: Thu, 16 Nov 2023 17:57:53 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 3 ++- pages/study/courseStudy.vue | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/index.js b/config/index.js index 3a5014c..9412c99 100644 --- a/config/index.js +++ b/config/index.js @@ -19,7 +19,8 @@ if(process.env.NODE_ENV === 'development'){ oldApiBaseUrl = '/uboeApi'; statApiBaseUrl='/statApi'; socialApiBaseUrl='/socialApi'; - fileUrl = 'https://u-pre.boe.com/cdn/upload'; + fileUrl = 'https://u-pre.boe.com/upload'; + //fileUrl = 'https://u-pre.boe.com/cdn/upload'; loginPath='/mobile/pages/login/login'; scormPlayer='https://u-pre.boe.com/scorm-player'; }else if(process.env.ENV_TYPE === 'preview'){ diff --git a/pages/study/courseStudy.vue b/pages/study/courseStudy.vue index e682f7e..fb01886 100644 --- a/pages/study/courseStudy.vue +++ b/pages/study/courseStudy.vue @@ -568,6 +568,12 @@ getSysTypeTree:'sysType/getSysTypeTree', loadSysTypes:'sysType/loadSysTypes' }), + // 没有写播放时间 + onPlayerPlay() { + this.playerBoxShow = false; + this.isAppendTime=true; + this.appendStudyTime();//启动追加学习时长 + }, convertTypeName(code){ if(!code){return '';} return this.sysTypeMap.get(code); @@ -945,7 +951,8 @@ return false; }) this.scrollInfo.scrollLeft=len*this.scrollItemWidth+len*6; - if(con.contentType>20){ + //50事scorm项目单独计时 + if(con.contentType>20 && con.contentType !== 50){ let $this=this; //用户的学习时长,音视频课程学习,单独的处理,不再追加学习时长 this.isAppendTime = false; From 5d7df19bce9c4cac2a4e71776b25317c04ee1303 Mon Sep 17 00:00:00 2001 From: nisen Date: Mon, 20 Nov 2023 17:12:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=96=87=E7=AB=A0=E8=AE=A1=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/resource/articeDetail.vue | 44 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/pages/resource/articeDetail.vue b/pages/resource/articeDetail.vue index 8919362..e747db8 100644 --- a/pages/resource/articeDetail.vue +++ b/pages/resource/articeDetail.vue @@ -91,9 +91,7 @@ }, destroyed() { - if(this.setTime){ - clearTimeout(this.setTime); - } + this.setTime && clearTimeout(this.setTime); }, onReachBottom(){ this.getDetail() @@ -104,24 +102,15 @@ methods: { // 发送计时 sendEventData(){ - let event = { - key: "ReadArticle",//后台的事件key 发布文章且审核通过 - title: "阅读文章",//事件的标题 - parameters:"second:" + this.secondTime,//用户自定义参数 name:value,name:value - content: "阅读了文章",//事件的内容 - source:'page', - objId: this.id,//关联的id - objType: "2",//关联的类型 - objInfo: this.detail.title, - aid: this.userInfo.aid, //当前登录人的id - aname: this.userInfo.name,//当前人的姓名 - status: 1 ,//状态,直接写1 - source:"h5", - } + this.setTime && clearTimeout(this.setTime); + let startTime = new Date().getTime(); this.setTime = setTimeout(()=>{ - this.cumulativeDuration += this.secondTime + let endTime = new Date().getTime(); + let totalTime = Math.round((endTime - startTime) / 1000); + this.cumulativeDuration += totalTime; + console.log(this.cumulativeDuration,'时间'); if(this.cumulativeDuration <= this.defaultMaxTime){ - apiStat.sendEvent(event); + this.sendStudyTime(totalTime) this.secondTime = 60 this.sendEventData() }else{ @@ -131,6 +120,23 @@ } },this.secondTime * 1000);//15秒记录一次之后1分钟后记录 }, + //发送学习时间 + sendStudyTime(totalTime){ + apiStat.sendEvent({ + key: "ReadArticle",//后台的事件key 发布文章且审核通过 + title: "阅读文章",//事件的标题 + parameters:"second:" + totalTime,//用户自定义参数 name:value,name:value + content: "阅读了文章",//事件的内容 + source:'page', + objId: this.id,//关联的id + objType: "2",//关联的类型 + objInfo: this.detail.title, + aid: this.userInfo.aid, //当前登录人的id + aname: this.userInfo.name,//当前人的姓名 + status: 1 ,//状态,直接写1 + source:"h5", + }); + }, getDetail(){ uni.showLoading({title:'加载中...'}); let $this=this; From 58645d9718eb2ef396b5f60c1ead7f0d409d70af Mon Sep 17 00:00:00 2001 From: nisen Date: Mon, 20 Nov 2023 17:15:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E8=AE=A1=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/study/courseStudy.vue | 102 ++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 29 deletions(-) diff --git a/pages/study/courseStudy.vue b/pages/study/courseStudy.vue index fb01886..66dbf7a 100644 --- a/pages/study/courseStudy.vue +++ b/pages/study/courseStudy.vue @@ -486,6 +486,9 @@ appendStudyOtherHandle:null, articleMore:true, scormUrl:'', + maxDuration:0, //非音频最大时长 + cumulativeDuration:0, //非音频累计时长 + defaultMaxTime:1800, //非音频默认最大时间 } }, computed: { @@ -957,8 +960,31 @@ //用户的学习时长,音视频课程学习,单独的处理,不再追加学习时长 this.isAppendTime = false; this.appendStudyOtherHandle = setTimeout(function() { + // 开始之前把响应式清空 + $this.maxDuration = 0; + $this.cumulativeDuration = 0; + // 没有设置默认时长三十分钟, + $this.maxDuration = con.duration !== 0 ? con.duration * 2 : $this.defaultMaxTime; + //静默处理 + apiStat.sendEvent({ + "key": "StudyCourse",//课程学习的key + "title": "学习课程",//事件的标题 + "parameters":"second:15",//second:value,total:value 本次的学习时长 + "content": "学习课程【"+$this.courseInfo.name+"】",//事件的内容 + "objId": $this.courseInfo.id,//课程的id + "objType": "1",//类型 + "source":"h5", + "objInfo": ""+$this.courseInfo.name, + "aid":$this.userInfo.aid, //当前登录人的id + "aname":$this.userInfo.name,//当前人的姓名 + "status": 1 //状态 + }).then(rs=>{ + if(rs.status !== 200) { + console.log(rs.message); + } + }); $this.appendStudyOtherTime(); - }, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒 + }, 1000 * 15); //非音视频课程学习,15秒后记录,因为一次记录是60秒 //this.appendStudyTime(); //非视频,音频的5秒后学习完成 if(con.contentType!=50){ @@ -1287,7 +1313,7 @@ //静默处理 apiStat.sendEvent(postData).then(rs=>{ if(rs.status == 200) { - this.appendStartTime = new Date();//重新计时 + //this.appendStartTime = new Date();//重新计时 studyUtil.clearStudyDuration(); //清除本地存储 } else { console.log(rs.message); @@ -1299,6 +1325,8 @@ stopStudyTime(){ //console.log('停止追加学习时长'); this.isAppendTime=false; + //暂停让他为空 从新计时 + this.appendStartTime = null if (this.appendHandle != null) { window.clearTimeout(this.appendHandle); } @@ -1331,7 +1359,7 @@ $this.appendStudyTime(); }, $this.appentInterval); //设置定时追加学习时长 //保存之前的 - if (duration >0 ) { + if (duration >= 60 ) { this.saveStudyDuration(duration); } return; @@ -1339,13 +1367,16 @@ //如果当前追加开始时间不为空 let now = new Date(); let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数 - let sen = parseInt(m / 1000); //计算秒数 - duration = duration + $this.appentInterval/1000;//追加的是秒 + let sen = Math.round(m / 1000); //计算秒数 + // 每次添加的是定时器计时的时间 + duration = duration + sen;//追加的是秒 if (sen>=60) { //一分钟保存一次 this.saveStudyDuration(duration); } else { studyUtil.setStudyDuration(duration); //添加到本地存储中 } + //重新覆盖时间 + this.appendStartTime = new Date(); //启动下次追加学习时长 this.appendHandle = setTimeout(function() { $this.appendStudyTime(); @@ -1360,31 +1391,44 @@ if (!this.curContent.id) { return; } - let postData={ - "key": "StudyCourseOther",//课程学习的key - "title": "非音视频课内容",//事件的标题 - "parameters":"second:60",//second:value 本次的学习时长 - "content": "学习课程",//事件的内容 - "objId": this.courseInfo.id,//课程的id - "objType": "1",//类型 - "source":"h5", - "objInfo": ""+this.courseInfo.name, - "aid":this.userInfo.aid, //当前登录人的id - "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; + let startTime = new Date().getTime(); + this.appendStudyOtherHandle = setTimeout(function() { + let endTime = new Date().getTime(); + let totalTime = Math.round((endTime - startTime) / 1000); + $this.cumulativeDuration += totalTime; + if($this.cumulativeDuration <= $this.maxDuration){ + //静默处理 + $this.sendOtherTime(totalTime) + $this.appendStudyOtherTime(); + }else{ + clearTimeout(this.appendStudyOtherHandle); + $this.cumulativeDuration = 0; + $this.maxDuration = 0; + } + }, 1000*60); + + }, + sendOtherTime(totalTime){ + apiStat.sendEvent({ + "key": "StudyCourseOther",//课程学习的key + "title": "非音视频课内容",//事件的标题 + "parameters":"second:" + totalTime,//second:value 本次的学习时长 + "content": "学习课程",//事件的内容 + "objId": this.courseInfo.id,//课程的id + "objType": "1",//类型 + "source":"h5", + "objInfo": ""+this.courseInfo.name, + "aid":this.userInfo.aid, //当前登录人的id + "aname":this.userInfo.name,//当前人的姓名 + "status": 1 //状态 + }).then(rs=>{ + if(rs.status != 200) { + console.log(rs.message); + } + }); }, //先保存学习的内容,针对于音视频的内容 saveStudyItem(){ From 1f635ae52875b34d8ad38ab50007cf3db0dcfcbc Mon Sep 17 00:00:00 2001 From: nisen Date: Mon, 20 Nov 2023 17:31:12 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/study/courseStudy.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/study/courseStudy.vue b/pages/study/courseStudy.vue index 66dbf7a..c5a3a49 100644 --- a/pages/study/courseStudy.vue +++ b/pages/study/courseStudy.vue @@ -1370,7 +1370,7 @@ let sen = Math.round(m / 1000); //计算秒数 // 每次添加的是定时器计时的时间 duration = duration + sen;//追加的是秒 - if (sen>=60) { //一分钟保存一次 + if (duration >= 60) { //一分钟保存一次 this.saveStudyDuration(duration); } else { studyUtil.setStudyDuration(duration); //添加到本地存储中 From 941de8ffc7c236f37dc4337fe24fe4be8babbe2d Mon Sep 17 00:00:00 2001 From: nisen Date: Tue, 21 Nov 2023 14:58:39 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=9F=B3=E8=A7=86=E9=A2=91=E6=B3=A8?= =?UTF-8?q?=E9=87=8AonHide=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/study/courseStudy.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/study/courseStudy.vue b/pages/study/courseStudy.vue index c5a3a49..34427be 100644 --- a/pages/study/courseStudy.vue +++ b/pages/study/courseStudy.vue @@ -558,8 +558,9 @@ }, onHide(){ - //清除定时任务 - this.clearTimeHandle(); + //清除定时任务,隐藏的时候不清除,因为没有停止播放 + // this.clearTimeHandle(); + console.log('触发onHide'); }, destroyed() { this.clearTimeHandle();