From f088eaa62a69347e9858dcb961bb704efbfad21d Mon Sep 17 00:00:00 2001 From: daihh Date: Tue, 15 Nov 2022 19:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/study/courseStudy.vue | 138 ++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 61 deletions(-) diff --git a/pages/study/courseStudy.vue b/pages/study/courseStudy.vue index 968c495..fc4d8e6 100644 --- a/pages/study/courseStudy.vue +++ b/pages/study/courseStudy.vue @@ -533,6 +533,12 @@ onReady() { this.videoPlayer=uni.createVideoContext("myVideo", this); }, + onHide(){ + //清除定时任务 + if(this.appendStudyOtherHandle!=null){ + window.clearTimeout(this.appendStudyOtherHandle); + } + }, methods:{ ...mapActions({ // getResOwnerTree:'resOwner/getResOwnerTree', @@ -685,66 +691,8 @@ } } } - - // console.log(con,'con'); - if(this.videoPlayer){ - //console.log('切换视频'); - this.videoPlayer.stop(); - } - this.playerBoxShow=false; - if(con.contentType==40){ - //如果是文档,需要再次加载pdf - if(con.content!='' && con.content.indexOf('.pdf')==-1){ - // 先置空,否则会有延迟 - con.content = ''; - apiCourseFile.detail(con.contentRefId).then(cfrs=>{ - if(cfrs.status==200){ - con.content=cfrs.result.previewFilePath; - //console.log(r.content); - }else{ - $this.$refs.messager.show({message:'加载pdf课件文件失败',type:'error'}); - } - }); - } - }else if(con.contentType==52){ - if(con.content.startsWith('\{')){ - this.conLink=JSON.parse(con.content); - }else{ - this.conLink.url=con.content; - this.conLink.openType=1; - } - } else if(con.contentType==10 || con.contentType==20) { - - if(con.content.startsWith('\{')){ - this.curriculumData=JSON.parse(con.content); - }else{ - this.curriculumData.url=con.content; - } - this.blobUrl=this.fileBaseUrl+this.curriculumData.url; - console.log(this.blobUrl,'this.blobUrl'); - } - this.curContent=con; - this.catalogShow=false; - this.scoreInfo.itemId=con.id; - if(this.curContent.status<2){ - this.curContent.status=2; //设置状态 进行中 - } - //横向滚动条定位 - let len=0; - this.scrollList.some((sitem,idx)=>{ - if(sitem.id==con.id){ - len=idx; - return true; - } - return false; - }) - this.scrollInfo.scrollLeft=len*this.scrollItemWidth+len*6; - if(con.contentType>20){ - let $this=this; - //非视频,音频的5秒后学习完成 - this.handleTimeout = setTimeout(function(){$this.saveStudyInfo();},5000); - } - + //切换播放内容 + this.changePlayRes(con); }, loadReCourses(){ let dto={ @@ -821,6 +769,73 @@ }); }, + //更换播放内容 + changePlayRes(con){ + // console.log(con,'con'); + if(this.videoPlayer){ + //console.log('切换视频'); + this.videoPlayer.stop(); + } + this.playerBoxShow=false; + if(con.contentType==40){ + //如果是文档,需要再次加载pdf + if(con.content!='' && con.content.indexOf('.pdf')==-1){ + // 先置空,否则会有延迟 + con.content = ''; + apiCourseFile.detail(con.contentRefId).then(cfrs=>{ + if(cfrs.status==200){ + con.content=cfrs.result.previewFilePath; + //console.log(r.content); + }else{ + $this.$refs.messager.show({message:'加载pdf课件文件失败',type:'error'}); + } + }); + } + }else if(con.contentType==52){ + if(con.content.startsWith('\{')){ + this.conLink=JSON.parse(con.content); + }else{ + this.conLink.url=con.content; + this.conLink.openType=1; + } + } else if(con.contentType==10 || con.contentType==20) { + + if(con.content.startsWith('\{')){ + this.curriculumData=JSON.parse(con.content); + }else{ + this.curriculumData.url=con.content; + } + this.blobUrl=this.fileBaseUrl+this.curriculumData.url; + console.log(this.blobUrl,'this.blobUrl'); + } + this.curContent=con; + this.catalogShow=false; + this.scoreInfo.itemId=con.id; + if(this.curContent.status<2){ + this.curContent.status=2; //设置状态 进行中 + } + //横向滚动条定位 + let len=0; + this.scrollList.some((sitem,idx)=>{ + if(sitem.id==con.id){ + len=idx; + return true; + } + return false; + }) + this.scrollInfo.scrollLeft=len*this.scrollItemWidth+len*6; + if(con.contentType>20){ + let $this=this; + //用户的学习时长,音视频课程学习,单独的处理,不再追加学习时长 + this.isAppendTime = false; + this.appendStudyOtherHandle = setTimeout(function() { + $this.appendStudyOtherTime(); + }, 1000*60*2); //非音视频课程学习,2分钟后记录,因为一次记录是60秒 + //this.appendStudyTime(); + //非视频,音频的5秒后学习完成 + this.handleTimeout = setTimeout(function(){$this.saveStudyInfo();},5000);//5秒后记录学习完成 + } + }, followUser(tea){ //实现关注处理 if(tea.followed){ @@ -1371,7 +1386,8 @@ 9:'finish', } return statusObj[status] - } + }, + } }