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