liujiaxin 3 týždňov pred
rodič
commit
3f71c01475

+ 24 - 25
pages/home/living.vue

@@ -404,6 +404,9 @@
 			// 	this.getliveUser(true); // 调用获取在线用户接口
 			// });
 			const platform = uni.getWindowInfo().platform;
+			// 初始化直播间列表
+			this.initLiveList(options);
+
 			if (['mp-weixin', 'mp-alipay', 'mp-baidu', 'mp-toutiao'].includes(platform)) {
 				// 确保 API 存在再调用
 				if (uni.showShareMenu) {
@@ -449,10 +452,10 @@
 			}
 		},
 		onHide() {
-			 const currentLive = this.list[this.currentSwiperIndex];
-			  if (currentLive) {
-			    this.pauseVideo(currentLive);
-			  }
+			const currentLive = this.list[this.currentSwiperIndex];
+			if (currentLive) {
+				this.pauseVideo(currentLive);
+			}
 		},
 		onUnload() {
 			// 关闭所有WebSocket连接
@@ -470,12 +473,12 @@
 				this.hlsPlayer = null;
 			}
 			this.list.forEach(liveItem => {
-			    const videoId = `myVideo_${liveItem.liveId}`;
-			    const videoContext = uni.createVideoContext(videoId, this);
-			    if (videoContext) {
-			      videoContext.destroy();
-			    }
-			  });
+				const videoId = `myVideo_${liveItem.liveId}`;
+				const videoContext = uni.createVideoContext(videoId, this);
+				if (videoContext) {
+					videoContext.destroy();
+				}
+			});
 		},
 		watch: {
 			// 监听orderUser.count的变化
@@ -648,13 +651,13 @@
 						this.getliveUser(false), // 重新请求新直播间的在线观众
 					]);
 
-					 if (oldLive) {
-					    this.pauseVideo(oldLive);
-					  }
-					  // 延迟100ms再播放新视频,避免冲突
-					  setTimeout(() => {
-					    this.playVideo(newLive);
-					  }, 100);
+					if (oldLive) {
+						this.pauseVideo(oldLive);
+					}
+					// 延迟100ms再播放新视频,避免冲突
+					setTimeout(() => {
+						this.playVideo(newLive);
+					}, 100);
 				} catch (error) {
 					console.error('切换直播间失败:', error);
 				}
@@ -702,9 +705,9 @@
 					const videoContext = uni.createVideoContext(videoId, this);
 					if (videoContext) {
 						videoContext.pause(() => {
-						        // 暂停完成后再播放
-						        videoContext.play();
-						      });
+							// 暂停完成后再播放
+							videoContext.play();
+						});
 					}
 				} catch (error) {
 					console.error("播放视频失败:", error);
@@ -771,7 +774,6 @@
 					}).exec();
 				});
 			},
-
 			// 重置直播间数据
 			resetLiveData() {
 				// 保留不需要重置的数据(如用户信息等)
@@ -1584,10 +1586,7 @@
 						// 	liveItem.redanswertips = JSON.parse(liveItem.redanswerAll[0]
 						// 		.randomAmount)
 						// }
-
-
 					}
-
 				} else {
 					uni.showToast({
 						title: data.msg,
@@ -1652,7 +1651,7 @@
 					success: () => {
 						console.log("发送成功");
 						// liveItem.value = ''; // 清空当前直播间的输入框
-						 this.$set(liveItem, 'value', '');
+						this.$set(liveItem, 'value', '');
 					},
 					fail: (err) => {
 						console.error("发送失败:", err);

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
unpackage/dist/dev/mp-weixin/pages/home/living.js


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov