diff --git a/src/api/modules/courseStudy.js b/src/api/modules/courseStudy.js index fe0bffd2..11fca357 100644 --- a/src/api/modules/courseStudy.js +++ b/src/api/modules/courseStudy.js @@ -114,6 +114,10 @@ const studyVideoTime = function(data) { return ajax.post('/xboe/school/study/course/study-video-time',data); } +const updateStudyVideoTime = function(data) { + return ajax.post('/xboe/school/study/course/updateStudyVideoTime',data); +} + /** * 获取上一次的学习内容 * @returns @@ -408,6 +412,7 @@ export default { studyIndex, studyInfo, studyVideoTime, + updateStudyVideoTime, lastStudy, studyContent, appendStudyTime, diff --git a/src/components/VideoPlayer/index.vue b/src/components/VideoPlayer/index.vue index 7de2f936..9a652683 100644 --- a/src/components/VideoPlayer/index.vue +++ b/src/components/VideoPlayer/index.vue @@ -512,6 +512,7 @@ export default { this.currentProgress = progressVideo; this.barrageTimelineStart = newCurrentTime; this.videoDom.currentTime = newCurrentTime; + this.updateProgressText(); }, /* 提高视频音量 */ diff --git a/src/views/portal/course/Micro.vue b/src/views/portal/course/Micro.vue index 9d725e98..aa472593 100644 --- a/src/views/portal/course/Micro.vue +++ b/src/views/portal/course/Micro.vue @@ -225,7 +225,7 @@ - + @@ -653,7 +653,7 @@ export default { itemId:this.coursewareInfo.studyItemId, videoTime:intTime } - apicourseStudy.studyVideoTime(postData).then(rs=>{ + apicourseStudy.updateStudyVideoTime(postData).then(rs=>{ if(rs.status!=200){ console.log('记录播放时间错误'); } @@ -693,7 +693,7 @@ export default { itemId:this.coursewareInfo.studyItemId, videoTime:intTime } - apicourseStudy.studyVideoTime(postData).then(rs=>{ + apicourseStudy.updateStudyVideoTime(postData).then(rs=>{ if(rs.status!=200){ console.log('记录播放时间错误'); } diff --git a/src/views/study/PortalIndex.vue b/src/views/study/PortalIndex.vue index ba635349..d5161afe 100644 --- a/src/views/study/PortalIndex.vue +++ b/src/views/study/PortalIndex.vue @@ -1,1493 +1,1493 @@ - - - - - + + + + + diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index 7382c602..cc6143a8 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -467,7 +467,6 @@ this.stopStudyTime();//先关闭 this.cleanAppendTime();// this.loadData(); - //console.log(this.$xpage.constants.fileBaseUrl,'this.$xpage.constants.fileBaseUrl'); }, computed: { ...mapGetters(['userInfo']), @@ -511,14 +510,12 @@ }, methods: { handleOpen(key,path){ - // console.log(key,path,'handleOpen') if(this.isFalse){ this.defaultOpeneds = [key] } this.isFalse = false }, handleClose(key,path){ - // console.log(key,path,'handleClose') }, toUserHome(tea){ this.$router.push({path:this.$xpage.getHomePath(tea.teacherId)}) @@ -591,9 +588,7 @@ let $this=this; if(this.contentData.id==contentId){ this.onPlayerPause() - //this.audioPause(); this.contentData.lastStudyTime=time; - //this.onPlayerPlay(); setTimeout(() => { $this.$refs.myVideoPlayer.startPlay(time); }, 10) @@ -610,7 +605,6 @@ if(toResContent){ this.changePlayRes(toResContent); - //this.onPlayerPlay(); setTimeout(() => { $this.$refs.myVideoPlayer.startPlay(time); }, 10) @@ -621,18 +615,9 @@ } } this.playerBoxShow = false; - //this.changePlayRes(r); - // this.playerBoxShow = false; - // this.notePlay = null; - // let $this=this; - // setTimeout(() => { - // $this.notePlay = time; - // }, 500) }, //笔记组件触发,记录当前播放时间 videoLocation() { - //this.$store.dispatch("SetIntTimeNote", this.intTimeNote); - //console.log(this.contentData.id+'='+this.intTimeNote,'设置视频播放时间') this.$refs.mynote.setVideoTime(this.contentData.id,this.intTimeNote); }, coutab(n) { @@ -642,9 +627,7 @@ let nowDate = new Date(); let ctime = parseInt(nowDate.getTime() / 1000); let beforeUrl = parseInt(nowDate.getTime() / 1000) + '/' + fid; - //console.log(beforeUrl,'beforeUrl'); let urlSign = encodeURIComponent(encrypt(beforeUrl)); - //console.log(urlSign,'urlSign'); cookies.set('PLAYSIGN_TIME', ctime); //写客户端的cookie保存 //以下判断是为了区分本地环境和服务器环境 if (process.env.NODE_ENV == 'development') { @@ -652,9 +635,7 @@ } else { this.blobUrl = process.env.VUE_APP_BASE_API + '/xboe/m/course/cware/resource?sign=' + urlSign; } - // console.log('this.contentData.id:',this.contentData.id) this.blobId = this.contentData.id - //console.log(this.blobUrl,'this.blobUrl'); }, widthOpen(url) { window.open(url, '_blank'); @@ -687,8 +668,6 @@ this.curriculumData.url = r.content; } this.$refs.mynote.showVideoTimeBtn(true); - //let url=process.env.VUE_APP_BASE_API+'/xboe/m/course/file/show?cf='+this.curriculumData.url; - //let url=this.fileBaseUrl+this.curriculumData.url; this.createPlayUrl(r.contentRefId, this.curriculumData.url); } else if (r.contentType == 40) { // if (r.content != '' && r.content.indexOf('.pdf') == -1) { @@ -787,7 +766,6 @@ }); $this.appendStudyOtherTime(); }, 15000); //非音视频课程学习,十五秒后记录 - //this.appendStudyTime(); this.isContentType = this.contentData.contentType if (this.contentData.contentType != 50) { this.handleTimeout = setTimeout(function(){ @@ -802,28 +780,23 @@ this.$nextTick(function(){ - if(this.contentData.progressVideo){ + if (r.contentType == 10) { + console.log('视频处理lastStudyTime',this.contentData.lastStudyTime) + console.log('视频处理progressVideo',this.contentData.progressVideo) this.$refs.myVideoPlayer.updateProgressByClickBar2(this.contentData.lastStudyTime,this.contentData.progressVideo); - // $this.notePlay = this.contentData.lastStudyTime; } - //let h0=document.getElementById('id_course_player').offsetHeight; let h=$this.$refs.coursePlayer.offsetHeight; - //let h1=$this.$refs.coursePlayer.clientHeight; - ///console.log(h0,h,$this.controlHeight,'$this.controlHeight'); //解决获取高度不正的问题 if(h>400 && h<500){ h=h+40; }else if(h>500){ h=h+60; } - //$this.controlHeight=h-99; $this.controlHeight=h-95; - //console.log(h,$this.controlHeight,'$this.controlHeight'); }) - //console.log('this.contentData11:',this.contentData,this.curriculumData) // 视频设置禁用处理逻辑,如果用户已全部观看完该视频,则设置为能全部拖动的逻辑,把isDrag设置为true即可,同时删除本地存储的数据 if(this.contentData.progressVideo ===1){ var obj = JSON.parse(this.contentData.content) @@ -1131,38 +1104,16 @@ }); } else { - //console.log('加载课程信息失败:'+res.error); - //this.$message.error(res.message); } }); }, onPlayerPlay() { - //console.log("开始播放"); - // if(this.contentData.contentType == 10){ - // if(this.contentData.status<2){ - // this.contentData.status = 2; - // } - // } this.playerBoxShow = false; - // this.onPlayerPlayFullscreen() - // this.$watermark.set(this.userInfo.name + this.userInfo.loginName); let $this = this; //这里有些不准备,如果文件未能加载,这个事件就是错误的 this.isAppendTime=true; this.appendStudyTime();//启动追加学习时长 - //console.log(this.contentData.status,'this.contentData.status'); - // if(this.contentData.status<9){ - // let completeType=this.curriculumData.completeSetup; - // //console.log(completeType,'completeType'); - // if(completeType==0){ - // //默认5秒后学习完成. - // $this.handleTimeout= setTimeout(function() {$this.saveStudyInfo();}, 5000); //5秒后记录学习完成 - // }else{ - // //先记录进行中的学习内容 - // this.saveStudyItem(); - // } - // } }, onFullscreen(full) { @@ -1194,7 +1145,6 @@ } }, onPlayerPause() { - //console.log("暂停"); this.stopStudyTime(); }, onPlayerEnded() { @@ -1207,8 +1157,6 @@ onPlayerPlaying(itme) { this.isAppendTime = true;//可以追加学习时长 this.intTimeNote = parseInt(itme); - //console.log("当前播放"+itme); - //console.log("当前播放11"+itme); if (this.contentData.contentType && this.contentData.contentType == 10) { let intTime = parseInt(itme); //判断是否完成 @@ -1238,7 +1186,13 @@ this.contentData.lastStudyTime = intTime; let postData = { itemId: this.contentData.studyItemId, - videoTime: intTime + videoTime: intTime, + id: this.appentId, + studyId: this.studyId, + courseId: this.contentData.courseId, + contentId: this.contentData.id, + studyInfo: this.courseInfo.name +"-" +this.contentData.contentName, + duration: 10 }; //console.log('this.courseInfo:',this.contentData) if(!this.curriculumData.isDrag && this.contentData.progressVideo !=1){ @@ -1246,22 +1200,24 @@ var arr = time&&JSON.parse(time) || {} if(arr[this.blobId] && this.contentData.progressVideo { + apiStudy.updateStudyVideoTime(postData).then(rs => { if (rs.status != 200) { console.log('记录播放时间错误'); + }else{ + studyUtil.clearStudyDuration(); //清除本地存储 } }); } } }, audioPlaying(item, currentTime) { - //console.log("当前播放"+item); let intTime = parseInt(currentTime); + console.log("======音频播放"+intTime); this.handleAudioTimeUpdate(intTime) //判断是否完成 let completeType = this.curriculumData.completeSetup; @@ -1290,7 +1246,13 @@ this.contentData.lastStudyTime = intTime; let postData = { itemId: this.contentData.studyItemId, - videoTime: intTime + videoTime: intTime, + id: this.appentId, + studyId: this.studyId, + courseId: this.contentData.courseId, + contentId: this.contentData.id, + studyInfo: this.courseInfo.name +"-" +this.contentData.contentName, + duration: 10 }; //console.log('this.courseInfo:',this.contentData) if(!this.curriculumData.isDrag && this.contentData.progressVideo !=1){ @@ -1298,23 +1260,21 @@ var arr = time&&JSON.parse(time) || {} if(arr[this.blobId] && this.contentData.progressVideo { + apiStudy.updateStudyVideoTime(postData).then(rs => { if (rs.status != 200) { console.log('记录播放时间错误'); + }else{ + studyUtil.clearStudyDuration(); //清除本地存储 } }); } }, audioPlay() { - //console.log("开始播放"); - // if(this.contentData.contentType == 20 && this.contentData.status < 2){ - // this.contentData.status = 2; - // } let $this = this; this.isAppendTime=true; this.appendStudyTime();//启动追加学习时长 @@ -1425,7 +1385,6 @@ //处理内容的名称 this.totalContent = rs.result.contents.length; //加载学习的数据 - //this.loadStudyData(); this.loadStudyData(rs.result); } else { @@ -1440,6 +1399,7 @@ //对已学习的内容进行比对,重要的字段, 学习内容id,在后缀的 let playIndex = -1; this.contentList.forEach((con, conIdx) => { + con.progressVideo = con.progressVideo || 0; result.contentStudys.forEach((scon, sconIdx) => { if (scon.contentId == con.id) { //定位显示的内容 @@ -1451,9 +1411,8 @@ playIndex = conIdx; } } - //console.log(scon.contentId,con.id); con.lastStudyTime = scon.lastStudyTime; - con.progressVideo = scon.progressVideo; + con.progressVideo = scon.progressVideo || 0; //以下判断是为了兼容之前的问题,学习状态 if (scon.status) { con.status = scon.status; @@ -1461,23 +1420,17 @@ con.status = 9; } con.studyItemId = scon.id; //这个就是学习内容(条目)的id - //console.log(scon.id,"scon.id"); - //console.log(con,"scon.id"); } }); }); if (this.courseInfo.type == 10) { - ///console.log(this.contentList[0],'ccccc11111') this.showRes(this.contentList[0]); } else { //如果没有,就定位第一项内容 if (playIndex === -1) { - // this.showRes(this.contentList[0]); - //console.log(this.catalogTree,'ccccc22222') this.showRes(this.catalogTree[0].children[0]) } else { - //console.log(this.contentList[0],'ccccc3333') this.showRes(this.contentList[playIndex]); } } @@ -1592,22 +1545,23 @@ 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); - } - }); + // 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, + // type: 1 + // }; + // apiStudy.updateStudyVideoTime(postAppendData).then(rs => { + // if (rs.status == 200) { + // this.appentId = rs.result; + // studyUtil.clearStudyDuration(); //清除本地存储 + // } else { + // console.log(rs.message); + // } + // }); } }, //结束追加学习时长 @@ -1647,60 +1601,6 @@ 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) { @@ -1782,7 +1682,6 @@ }) this.trueFalse = false } - // } }, }, }