浏览代码

fix 随机拍

he2802 3 年之前
父节点
当前提交
3e03240f33
共有 3 个文件被更改,包括 28 次插入22 次删除
  1. 2 2
      components/course/courseSection.vue
  2. 1 1
      pages2/wd/course.vue
  3. 25 19
      pages3/polyv/detail.vue

+ 2 - 2
components/course/courseSection.vue

@@ -11,8 +11,8 @@
 				<view v-if="menuItem.sectionType==3" :class="playSectionId==newId?'color3':''">{{menuItem.name}}</view>
 					<view style="font-size: 20rpx;color: #FF3B30;" v-if="menuItem.liveStartTime">
 						<view v-if="menuItem.liveStartTime>nowTime">
-							<text>{{$method.timestampToTime(menuItem.liveStartTime)}}</text>-
-							<text>{{$method.timestampToTime(menuItem.liveEndTime)}}</text>
+							<text>{{$method.timestampToTime(menuItem.liveStartTime, isDay =false)}}</text>-
+							<text>{{$method.timestampToTime(menuItem.liveEndTime, isDay =false).substr(11,9)}}</text>
 						</view>
 						<view v-if="menuItem.liveStartTime<=nowTime&&menuItem.liveEndTime>nowTime">
 							<text>直播中</text>

+ 1 - 1
pages2/wd/course.vue

@@ -62,7 +62,7 @@ export default {
 			}); 
 		},
 		studyIn(item) {
-			this.$navTo.togo('/pages2/class/detail', {
+			this.$navTo.togo('/pages3/polyv/detail', {
 				id: item.courseId,
 				goodsId: this.goodsId
 			});

+ 25 - 19
pages3/polyv/detail.vue

@@ -398,6 +398,8 @@ export default {
 		uni.$on('getSection', item => {
 			//清除直播
 			this.$store.commit('setPlayChannelId', { playChannelId: 0 });
+			//获取拍照历史
+			this.getPhotoLastRecord()
 			this.playVideo(item);
 		});
 		uni.$on('levelId', item => {
@@ -440,6 +442,7 @@ export default {
 				currentTime = polyvPlayerContext.getCurrentTime();
 			}
 			let self = this;
+			let photoIndex = self.photoIndex-1
 			let data = {
 				photo: self.ossAvatarUrl,
 				sectionId: parseInt(self.playSectionId),
@@ -447,7 +450,7 @@ export default {
 				courseId: parseInt(self.courseId),
 				photoTime: parseInt(currentTime > 0 ? currentTime : 0),
 				gradeId: parseInt(self.gradeId),
-				photoIndex: parseInt(self.photoIndex-1),//从0算起
+				photoIndex: parseInt(photoIndex),//从0算起
 				photoNum:parseInt(self.photoNum)
 			};
 			console.log('提交接口', data);
@@ -484,25 +487,30 @@ export default {
 					this.photoNum = 1 //只要设置,至少拍一次
 					spaceTime = totalVideoTime
 				}
-				let initSpace = 2
+				let initSpace = 0
 				this.photoList = []
 				for(let i=0;i<this.photoNum;i++){
 					let s = this.randomNum(initSpace,initSpace+spaceTime)
 					if(s>totalVideoTime){
 						s = totalVideoTime-1
 					}
+					if(s<2){
+						s =1
+					}
 					this.photoList.push(s)
 					initSpace+=spaceTime
 				}
-				console.log(this.photoList,"随机拍时间数组")
+				console.log(this.photoList,"随机拍时间数组",this.photoNum)
 				//兼容已有观看历史
 				for(let i=0;i<this.photoList.length-1;i++){
 					if(this.photoList[i]<duration&&this.photoList[i+1]>duration){
 						this.photoIndex = i+1
+						console.log("我的修改了photoIndex")
 						break
 					}
 					if(duration>this.photoList[this.photoList.length-1]){
 						this.photoIndex = this.photoList.length-1 //取最后一个下标
+						console.log("1我的修改了photoIndex")
 						break
 					}
 				}
@@ -522,8 +530,8 @@ export default {
 		timeEventLiving() {
 			if (plv != null) {
 				if(this.livePlay){
-					this.liveDuration = this.liveDuration +1.5 //每隔1.5
-					if(this.liveDuration==1.5){ //第6秒拍照
+					this.liveDuration = this.liveDuration +1 //每隔1秒
+					if(this.liveDuration==2){ //直播第2秒拍照
 						if(this.goodsPhotographConfig){
 							if(this.goodsPhotographConfig.livephotograph==1){
 								//开启直播拍照
@@ -545,7 +553,7 @@ export default {
 			  	clearInterval(this.timer);
 			  }
 			  this.livePlay = true
-			  this.timer = setInterval(this.timeEventLiving, 1500); //定时器
+			  this.timer = setInterval(this.timeEventLiving, 1000); //定时器
 		    }
 		    if (status === 'end') {
 				this.livePlay = false
@@ -856,10 +864,13 @@ export default {
 			let currentTime = 0;
 			var polyvPlayerContext = this.selectComponent('#playerVideo');
 			if (polyvPlayerContext) {
-				currentTime = polyvPlayerContext.getCurrentTime();
+				currentTime = polyvPlayerContext.getCurrentTime(); //录播回放
+			}
+			if(this.playChannelId>0){
+				currentTime = 2;//直播 
 			}
 			let self = this;
-			console.log(self.ossAvatarUrl,"准备提交,照片地址")
+			console.log(self.ossAvatarUrl,"准备提交学习记录")
 			let data = {
 				photo: self.ossAvatarUrl,
 				sectionId: parseInt(sectionId),
@@ -870,10 +881,7 @@ export default {
 				chapterId: parseInt(self.chapterId),
 				moduleId: parseInt(self.moduleId)
 			};
-			if (data.studyDuration <= 5) {
-				//5秒内不上传记录
-				return;
-			}
+			
 			if (status > 0) {
 				data.status = status;
 			}
@@ -982,15 +990,15 @@ export default {
 						if(nextIndex<this.photoList.length){
 							nextTime = Number(this.photoList[nextIndex]); //获取下次拍照秒数
 						}
-						
 						if (photoTime < this.playTime) {
 							if(this.photoHistoryList.indexOf(this.photoIndex)<0){ //不存在拍照历史则拍照
 								//启动拍照
 								//暂停
 								polyvPlayerContext.exitFullScreen();
 								polyvPlayerContext.pause();
-								this.openPhoto();
 								this.photoIndex++;
+								this.openPhoto();
+								
 							}
 							
 							
@@ -1002,8 +1010,6 @@ export default {
 		},
 		onStateChange(newstate, oldstate) {
 			if (newstate.detail.newstate == 'playing') {
-				//获取拍照历史
-				this.getPhotoLastRecord()
 				if (this.needSeek) {   
 					var polyvPlayerContext = this.selectComponent('#playerVideo');
 					polyvPlayerContext.seek(this.recordObj.studyDuration);
@@ -1014,7 +1020,7 @@ export default {
 				if (this.timer) {
 					clearInterval(this.timer);
 				}
-				this.timer = setInterval(this.timeEvent, 1500); //定时器
+				this.timer = setInterval(this.timeEvent, 1000); //定时器
 			}
 			if (newstate.detail.newstate == 'pause') {
 				//暂停提交记录
@@ -1044,7 +1050,7 @@ export default {
 			if (polyvPlayerContext != null) {
 				polyvPlayerContext.play();
 			}
-			console.log(this.ossAvatarUrl, '拍照完成456');
+			
 		},
 		//确认拍照
 		takePhoto() {
@@ -1114,7 +1120,7 @@ export default {
 		},
 		getAnswerList() {
 			let self = this;
-			this.$api.answerList({ courseId: this.courseId }).then(res => {
+			this.$api.answerList({ courseId: this.courseId,goodsId: this.goodsId }).then(res => {
 				if (res.data.code == 200) {
 					self.answerList = res.data.rows;
 				}