Ver código fonte

视频课和直播课清除定时器

xuqiaoying 3 anos atrás
pai
commit
56fa67e611

+ 1 - 1
components/course/courseModule.vue

@@ -193,7 +193,7 @@ export default {
 					self.list = res.data.data
 				}
 			});
-			console.log('-----------list', this.list)
+			// console.log('-----------list', this.list)
 		},
 		/**
 		 * 去做题

+ 7 - 9
pages/index/index.vue

@@ -334,7 +334,6 @@ export default {
 		})
 	},
 	async onShow() {
-		console.log('-----couIndex', this.couIndex, this.courseId, this.courseName)
 		this.getInfo() // 判断有没有关注公众号		
 		this.isClickOff() //关注公众号,每天最多显示1次;当天学员关闭弹窗后,无需再显示
 		uni.removeStorageSync('goPath')
@@ -385,7 +384,7 @@ export default {
 		};
 	},
 	async onPullDownRefresh() {
-		console.log('下拉this.courseId:', this.courseId)
+		// console.log('下拉this.courseId:', this.courseId)
 		if (this.tabNum == 0) {
 			this.list1 = []
 			this.paramList[0].pageNum = 1
@@ -397,7 +396,7 @@ export default {
 		}
 	},
 	async onReachBottom() {
-		console.log('加载this.courseId:', this.courseId, this.list1.length, this.paramList[0].total)
+		// console.log('加载this.courseId:', this.courseId, this.list1.length, this.paramList[0].total)
 		if (this.tabNum == 0) {
 			if (this.list1.length < this.paramList[0].total) {
 				this.paramList[0].pageNum++
@@ -424,7 +423,6 @@ export default {
 	methods: {
 		...mapActions(['getUserInfo','appCommonConfig']),
 		tobuy(item) {
-			// console.log(item)
 			if (item.goodsType == 2) {
                 uni.navigateTo({
                     url: '/pages2/bank/detail?id='+item.goodsId
@@ -615,7 +613,7 @@ export default {
 			this.list2.push(...list2)
 		},
 		async changeSub(subjectId, index) {
-			console.log('subjectId, index:', subjectId, index, 'this.courseId:', this.courseId, 'this.bankId:', this.bankId)
+			// console.log('subjectId, index:', subjectId, index, 'this.courseId:', this.courseId, 'this.bankId:', this.bankId)
 			this.subIndex = index
 			this.courSubjectId = subjectId
 			this.paramList[this.tabNum].pageNum = 1 
@@ -652,7 +650,7 @@ export default {
 							recommendId: x.recommendId
 						}
 					});
-					console.log('couIndex', this.couIndex, this.courseName)
+					// console.log('couIndex', this.couIndex, this.courseName)
 					//题库
 					this.bankName = list.filter(x => x.type == 2).sort((a,b) => a.sort - b.sort).map(x => {
 						return {
@@ -668,7 +666,7 @@ export default {
 							courseId = this.courseName[0].recommendId
 							this.courseId = this.courseName[0].recommendId
 						}
-						console.log('courseId:', courseId)
+						// console.log('courseId:', courseId)
 						this.getSubjectList(courseId)
 						let list1 = await this.getGoodsList(courseId, 0, '')
 						this.list1.push(...list1)
@@ -697,7 +695,7 @@ export default {
 					recommendId: recommendId
 				}
 				subjectId && (params.subjectId = subjectId)
-				console.log('params:', params)
+				// console.log('params:', params)
 				this.$http({
 					url: `/app/common/activity/recommend/goodsList`,
 					method: 'get',
@@ -724,7 +722,7 @@ export default {
 				if (res.data.code == 200) {
 					let data = res.data.data || []
 					this.subjectList = [{ id: '', subjectName: '全部'}, ...data]
-					console.log('this.subjectList:', this.subjectList)
+					// console.log('this.subjectList:', this.subjectList)
 				}	
 			})
 		},

+ 7 - 7
pages3/live/detail.vue

@@ -784,6 +784,10 @@ export default {
   onUnload() {
     this.originUnload()
   },
+  onHide() {
+    console.log('index:--onHide')
+    this.originUnload()
+  },
   mounted() {
   },
   methods: {
@@ -971,14 +975,11 @@ export default {
       this.$store.commit("setPlayChannelId", { playChannelId: 0 });
       this.$store.commit("setPlayVID", { playVID: null });
       this.closePlv();
-      // console.log("onUnload");
       //移除所有的事件监听器
       uni.$off();
-      // clearInterval(this.answerTimer);
-      if (this.timer) {
-        clearInterval(this.timer);
-      }
-      // console.log(this.lockTimer, "this.lockTimer");
+      this.clearTimer && clearTimeout(this.clearTimer)
+      this.toastTimer && clearTimeout(this.toastTimer)
+      this.timer && clearInterval(this.timer);
       if (this.lockTimer) {
         clearInterval(this.lockTimer);
         this.$api
@@ -987,7 +988,6 @@ export default {
           })
           .then((res) => {});
       }
-      // websocket.sendMsg("delAction");
     },
     changeCourses() {
       this.toggleCourseShow = true

+ 13 - 20
pages3/polyv/detail.vue

@@ -748,6 +748,7 @@ export default {
       newActiveSubjectId: "", //当前选中ID
       compareFaceData: 0, // 拍照匹配相似度
       prendreAutoCarme: false, // 是否发起授权相机
+      studyTimer: null, // 学习记录定时器
     };
   },
   computed: {
@@ -804,6 +805,7 @@ export default {
   },
   onHide() {
     console.log('index:--onHide')
+    this.originUnload()
   },
   mounted() {
     console.log('index:--mounted')
@@ -812,7 +814,6 @@ export default {
     ...mapMutations(["updateChapterOpen","updateLiveLast"]),
     // 调用节的方法
     togoBack(value) {
-      // console.log('模块的节', value , this.$refs.MoudleSection)
       this.$refs.MoudleSection[0].ModuleExam()
     },
     // 新增微信公众号模板消息点击数据
@@ -823,7 +824,6 @@ export default {
         data: { informId: this.informId }
       }).then((res) => {
         if (res.data.code == 200) {
-          // console.log('埋点')
         }
       })
     },
@@ -1097,10 +1097,11 @@ export default {
       this.closePlv();
       //移除所有的事件监听器
       uni.$off();
-      // clearInterval(this.answerTimer);
-      if (this.timer) {
-        clearInterval(this.timer);
-      }
+      console.log('timer', this.timer, 'lockTimer:', this.lockTimer, 'studyTimer:', this.studyTimer);
+      this.clearTimer && clearTimeout(this.clearTimer)
+      this.toastTimer && clearTimeout(this.toastTimer)
+      this.studyTimer && clearInterval(this.studyTimer)
+      this.timer && clearInterval(this.timer)
       if (this.lockTimer) {
         clearInterval(this.lockTimer);
         this.$api
@@ -1111,7 +1112,6 @@ export default {
           .then((res) => {});
       }
       uni.removeStorageSync('current')
-      // websocket.sendMsg("delAction");
     },
     changeCourses() {
       this.toggleCourseShow = true
@@ -1789,6 +1789,7 @@ export default {
       return {};
     },
 		loadedmetadata(e) {
+      console.log('------: loadedmetadata', 'this.recordObj:', this.recordObj);
 			var polyvPlayerContext = this.selectComponent("#playerVideo");
 			this.hasStart = true;
 			uni.$off('playPause')
@@ -1798,9 +1799,10 @@ export default {
 			if(!this.recordObj.videoCurrentTime) { //新视频直接提交一条观看记录
 				this.postStudyRecord(0)
 			}
-      // setInterval(() => {
-      //   this.postStudyRecord(0)
-      // }, 15 * 1000)
+      this.studyTimer = setInterval(() => {
+        this.postStudyRecord(0)
+      }, 15 * 1000)
+      console.log('studyTimer:', this.studyTimer);
 		},
     getPhotoLastRecord() {
       let self = this;
@@ -2172,15 +2174,6 @@ export default {
           moduleId: this.moduleId || 0,
 					orderGoodsId: this.orderGoodsId,
         };
-        // if (this.playSectionId || this.playSectionId == 0) {
-        //   data.sectionId = Number(this.playSectionId)
-        // }
-        // if (this.chapterId || this.chapterId == 0) {
-        //   data.chapterId = parseInt(this.chapterId)
-        // }
-        // if (this.moduleId || this.moduleId == 0) {
-        //   data.moduleId = parseInt(this.moduleId)
-        // }
         this.$api.recordLast(data).then((res) => {
           resolve(res.data.data);
         });
@@ -2377,7 +2370,7 @@ export default {
       this.postAnswer();
     },
     postStudyRecord(status = 0, sectionId = this.playSectionId) {
-      // console.log("status", status);
+      console.log('学习记录接口的playSectionId', sectionId);
       let currentTime = 0;
       let PlayDuration = 0;
       var polyvPlayerContext = this.selectComponent("#playerVideo");