Browse Source

去除课程缓存

wangguoyu 1 month ago
parent
commit
37bd6d0424
1 changed files with 44 additions and 95 deletions
  1. 44 95
      pages/client/Kecheng/study.vue

+ 44 - 95
pages/client/Kecheng/study.vue

@@ -96,42 +96,15 @@
 		},
 		methods: {
 			handlePlayFirst() {
-				let sectionPage = getKechengSectionPageFromHistory(this.operId)
-				if (sectionPage) {
-					const {
-						zhangIndex,
-						jieIndex
-					} = getCurKjIndex(sectionPage.kjId,this.operId)
-					sectionPage.iChapter = zhangIndex;
-					sectionPage.iSection = jieIndex;
-					sectionPage.kjId = sectionPage.kjId;
-					sectionPage.operId = this.operId;
-					
+				if (this.list && this.list[0].jieList && this.list[0].jieList[0].kejianList) {
 					// 设置默认展开项
-					this.list[zhangIndex].open = true;
-					this.list[zhangIndex].jieList[jieIndex].open = true;
-					
-					const kejian = this.list[0].jieList && this.list[zhangIndex].jieList[jieIndex].kejianList.find(item => item.kjId ==sectionPage.kjId )
+					this.list[0].open = true;
+					this.list[0].jieList[0].open = true;
+					// 设置播放可见
+					const kejian = this.list[0].jieList[0].kejianList[0];
 					this.handlePlay(kejian)
-				} else {
-					if (this.list && this.list[0].jieList && this.list[0].jieList[0].kejianList) {
-						// 设置默认展开项
-						this.list[0].open = true;
-						this.list[0].jieList[0].open = true;
-						// 设置播放可见
-						const kejian = this.list[0].jieList[0].kejianList[0];
-						this.handlePlay(kejian)
-						// 更新缓存
-						sectionPage = {
-							kjId: kejian.kjId,
-							iChapter: 0,
-							iSection: 0,
-							operId: this.operId
-						}
-					}
+					
 				}
-						
-				saveKechengSectionPage(this.operId, sectionPage)
 			},
 			onPause() {
 				clearInterval(this.timer1);
@@ -140,9 +113,9 @@
 			onPlay() {
 				clearInterval(this.timer1);
 				this.timer1 = null;
-				this.timer = setInterval(() => {
-					updateSectionProgress(this.operId);
-				}, 1000 * 1 * 60) // 自动保存进度 1分钟已保存
+			// 	this.timer = setInterval(() => {
+			// 		updateSectionProgress(this.operId);
+			// 	}, 1000 * 1 * 60) // 自动保存进度 1分钟已保存
 			
 			},
 			sectionPlayerProgress(progress) {
@@ -166,18 +139,18 @@
 				const progress = parseInt(time / this.curPlayData.duration * 100);
 				this.curPlayData.curProgress = parseInt(progress >= 100 ? '99' : progress);
 				// 保存进度
-				saveCourseProgress(time, this.curPlayData.duration, this.operId)
+			//	saveCourseProgress(time, this.curPlayData.duration, this.operId)
 				// 更新进度
-				this.sectionPlayerProgress(progress)
+			//	this.sectionPlayerProgress(progress)
 			},
 			onPlayEnd() {
 				clearInterval(this.timer1);
 				this.timer1 = null;
-				saveCourseProgress(this.curPlayData.duration, this.curPlayData.duration, this.operId, 'end');
-				updateSectionProgress(this.operId, 'end', 'video', () => {
-					this.curPlayData.maxProcess = 99;
-					this.curPlayData.curProcess = 99;
-				});
+				// saveCourseProgress(this.curPlayData.duration, this.curPlayData.duration, this.operId, 'end');
+				// updateSectionProgress(this.operId, 'end', 'video', () => {
+				// 	this.curPlayData.maxProcess = 99;
+				// 	this.curPlayData.curProcess = 99;
+				// });
 				console.log('end')
 			},
 			goUpPage() {
@@ -231,7 +204,7 @@
 				sectionPage.iSection = jieIndex;
 				sectionPage.kjId = data.kjId;
 				sectionPage.operId = this.operId;
-				saveKechengSectionPage(this.operId, sectionPage)
+			//	saveKechengSectionPage(this.operId, sectionPage)
 				kechengApi.getVideoAuth({
 					videoId: data.url
 				}).then(res => {
@@ -246,42 +219,18 @@
 				})
 			},
 			initFirstVideo() {
-				let sectionPage = getKechengSectionPageFromHistory(this.operId)
-				if (sectionPage) {
-					const {
-						zhangIndex,
-						jieIndex
-					} = getCurKjIndex(sectionPage.kjId,this.operId)
-					sectionPage.iChapter = zhangIndex;
-					sectionPage.iSection = jieIndex;
-					sectionPage.kjId = sectionPage.kjId;
-					sectionPage.operId = this.operId;
-					
-					// 设置默认展开项
-					this.list[zhangIndex].open = true;
-					this.list[zhangIndex].jieList[jieIndex].open = true;
-					
-					const kejian = this.list[0].jieList && this.list[zhangIndex].jieList[jieIndex].kejianList.find(item => item.kjId ==sectionPage.kjId )
-					// this.handlePlay(kejian)
-				} else {
-					if (this.list && this.list[0].jieList && this.list[0].jieList[0].kejianList) {
-						// 设置默认展开项
-						this.list[0].open = true;
-						this.list[0].jieList[0].open = true;
-						// 设置播放可见
-						const kejian = this.list[0].jieList[0].kejianList[0];
-						// this.handlePlay(kejian)
-						// 更新缓存
-						sectionPage = {
-							kjId: kejian.kjId,
-							iChapter: 0,
-							iSection: 0,
-							operId: this.operId
-						}
-					}
-				}
+				
+			if (this.list && this.list[0].jieList && this.list[0].jieList[0].kejianList) {
+				// 设置默认展开项
+				this.list[0].open = true;
+				this.list[0].jieList[0].open = true;
+				// 设置播放可见
+				const kejian = this.list[0].jieList[0].kejianList[0];
+				// this.handlePlay(kejian)
+			
+			}
 		
-				saveKechengSectionPage(this.operId, sectionPage)
+				//saveKechengSectionPage(this.operId, sectionPage)
 			},
 
 			init() {
@@ -304,25 +253,25 @@
 					this.list = kejianUserVo.zhangList;
 					this.intro = intro;
 					this.operId = operId;
-
+					
 					// 获取课程缓存 && 课件缓存(课件缓存点击后产生)
-					let historyArrKecheng = getKechengDataFromHistory(this.operId)
-					let sectionPageHistory = getKechengSectionPageFromHistory(this.operId)
-					// 判断是否有前台缓存
-					if (historyArrKecheng && sectionPageHistory) {
-						// 有缓存---- 把start接口中,返回数据进度100%,更新到前台缓存
-						const arrKecheng = mergeProgress(kejianUserVo && kejianUserVo.zhangList,
-							historyArrKecheng);
-						// 后台数据 同步前台缓存
-						saveKechengData(this.operId, arrKecheng)
-					} else {
-						// 无缓存----把start接口中,返回的所有数据,更新到前台缓存
-						saveKechengData(this.operId, kejianUserVo && kejianUserVo.zhangList)
-					}
+					//let historyArrKecheng = getKechengDataFromHistory(this.operId)
+				//	let sectionPageHistory = getKechengSectionPageFromHistory(this.operId)
+					// // 判断是否有前台缓存
+					// if (historyArrKecheng && sectionPageHistory) {
+					// 	// 有缓存---- 把start接口中,返回数据进度100%,更新到前台缓存
+					// 	const arrKecheng = mergeProgress(kejianUserVo && kejianUserVo.zhangList,
+					// 		historyArrKecheng);
+					// 	// 后台数据 同步前台缓存
+					// 	saveKechengData(this.operId, arrKecheng)
+					// } else {
+					// 	// 无缓存----把start接口中,返回的所有数据,更新到前台缓存
+					// 	saveKechengData(this.operId, kejianUserVo && kejianUserVo.zhangList)
+					// }
 					// 初始化页面 常规数据
-					initCourseProgressAll(this.operId)
+					//initCourseProgressAll(this.operId)
 
-					console.log('初始化播放首次')
+					console.log('初始化播放首1123次')
 					// 设置播放视频
 					this.initFirstVideo();
 				}).catch(err => {