|
@@ -1431,6 +1431,11 @@
|
|
|
clearInterval(this.trafficTimer);
|
|
clearInterval(this.trafficTimer);
|
|
|
this.trafficTimer = null;
|
|
this.trafficTimer = null;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 清除直播间数据定时器(防止页面隐藏后继续请求)
|
|
|
|
|
+ if (this.liveViewDataTimer) {
|
|
|
|
|
+ clearInterval(this.liveViewDataTimer);
|
|
|
|
|
+ this.liveViewDataTimer = null;
|
|
|
|
|
+ }
|
|
|
// 暂停观看时长统计
|
|
// 暂停观看时长统计
|
|
|
this.pauseWatchDurationTracking();
|
|
this.pauseWatchDurationTracking();
|
|
|
// 页面隐藏时清理部分数据,减少内存占用
|
|
// 页面隐藏时清理部分数据,减少内存占用
|
|
@@ -1486,7 +1491,11 @@
|
|
|
clearTimeout(this.getlivingTimer);
|
|
clearTimeout(this.getlivingTimer);
|
|
|
this.getlivingTimer = null;
|
|
this.getlivingTimer = null;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ // 显式清除直播间数据定时器(防止页面卸载后继续请求)
|
|
|
|
|
+ if (this.liveViewDataTimer) {
|
|
|
|
|
+ clearInterval(this.liveViewDataTimer);
|
|
|
|
|
+ this.liveViewDataTimer = null;
|
|
|
|
|
+ }
|
|
|
// 清除所有定时器(使用增强清理)
|
|
// 清除所有定时器(使用增强清理)
|
|
|
this.clearAllTimersEnhanced();
|
|
this.clearAllTimersEnhanced();
|
|
|
|
|
|
|
@@ -2458,7 +2467,7 @@
|
|
|
// 然后加载其他数据(并行执行,不阻塞视频加载)
|
|
// 然后加载其他数据(并行执行,不阻塞视频加载)
|
|
|
Promise.all([
|
|
Promise.all([
|
|
|
this.getLiveMsg(this.liveItem),
|
|
this.getLiveMsg(this.liveItem),
|
|
|
- this.getliveViewData()
|
|
|
|
|
|
|
+ //this.getliveViewData()
|
|
|
]).catch(err => {
|
|
]).catch(err => {
|
|
|
console.error('加载数据失败:', err);
|
|
console.error('加载数据失败:', err);
|
|
|
});
|
|
});
|
|
@@ -3782,7 +3791,7 @@
|
|
|
// 指数退避算法:基础延迟 * 2^(重连次数-1) + 随机抖动
|
|
// 指数退避算法:基础延迟 * 2^(重连次数-1) + 随机抖动
|
|
|
const baseDelay = 1000;
|
|
const baseDelay = 1000;
|
|
|
const exponentialDelay = baseDelay * Math.pow(2, this.reconnectCount - 1);
|
|
const exponentialDelay = baseDelay * Math.pow(2, this.reconnectCount - 1);
|
|
|
- const jitter = Math.random() * 1000; // 随机抖动,避免同时重连
|
|
|
|
|
|
|
+ const jitter = 10000 + Math.random() * 1000; // 随机抖动,避免同时重连
|
|
|
const totalDelay = Math.min(exponentialDelay + jitter, 30000); // 最大30秒
|
|
const totalDelay = Math.min(exponentialDelay + jitter, 30000); // 最大30秒
|
|
|
console.log(
|
|
console.log(
|
|
|
`第${this.reconnectCount}次重连,延迟${Math.round(totalDelay)}ms,网络类型:${this.networkType}`
|
|
`第${this.reconnectCount}次重连,延迟${Math.round(totalDelay)}ms,网络类型:${this.networkType}`
|
|
@@ -4841,7 +4850,7 @@
|
|
|
this.liveBeginWatchTime = this.getServerTimeNow();
|
|
this.liveBeginWatchTime = this.getServerTimeNow();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- this.startLiveViewDataTimer();
|
|
|
|
|
|
|
+ this.getliveViewData();
|
|
|
this.completionRecords();
|
|
this.completionRecords();
|
|
|
// 初始化观看时间统计
|
|
// 初始化观看时间统计
|
|
|
this.initWatchTime();
|
|
this.initWatchTime();
|
|
@@ -4960,20 +4969,20 @@
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
// 30秒刷新一下直播间点赞数
|
|
// 30秒刷新一下直播间点赞数
|
|
|
- startLiveViewDataTimer() {
|
|
|
|
|
- // 先清除旧定时器(防止重复创建)
|
|
|
|
|
- if (this.liveViewDataTimer) {
|
|
|
|
|
- clearInterval(this.liveViewDataTimer);
|
|
|
|
|
- this.liveViewDataTimer = null;
|
|
|
|
|
- }
|
|
|
|
|
- this.getliveViewData();
|
|
|
|
|
- this.liveViewDataTimer = setInterval(() => {
|
|
|
|
|
- // 安全校验:确保liveItem和liveId存在(避免无效请求)
|
|
|
|
|
- if (this.liveId) {
|
|
|
|
|
- this.getliveViewData();
|
|
|
|
|
- }
|
|
|
|
|
- }, 20000);
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ // startLiveViewDataTimer() {
|
|
|
|
|
+ // // 先清除旧定时器(防止重复创建)
|
|
|
|
|
+ // if (this.liveViewDataTimer) {
|
|
|
|
|
+ // clearInterval(this.liveViewDataTimer);
|
|
|
|
|
+ // this.liveViewDataTimer = null;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // this.getliveViewData();
|
|
|
|
|
+ // this.liveViewDataTimer = setInterval(() => {
|
|
|
|
|
+ // // 安全校验:确保liveItem和liveId存在(避免无效请求)
|
|
|
|
|
+ // if (this.liveId) {
|
|
|
|
|
+ // this.getliveViewData();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }, 20000);
|
|
|
|
|
+ // },
|
|
|
// 去购买,跳商品详情
|
|
// 去购买,跳商品详情
|
|
|
async goShop(productId, goodsId) {
|
|
async goShop(productId, goodsId) {
|
|
|
if (!this.liveId) return;
|
|
if (!this.liveId) return;
|
|
@@ -5519,7 +5528,7 @@
|
|
|
this.isShowCoupon = socketMessage.status === 1;
|
|
this.isShowCoupon = socketMessage.status === 1;
|
|
|
if (this.isShowCoupon) {}
|
|
if (this.isShowCoupon) {}
|
|
|
} else if (socketMessage.cmd == 'likeDetail') {
|
|
} else if (socketMessage.cmd == 'likeDetail') {
|
|
|
- this.liveViewData.like = socketMessage.data;
|
|
|
|
|
|
|
+ this.liveViewData.like = Number(socketMessage.data);
|
|
|
} else if (socketMessage.cmd == 'lottery') {
|
|
} else if (socketMessage.cmd == 'lottery') {
|
|
|
const lotteryData = socketMessage.data ? JSON.parse(
|
|
const lotteryData = socketMessage.data ? JSON.parse(
|
|
|
socketMessage.data) : {};
|
|
socketMessage.data) : {};
|