cmy 1 tahun lalu
induk
melakukan
dd4623b182
1 mengubah file dengan 9 tambahan dan 4 penghapusan
  1. 9 4
      pages/index/entertainment.vue

+ 9 - 4
pages/index/entertainment.vue

@@ -283,11 +283,13 @@
 
 				},
 				// 保存获取下次游戏对象
-				getNextTimeObj: ''
+				getNextTimeObj: '',
+				// 判断是否当前页面中
+				loadPage:false,
 			};
 		},
-		onLoad() {},
 		onShow() {
+			this.loadPage = true;
 			if (!this.hasLogin) {
 				uni.showModal({
 					title: this.$t('enter.c4'),
@@ -309,6 +311,8 @@
 		},
 		// 关闭循环
 		onHide() {
+			this.loadPage = false;
+			console.log('隐藏');
 			// 倒计时清理
 			this.initData();
 		},
@@ -328,7 +332,7 @@
 				clearInterval(that.time.t);
 				// 清空倒计时对象
 				that.getNextTimeObj = '';
-				this.time = {
+				that.time = {
 					H: 0,
 					M: 0,
 					S: 0,
@@ -558,7 +562,8 @@
 					that.history.next = data.next_game || '';
 					that.history.now = data.now_game || '';
 					// 是否不存在启动中的活动并判断防止重复调用创建倒计时
-					if (!that.history.next && !that.getNextTimeObj) {
+					// 判断是否不存在游戏,并且没有倒计时对象,且在当前页面
+					if (that.loadPage&&!that.history.next && !that.getNextTimeObj) {
 						that.getNextTimeObj = setInterval(() => {
 							that.getGame(id)
 						}, 1000)