Bläddra i källkod

fix 随机拍照

he2802 3 år sedan
förälder
incheckning
3447332804
1 ändrade filer med 29 tillägg och 15 borttagningar
  1. 29 15
      pages3/polyv/detail.vue

+ 29 - 15
pages3/polyv/detail.vue

@@ -437,15 +437,24 @@ export default {
 						//清空历史数据
 						self.photoHistoryList = []
 						this.photoIndex = 0 
+						self.photoList = []
 						for(let i=0;i<res.data.data.length;i++){
-							self.photoHistoryList.push(res.data.data[i].photoIndex)
+							//-2存储随机拍照数组
+							 if(res.data.data[i].photoIndex==-2){
+								 self.photoList = res.data.data[i].timeInterval.split(',')
+							 }else{
+								 self.photoHistoryList.push(res.data.data[i].photoIndex)
+							 }
 						}
+						
+						
 					}
 					
 				});
 			
 		},
-		postCoursePhotoRecord() {
+		//postTime 只提交随机时间
+		postCoursePhotoRecord(postTime=false) {
 			let currentTime = 0;
 			var polyvPlayerContext = this.selectComponent('#playerVideo');
 			if (polyvPlayerContext) {
@@ -460,10 +469,11 @@ export default {
 				courseId: parseInt(self.courseId),
 				photoTime: parseInt(currentTime > 0 ? currentTime : 0),
 				gradeId: parseInt(self.gradeId),
-				photoIndex: parseInt(photoIndex),//从0算起
+				photoIndex: postTime?-2:parseInt(photoIndex),//从0算起,-2只提交随机时间
 				photoNum:parseInt(self.photoNum),
 				chapterId: parseInt(self.chapterId),
 				moduleId: parseInt(self.moduleId),
+				timeInterval: postTime?self.photoList.join(','):''
 			};
 			console.log('提交接口', data);
 			this.$api.coursePhotoRecord(data).then(res => {
@@ -500,17 +510,21 @@ export default {
 					spaceTime = totalVideoTime
 				}
 				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
+				//没有历史拍照间隔数据
+				if(this.photoList.length==0){
+					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
 					}
-					this.photoList.push(s)
-					initSpace+=spaceTime
+					console.log(this.photoList,"随机拍照时间数组11")
+					this.postCoursePhotoRecord(true)//提交随机拍照时间数组
 				}
 				console.log(this.photoList,"随机拍照时间数组")
 				//兼容已有观看历史
@@ -681,7 +695,7 @@ export default {
 			} else {
 				this.vid = item.recordingUrl;
 			}
-			this.recordObj = {studyDuration:item.noteSecond}
+			this.recordObj = {videoCurrentTime:item.noteSecond}
 			if (this.recordObj.studyDuration) {
 				this.needSeek = true; //需要跳转到播放记录
 			}
@@ -1036,7 +1050,7 @@ export default {
 			if (newstate.detail.newstate == 'playing') {
 				if (this.needSeek) {   
 					var polyvPlayerContext = this.selectComponent('#playerVideo');
-					polyvPlayerContext.seek(this.recordObj.studyDuration);
+					polyvPlayerContext.seek(this.recordObj.videoCurrentTime);
 					polyvPlayerContext.play();
 					this.needSeek = false;
 				}