|
@@ -15,13 +15,13 @@
|
|
|
</view>
|
|
</view>
|
|
|
<view v-if="Array.isArray(filteredViewers)" class=" align-center" @click="toggleViewerList"
|
|
<view v-if="Array.isArray(filteredViewers)" class=" align-center" @click="toggleViewerList"
|
|
|
style="margin-top: 120rpx;">
|
|
style="margin-top: 120rpx;">
|
|
|
- <view v-for="(item,viewerIndex) in filteredViewers"
|
|
|
|
|
- :key="viewerIndex">
|
|
|
|
|
- <image v-if="item.avatar" class="w52 h52 mr4" style="border-radius: 26rpx;" :src="item.avatar" />
|
|
|
|
|
- <view v-else class="w52 h52"
|
|
|
|
|
- :style="{backgroundColor: getUserRandomColor(item.userId), borderRadius:'50%'}">
|
|
|
|
|
- <text class="text-white text-xs">{{getNicknameInitial(item.nickName)}}</text>
|
|
|
|
|
- </view>
|
|
|
|
|
|
|
+ <view v-for="(item,viewerIndex) in filteredViewers" :key="viewerIndex">
|
|
|
|
|
+ <image v-if="item.avatar" class="w52 h52 mr4" style="border-radius: 26rpx;"
|
|
|
|
|
+ :src="item.avatar" />
|
|
|
|
|
+ <view v-else class="w52 h52"
|
|
|
|
|
+ :style="{backgroundColor: getUserRandomColor(item.userId), borderRadius:'50%'}">
|
|
|
|
|
+ <text class="text-white text-xs">{{getNicknameInitial(item.nickName)}}</text>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="sum">{{liveUserTotal||0}}</view>
|
|
<view class="sum">{{liveUserTotal||0}}</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -59,7 +59,8 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- <view class="item-box" @click="onLottery()">
|
|
|
|
|
|
|
+ <!-- v-if="isShowCoupon" -->
|
|
|
|
|
+ <!-- <view class="item-box" @click="isShowCoupon=true">
|
|
|
<view class="x-f">
|
|
<view class="x-f">
|
|
|
<view class="tip">优惠券</view>
|
|
<view class="tip">优惠券</view>
|
|
|
<view class="item">
|
|
<view class="item">
|
|
@@ -83,8 +84,8 @@
|
|
|
class="item"></live-player>
|
|
class="item"></live-player>
|
|
|
<!-- 录播 -->
|
|
<!-- 录播 -->
|
|
|
<video v-if="liveItem.videoUrl&&liveItem.liveType==2" :id="`myVideo_${liveId}`" class="item"
|
|
<video v-if="liveItem.videoUrl&&liveItem.liveType==2" :id="`myVideo_${liveId}`" class="item"
|
|
|
- :src="liveItem.videoUrl" :autoplay="true" :controls="false" object-fit="contain"
|
|
|
|
|
- :custom-cache="false" :enable-progress-gesture="false" vslide-gesture-in-fullscreen="true"
|
|
|
|
|
|
|
+ :src="liveItem.videoUrl" :controls="false" object-fit="contain" :custom-cache="false"
|
|
|
|
|
+ :enable-progress-gesture="false" vslide-gesture-in-fullscreen="true"
|
|
|
:show-center-play-btn="false" :http-cache="false" loop @error="videoError"
|
|
:show-center-play-btn="false" :http-cache="false" loop @error="videoError"
|
|
|
@timeupdate="onVideoTimeUpdate" @loadeddata="onVideoLoaded"
|
|
@timeupdate="onVideoTimeUpdate" @loadeddata="onVideoLoaded"
|
|
|
@loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay">
|
|
@loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay">
|
|
@@ -92,10 +93,10 @@
|
|
|
|
|
|
|
|
<!-- 直播回放 -->
|
|
<!-- 直播回放 -->
|
|
|
<video v-if="liveItem.videoUrl&&liveItem.liveType==3" :id="`myVideo_${liveId}`" class="item"
|
|
<video v-if="liveItem.videoUrl&&liveItem.liveType==3" :id="`myVideo_${liveId}`" class="item"
|
|
|
- :src="liveItem.videoUrl" :autoplay="true" :controls="true" object-fit="contain"
|
|
|
|
|
- :custom-cache="false" :enable-progress-gesture="liveItem.isSpeedAllowed"
|
|
|
|
|
- vslide-gesture-in-fullscreen="true" :show-center-play-btn="true" :http-cache="false" loop
|
|
|
|
|
- @error="videoError" @timeupdate="onVideoTimeUpdate" @loadeddata="onVideoLoaded"
|
|
|
|
|
|
|
+ :src="liveItem.videoUrl" :controls="true" object-fit="contain" :custom-cache="false"
|
|
|
|
|
+ :enable-progress-gesture="liveItem.isSpeedAllowed" vslide-gesture-in-fullscreen="true"
|
|
|
|
|
+ :show-center-play-btn="true" :http-cache="false" loop @error="videoError"
|
|
|
|
|
+ @timeupdate="onVideoTimeUpdate" @loadeddata="onVideoLoaded"
|
|
|
@loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay"
|
|
@loadedmetadata="onVideoMetaLoaded" @pause="onVideoPause" @play="onVideoPlay"
|
|
|
@seek="onVideoSeek">
|
|
@seek="onVideoSeek">
|
|
|
</video>
|
|
</video>
|
|
@@ -362,24 +363,25 @@
|
|
|
</u-popup>
|
|
</u-popup>
|
|
|
|
|
|
|
|
<!-- 优惠券弹窗 -->
|
|
<!-- 优惠券弹窗 -->
|
|
|
- <!-- <view class="coupon-pop" v-if="isShowCoupon">
|
|
|
|
|
|
|
+ <view class="coupon-pop" v-if="isShowCoupon">
|
|
|
<view class="coupon-block">
|
|
<view class="coupon-block">
|
|
|
<image class="bg" src="/static/images/coupon_bg.png" />
|
|
<image class="bg" src="/static/images/coupon_bg.png" />
|
|
|
<image class="nav" src="/static/images/coupon_top.png" />
|
|
<image class="nav" src="/static/images/coupon_top.png" />
|
|
|
<image @click="isShowCoupon=false" class="w40 h40 close" src="/static/images/close1.png" />
|
|
<image @click="isShowCoupon=false" class="w40 h40 close" src="/static/images/close1.png" />
|
|
|
|
|
|
|
|
<view class="item">
|
|
<view class="item">
|
|
|
- <view class="title">鸡蛋专属优惠券</view>
|
|
|
|
|
- <view class="price">¥<text class="bold">999</text></view>
|
|
|
|
|
- <view class="txt">无门槛</view>
|
|
|
|
|
|
|
+ <view class="title">{{couponInfo.couponName}}</view>
|
|
|
|
|
+ <view class="price">¥<text class="bold">{{couponInfo.couponPrice}}</text></view>
|
|
|
|
|
+ <!-- <view class="txt">无门槛</view> -->
|
|
|
|
|
+ <view class="txt">满{{couponInfo.useMinPrice}}元可用</view>
|
|
|
<view class="txt" style="margin-top: 26rpx;">指定商品可用</view>
|
|
<view class="txt" style="margin-top: 26rpx;">指定商品可用</view>
|
|
|
- <view class="txt">自领取起2天内有效</view>
|
|
|
|
|
- <view class="button" @click="">
|
|
|
|
|
|
|
+ <view class="txt">自领取起{{couponInfo.couponTime}}天内有效</view>
|
|
|
|
|
+ <view class="button" @click="onCoupon()">
|
|
|
立即领券
|
|
立即领券
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- </view> -->
|
|
|
|
|
|
|
+ </view>
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <u-popup :show="true" @close="closeShop" round='20rpx' bgColor='#f3f5f9' zIndex='10075'>
|
|
<!-- <u-popup :show="true" @close="closeShop" round='20rpx' bgColor='#f3f5f9' zIndex='10075'>
|
|
@@ -470,6 +472,7 @@
|
|
|
import ThreeItemSwiper from '@/pages_course/components/ThreeItemSwiper.vue'
|
|
import ThreeItemSwiper from '@/pages_course/components/ThreeItemSwiper.vue'
|
|
|
import CryptoJS from 'crypto-js'
|
|
import CryptoJS from 'crypto-js'
|
|
|
import {
|
|
import {
|
|
|
|
|
+ coupon, //领取优惠券
|
|
|
liveLottery, // 抽奖查询
|
|
liveLottery, // 抽奖查询
|
|
|
claim, //抽奖
|
|
claim, //抽奖
|
|
|
liveRed, // 点击领红包
|
|
liveRed, // 点击领红包
|
|
@@ -490,6 +493,9 @@
|
|
|
import {
|
|
import {
|
|
|
getUserInfo
|
|
getUserInfo
|
|
|
} from '@/api/user'
|
|
} from '@/api/user'
|
|
|
|
|
+ import {
|
|
|
|
|
+ nextTick
|
|
|
|
|
+ } from "vue"
|
|
|
|
|
|
|
|
// var wsUrl = "wss://live.test.ylrztop.com/ws/live-api/app/webSocket"; //余红奇
|
|
// var wsUrl = "wss://live.test.ylrztop.com/ws/live-api/app/webSocket"; //余红奇
|
|
|
// var pingpangTimes = null;
|
|
// var pingpangTimes = null;
|
|
@@ -504,6 +510,12 @@
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ isConnecting: false, // 是否正在连接中
|
|
|
|
|
+ previousToken: null,
|
|
|
|
|
+ pageInBackground: false,
|
|
|
|
|
+ hasInitialized: false,
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
couponsList: [{
|
|
couponsList: [{
|
|
|
status: 0,
|
|
status: 0,
|
|
|
couponPrice: 59,
|
|
couponPrice: 59,
|
|
@@ -511,8 +523,8 @@
|
|
|
couponTitle: '包装袋',
|
|
couponTitle: '包装袋',
|
|
|
limitTime: 2
|
|
limitTime: 2
|
|
|
}],
|
|
}],
|
|
|
- liveViewersAvatar: [],
|
|
|
|
|
- liveUserCalled: false, //调用过watchUserList没
|
|
|
|
|
|
|
+ liveViewersData: [],
|
|
|
|
|
+ // liveUserCalled: false, //调用过watchUserList没
|
|
|
liveViewDataTimer: null,
|
|
liveViewDataTimer: null,
|
|
|
userRandomColors: {}, // 缓存用户ID -> 随机色的映射
|
|
userRandomColors: {}, // 缓存用户ID -> 随机色的映射
|
|
|
randomColor: '#8978e2',
|
|
randomColor: '#8978e2',
|
|
@@ -542,6 +554,7 @@
|
|
|
// wsNewUrl: 'ws://192.168.10.126:7014/app/webSocket',
|
|
// wsNewUrl: 'ws://192.168.10.126:7014/app/webSocket',
|
|
|
// wsNewUrl: 'wss://api.fhhx.runtzh.com/app/webSocket',
|
|
// wsNewUrl: 'wss://api.fhhx.runtzh.com/app/webSocket',
|
|
|
wsNewUrl: 'wss://api.fhhx.runtzh.com/ws/app/webSocket',
|
|
wsNewUrl: 'wss://api.fhhx.runtzh.com/ws/app/webSocket',
|
|
|
|
|
+ // wsNewUrl: 'ws://192.168.10.166:7114/ws/app/webSocket',
|
|
|
// wsNewUrl:'ws://192.168.10.166:7014/app/webSocket',
|
|
// wsNewUrl:'ws://192.168.10.166:7014/app/webSocket',
|
|
|
qrFrom: null,
|
|
qrFrom: null,
|
|
|
scene: '',
|
|
scene: '',
|
|
@@ -582,6 +595,7 @@
|
|
|
integral: {},
|
|
integral: {},
|
|
|
lotteryInfo: {},
|
|
lotteryInfo: {},
|
|
|
goodsCard: {},
|
|
goodsCard: {},
|
|
|
|
|
+ couponInfo: {},
|
|
|
redInfo: {},
|
|
redInfo: {},
|
|
|
storeId: null,
|
|
storeId: null,
|
|
|
isFocus: false,
|
|
isFocus: false,
|
|
@@ -640,13 +654,15 @@
|
|
|
showadd: false,
|
|
showadd: false,
|
|
|
videoContext: '',
|
|
videoContext: '',
|
|
|
livedata: {}, //直播间点赞、关注、在线人数数据
|
|
livedata: {}, //直播间点赞、关注、在线人数数据
|
|
|
- userData: {}
|
|
|
|
|
-
|
|
|
|
|
|
|
+ userData: {},
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
onLoad(options) {
|
|
onLoad(options) {
|
|
|
|
|
+ this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
|
|
|
|
|
+ this.userData = uni.getStorageSync("userData")
|
|
|
|
|
+ this.previousToken = uni.getStorageSync('AppToken')
|
|
|
console.log("全部参数", options)
|
|
console.log("全部参数", options)
|
|
|
//获取键盘高度
|
|
//获取键盘高度
|
|
|
this.keyboardListener = uni.onKeyboardHeightChange(res => {
|
|
this.keyboardListener = uni.onKeyboardHeightChange(res => {
|
|
@@ -680,8 +696,7 @@
|
|
|
console.log("这个", this.qrFrom)
|
|
console.log("这个", this.qrFrom)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
|
|
|
|
|
- this.userData = uni.getStorageSync("userData")
|
|
|
|
|
|
|
+
|
|
|
// 初始化直播间列表
|
|
// 初始化直播间列表
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
if (this.liveId) {
|
|
if (this.liveId) {
|
|
@@ -693,19 +708,49 @@
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+ // onShow() {
|
|
|
|
|
+ // this.randomColor = this.getRandomHexColor()
|
|
|
|
|
+ // if (uni.getStorageSync('AppToken')) {
|
|
|
|
|
+ // this.getUserInfo();
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // this.setVideoCurrentTime(this.liveItem.totalTime)
|
|
|
|
|
+ // // this.setVideoCurrentTime(this.liveItem.totalSeconds);
|
|
|
|
|
+ // // this.getliveUser()
|
|
|
|
|
+ // // 页面显示时,若连接未打开则重新初始化
|
|
|
|
|
+ // if (!this.isSocketAvailable()) {
|
|
|
|
|
+ // this.initSocket()
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
onShow() {
|
|
onShow() {
|
|
|
|
|
+ const currentToken = uni.getStorageSync('AppToken')
|
|
|
|
|
+
|
|
|
|
|
+ // 首次加载或登录状态变化时重新初始化
|
|
|
|
|
+ if (!this.hasInitialized || (!this.previousToken && currentToken)) {
|
|
|
|
|
+ this.initializePageData()
|
|
|
|
|
+ this.hasInitialized = true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.previousToken = currentToken
|
|
|
|
|
+ this.pageInBackground = false
|
|
|
|
|
+
|
|
|
|
|
+ // 恢复播放和连接
|
|
|
|
|
+ this.resumePageActivity()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
this.randomColor = this.getRandomHexColor()
|
|
this.randomColor = this.getRandomHexColor()
|
|
|
- if (uni.getStorageSync('AppToken')) {
|
|
|
|
|
- this.getUserInfo();
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (currentToken) {
|
|
|
|
|
+ this.getUserInfo()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.setVideoCurrentTime(this.liveItem.totalTime)
|
|
this.setVideoCurrentTime(this.liveItem.totalTime)
|
|
|
- // this.setVideoCurrentTime(this.liveItem.totalSeconds);
|
|
|
|
|
- this.getliveUser()
|
|
|
|
|
|
|
+
|
|
|
// 页面显示时,若连接未打开则重新初始化
|
|
// 页面显示时,若连接未打开则重新初始化
|
|
|
- if (!this.isSocketAvailable()) {
|
|
|
|
|
- this.initSocket()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (!this.isSocketAvailable()) {
|
|
|
|
|
+ // this.initSocket()
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
//分享给好友
|
|
//分享给好友
|
|
@@ -725,8 +770,7 @@
|
|
|
computed: {
|
|
computed: {
|
|
|
filteredViewers() {
|
|
filteredViewers() {
|
|
|
// 1. 强制兜底:若 liveViewers 不是数组(如 null/undefined),直接返回空数组
|
|
// 1. 强制兜底:若 liveViewers 不是数组(如 null/undefined),直接返回空数组
|
|
|
- const safeLiveViewers = Array.isArray(this.liveViewersAvatar) ? this.liveViewersAvatar : [];
|
|
|
|
|
- console.log("有头像吗",safeLiveViewers)
|
|
|
|
|
|
|
+ const safeLiveViewers = Array.isArray(this.liveViewersData) ? this.liveViewersData : [];
|
|
|
// 2. 截取前3项(空数组 slice 不会报错)
|
|
// 2. 截取前3项(空数组 slice 不会报错)
|
|
|
return safeLiveViewers.slice(0, 3);
|
|
return safeLiveViewers.slice(0, 3);
|
|
|
},
|
|
},
|
|
@@ -741,13 +785,12 @@
|
|
|
return String(item.userId) === String(this.userData.userId);
|
|
return String(item.userId) === String(this.userData.userId);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- // payLimitTime() {
|
|
|
|
|
- // return this.order?.updateTime ?
|
|
|
|
|
- // dayjs(this.order.updateTime).add(2, 'day').format('YYYY-MM-DD HH:mm:ss') :
|
|
|
|
|
- // '';
|
|
|
|
|
- // }
|
|
|
|
|
},
|
|
},
|
|
|
onHide() {
|
|
onHide() {
|
|
|
|
|
+ this.pageInBackground = true
|
|
|
|
|
+ this.suspendPageActivity()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
console.log('页面隐藏,暂停视频和定时器');
|
|
console.log('页面隐藏,暂停视频和定时器');
|
|
|
this.stopHeartBeat();
|
|
this.stopHeartBeat();
|
|
|
|
|
|
|
@@ -762,29 +805,14 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onUnload() {
|
|
onUnload() {
|
|
|
- this.loadUserColorsFromStorage();
|
|
|
|
|
|
|
+ this.loadUserColorsFromStorage();
|
|
|
if (this.liveViewDataTimer) {
|
|
if (this.liveViewDataTimer) {
|
|
|
clearInterval(this.liveViewDataTimer);
|
|
clearInterval(this.liveViewDataTimer);
|
|
|
this.liveViewDataTimer = null;
|
|
this.liveViewDataTimer = null;
|
|
|
}
|
|
}
|
|
|
- console.log('页面卸载,清理资源');
|
|
|
|
|
|
|
+ // console.log('页面卸载,清理资源');
|
|
|
this.isPageUnloading = true; // 标记为主动离开
|
|
this.isPageUnloading = true; // 标记为主动离开
|
|
|
|
|
|
|
|
- // (可选)手动向服务端发送离开事件,确保服务端正确推送out
|
|
|
|
|
- if (this.isSocketAvailable()) {
|
|
|
|
|
- const outMsg = JSON.stringify({
|
|
|
|
|
- cmd: "out",
|
|
|
|
|
- userId: this.userData.userId || '',
|
|
|
|
|
- liveId: this.liveId,
|
|
|
|
|
- msg: "离开"
|
|
|
|
|
- });
|
|
|
|
|
- this.socket.send({
|
|
|
|
|
- data: outMsg,
|
|
|
|
|
- success: () => console.log("手动发送离开事件成功"),
|
|
|
|
|
- fail: (err) => console.error("手动发送离开事件失败:", err)
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 1. 先关闭WebSocket
|
|
// 1. 先关闭WebSocket
|
|
|
this.closeWebSocket(true);
|
|
this.closeWebSocket(true);
|
|
|
|
|
|
|
@@ -859,23 +887,103 @@
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ onCoupon() {
|
|
|
|
|
+ if (!this.couponInfo.couponIssueId) return;
|
|
|
|
|
+
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ goodsId: this.couponInfo.goodsId,
|
|
|
|
|
+ couponIssueId: this.couponInfo.couponIssueId,
|
|
|
|
|
+ liveId: this.liveId
|
|
|
|
|
+ };
|
|
|
|
|
+ coupon(data)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ });
|
|
|
|
|
+ this.isShowCoupon = false
|
|
|
|
|
+ // const couponData = res.data || {};
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(rej => {});
|
|
|
|
|
+ },
|
|
|
|
|
+ async initializePageData() {
|
|
|
|
|
+ if (uni.getStorageSync('AppToken')) {
|
|
|
|
|
+ await this.getUserInfo()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.liveId) {
|
|
|
|
|
+ await this.getliving(this.liveId)
|
|
|
|
|
+ this.getCurrentActivities()
|
|
|
|
|
+ this.getliveOrder()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.initSocket()
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 恢复页面活动
|
|
|
|
|
+ resumePageActivity() {
|
|
|
|
|
+ if (this.liveItem) {
|
|
|
|
|
+ this.playVideo(this.liveItem)
|
|
|
|
|
+ this.startTimeTimer(this.liveItem)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.isSocketAvailable()) {
|
|
|
|
|
+ this.initSocket()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 暂停页面活动
|
|
|
|
|
+ suspendPageActivity() {
|
|
|
|
|
+ this.stopHeartBeat()
|
|
|
|
|
+ this.saveVideoProgress()
|
|
|
|
|
+
|
|
|
|
|
+ if (this.liveItem) {
|
|
|
|
|
+ this.pauseVideo(this.liveItem)
|
|
|
|
|
+ this.clearTimeTimer(this.liveItem)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // reinitializePage() {
|
|
|
|
|
+ // // 重新获取用户信息
|
|
|
|
|
+ // this.getUserInfo()
|
|
|
|
|
+
|
|
|
|
|
+ // // 重新获取直播间信息
|
|
|
|
|
+ // if (this.liveId) {
|
|
|
|
|
+ // this.getliving(this.liveId)
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // // 重新获取活动信息
|
|
|
|
|
+ // this.getCurrentActivities()
|
|
|
|
|
+
|
|
|
|
|
+ // // 重新获取订单信息
|
|
|
|
|
+ // this.getliveOrder()
|
|
|
|
|
+
|
|
|
|
|
+ // // 重置WebSocket连接
|
|
|
|
|
+ // this.closeWebSocket(true)
|
|
|
|
|
+ // setTimeout(() => {
|
|
|
|
|
+ // this.initSocket()
|
|
|
|
|
+ // }, 1000)
|
|
|
|
|
+ // },
|
|
|
// 获取用户专属随机色(缓存机制:同一用户始终用同一颜色)
|
|
// 获取用户专属随机色(缓存机制:同一用户始终用同一颜色)
|
|
|
getUserRandomColor(userId) {
|
|
getUserRandomColor(userId) {
|
|
|
- // 1. 参数校验和兜底
|
|
|
|
|
if (!userId) {
|
|
if (!userId) {
|
|
|
return '#8978e2'; // 默认颜色
|
|
return '#8978e2'; // 默认颜色
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 2. 如果缓存中已有该用户的颜色,直接返回
|
|
|
|
|
|
|
+ //如果缓存中已有该用户的颜色,直接返回
|
|
|
if (this.userRandomColors[userId]) {
|
|
if (this.userRandomColors[userId]) {
|
|
|
return this.userRandomColors[userId];
|
|
return this.userRandomColors[userId];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 3. 为新用户生成固定颜色(基于用户ID生成,不是完全随机)
|
|
|
|
|
|
|
+ //为新用户生成固定颜色(基于用户ID生成,不是完全随机)
|
|
|
const color = this.generateStableColor(userId);
|
|
const color = this.generateStableColor(userId);
|
|
|
this.userRandomColors[userId] = color;
|
|
this.userRandomColors[userId] = color;
|
|
|
-
|
|
|
|
|
- // 4. 存储到本地缓存,确保页面刷新后颜色不变
|
|
|
|
|
|
|
+ // 存储到本地缓存,确保页面刷新后颜色不变
|
|
|
this.saveUserColorsToStorage();
|
|
this.saveUserColorsToStorage();
|
|
|
|
|
|
|
|
return color;
|
|
return color;
|
|
@@ -1150,7 +1258,6 @@
|
|
|
this.isFocus = false
|
|
this.isFocus = false
|
|
|
},
|
|
},
|
|
|
getTimeDifferenceInSeconds(createTimeStr) {
|
|
getTimeDifferenceInSeconds(createTimeStr) {
|
|
|
- console.log('设置视频播放位置qq', createTimeStr)
|
|
|
|
|
const createTime = new Date(createTimeStr.replace(/-/g, '/'));
|
|
const createTime = new Date(createTimeStr.replace(/-/g, '/'));
|
|
|
const now = new Date();
|
|
const now = new Date();
|
|
|
const timeDiffMs = now - createTime;
|
|
const timeDiffMs = now - createTime;
|
|
@@ -1161,24 +1268,11 @@
|
|
|
onVideoMetaLoaded(e) {
|
|
onVideoMetaLoaded(e) {
|
|
|
// 设置存储key
|
|
// 设置存储key
|
|
|
this.videoProgressKey = `videoProgress_${this.liveId}`;
|
|
this.videoProgressKey = `videoProgress_${this.liveId}`;
|
|
|
- // 尝试从存储中获取保存的播放进度
|
|
|
|
|
- // uni.getStorage({
|
|
|
|
|
- // key: this.videoProgressKey,
|
|
|
|
|
- // success: (res) => {
|
|
|
|
|
- // this.videoCurrentTime = res.data;
|
|
|
|
|
- // console.log('设置视频播放位置', this.videoCurrentTime)
|
|
|
|
|
- // // 设置视频播放位置
|
|
|
|
|
- // this.setVideoCurrentTime(this.videoCurrentTime);
|
|
|
|
|
- // },
|
|
|
|
|
- // fail: (err) => {
|
|
|
|
|
- // console.log('没有找到保存的播放进度或获取失败', err);
|
|
|
|
|
- // this.videoCurrentTime = 0;
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
const diff = this.getTimeDifferenceInSeconds(this.liveItem.startTime);
|
|
const diff = this.getTimeDifferenceInSeconds(this.liveItem.startTime);
|
|
|
- console.log('设置视频播放位置', diff)
|
|
|
|
|
- this.setVideoCurrentTime(diff);
|
|
|
|
|
- // this.videoCurrentTime = res.data;
|
|
|
|
|
|
|
+ const realDiff = diff % this.liveItem.duration
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.setVideoCurrentTime(realDiff);
|
|
|
|
|
+ }, 100);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1211,12 +1305,13 @@
|
|
|
},
|
|
},
|
|
|
// 设置视频当前时间
|
|
// 设置视频当前时间
|
|
|
setVideoCurrentTime(time) {
|
|
setVideoCurrentTime(time) {
|
|
|
|
|
+ if (!time) return;
|
|
|
const videoId = `myVideo_${this.liveId}`;
|
|
const videoId = `myVideo_${this.liveId}`;
|
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
|
|
|
|
|
|
if (videoContext) {
|
|
if (videoContext) {
|
|
|
videoContext.seek(time);
|
|
videoContext.seek(time);
|
|
|
- // console.log(`设置视频播放位置: ${time}秒`);
|
|
|
|
|
|
|
+ console.log(`设置视频播放位置: ${time}秒`);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -1495,7 +1590,6 @@
|
|
|
// 播放视频
|
|
// 播放视频
|
|
|
playVideo(liveItem) {
|
|
playVideo(liveItem) {
|
|
|
if (!liveItem) return;
|
|
if (!liveItem) return;
|
|
|
- console.log("直播的状态", liveItem)
|
|
|
|
|
try {
|
|
try {
|
|
|
// 直播流使用live-player
|
|
// 直播流使用live-player
|
|
|
if (liveItem.liveType === 1 && liveItem.livingUrl && liveItem.status == 2) {
|
|
if (liveItem.liveType === 1 && liveItem.livingUrl && liveItem.status == 2) {
|
|
@@ -1505,7 +1599,6 @@
|
|
|
livePlayerContext.play();
|
|
livePlayerContext.play();
|
|
|
}
|
|
}
|
|
|
} else if (liveItem.status == 1 && liveItem.previewUrl) {
|
|
} else if (liveItem.status == 1 && liveItem.previewUrl) {
|
|
|
- console.log("直播预告")
|
|
|
|
|
const videoId = `myVideo_${this.liveId}`;
|
|
const videoId = `myVideo_${this.liveId}`;
|
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
const videoContext = uni.createVideoContext(videoId, this);
|
|
|
if (videoContext) {
|
|
if (videoContext) {
|
|
@@ -1589,9 +1682,13 @@
|
|
|
try {
|
|
try {
|
|
|
const res = await watchUserList(this.liveId, this.viewPageSize, this.viewPageNum, false);
|
|
const res = await watchUserList(this.liveId, this.viewPageSize, this.viewPageNum, false);
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
- const userRows = Array.isArray(res.row) ? res.row : [];
|
|
|
|
|
- this.liveViewersAvatar = userRows.map(item => item.avatar || '');
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const userRows = Array.isArray(res.rows) ? res.rows : [];
|
|
|
|
|
+ // this.liveViewersData = userRows.map(item => item.avatar || '');
|
|
|
|
|
+ this.liveViewersData = userRows.map(item => ({
|
|
|
|
|
+ avatar: item.avatar || '',
|
|
|
|
|
+ userId: item.userId || '',
|
|
|
|
|
+ nickName: item.nickName || '未命名'
|
|
|
|
|
+ }));
|
|
|
|
|
|
|
|
this.liveUserTotal = res.total || 0;
|
|
this.liveUserTotal = res.total || 0;
|
|
|
// 兜底 newRows:接口返回的 rows 必须是数组,否则为空数组
|
|
// 兜底 newRows:接口返回的 rows 必须是数组,否则为空数组
|
|
@@ -1771,7 +1868,11 @@
|
|
|
// 直播预告
|
|
// 直播预告
|
|
|
this.liveStartTimer = setInterval(() => {
|
|
this.liveStartTimer = setInterval(() => {
|
|
|
this.liveCountdown = this.handleTime(res.data.startTime, 0)
|
|
this.liveCountdown = this.handleTime(res.data.startTime, 0)
|
|
|
|
|
+
|
|
|
}, 1000);
|
|
}, 1000);
|
|
|
|
|
+ if (res.data.liveType !== 1 && this.liveCountdown) {
|
|
|
|
|
+ this.getliving(this.liveId); // 需用 await 确保数据更新完成
|
|
|
|
|
+ }
|
|
|
this.$set(this.liveItem, 'previewUrl', res.data.previewUrl);
|
|
this.$set(this.liveItem, 'previewUrl', res.data.previewUrl);
|
|
|
this.$set(this.liveItem, 'livingUrl', ''); // 清空直播流
|
|
this.$set(this.liveItem, 'livingUrl', ''); // 清空直播流
|
|
|
this.$set(this.liveItem, 'videoUrl', ''); // 清空回放视频
|
|
this.$set(this.liveItem, 'videoUrl', ''); // 清空回放视频
|
|
@@ -1831,7 +1932,6 @@
|
|
|
if (livePlayerContext) {
|
|
if (livePlayerContext) {
|
|
|
livePlayerContext.stop(); // 先停止旧流
|
|
livePlayerContext.stop(); // 先停止旧流
|
|
|
livePlayerContext.play(); // 播放新流
|
|
livePlayerContext.play(); // 播放新流
|
|
|
- console.log("live-player 重新拉流:", livingUrl);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1843,7 +1943,6 @@
|
|
|
videoContext.stop(); // 停止旧视频
|
|
videoContext.stop(); // 停止旧视频
|
|
|
videoContext.seek(0); // 重置到开头
|
|
videoContext.seek(0); // 重置到开头
|
|
|
videoContext.play(); // 播放新视频
|
|
videoContext.play(); // 播放新视频
|
|
|
- console.log("video 重新加载:", videoUrl);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -1865,8 +1964,6 @@
|
|
|
|
|
|
|
|
// 返回上一个页面并关闭WebSocket
|
|
// 返回上一个页面并关闭WebSocket
|
|
|
goBack() {
|
|
goBack() {
|
|
|
- console.log('返回上一页,清理资源');
|
|
|
|
|
-
|
|
|
|
|
// 暂停当前视频
|
|
// 暂停当前视频
|
|
|
const currentLive = this.liveItem;
|
|
const currentLive = this.liveItem;
|
|
|
if (currentLive) {
|
|
if (currentLive) {
|
|
@@ -1993,7 +2090,7 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log("websocket 连接关闭: 1000 normal closure");
|
|
|
|
|
|
|
+ console.log("websocket 连接关闭");
|
|
|
this.isManualClose = isManual;
|
|
this.isManualClose = isManual;
|
|
|
this.stopHeartBeat();
|
|
this.stopHeartBeat();
|
|
|
this.resetReconnectState();
|
|
this.resetReconnectState();
|
|
@@ -2025,6 +2122,14 @@
|
|
|
}, this.heartBeatInterval);
|
|
}, this.heartBeatInterval);
|
|
|
},
|
|
},
|
|
|
initSocket() {
|
|
initSocket() {
|
|
|
|
|
+ if (this.isConnecting) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果已经存在连接且状态为open,则退出
|
|
|
|
|
+ if (this.socket && this.socket.readyState === 1) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (this.socket && (this.socket.readyState === 0 || this.socket.readyState === 1)) {
|
|
if (this.socket && (this.socket.readyState === 0 || this.socket.readyState === 1)) {
|
|
|
console.log('关闭现有WebSocket连接,创建新连接');
|
|
console.log('关闭现有WebSocket连接,创建新连接');
|
|
|
this.closeWebSocket(true);
|
|
this.closeWebSocket(true);
|
|
@@ -2051,12 +2156,12 @@
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const baseWsUrl = 'wss://api.fhhx.runtzh.com/ws/app/webSocket';
|
|
const baseWsUrl = 'wss://api.fhhx.runtzh.com/ws/app/webSocket';
|
|
|
- // const baseWsUrl = 'wss://api.fhhx.runtzh.com/app/webSocket';
|
|
|
|
|
|
|
+ // const baseWsUrl = 'ws://192.168.10.166:7114/ws/app/webSocket';
|
|
|
let wsUrl =
|
|
let wsUrl =
|
|
|
`${baseWsUrl}?userId=${this.userData.userId}&liveId=${this.liveId}&userType=${this.userType}×tamp=${this.timestamp}&signature=${signature}`;
|
|
`${baseWsUrl}?userId=${this.userData.userId}&liveId=${this.liveId}&userType=${this.userType}×tamp=${this.timestamp}&signature=${signature}`;
|
|
|
if (this.qrFrom) wsUrl += this.qrFrom;
|
|
if (this.qrFrom) wsUrl += this.qrFrom;
|
|
|
|
|
|
|
|
- console.log("创建新的WebSocket连接:", wsUrl);
|
|
|
|
|
|
|
+ // console.log("创建新的WebSocket连接:", wsUrl);
|
|
|
|
|
|
|
|
const socketTask = uni.connectSocket({
|
|
const socketTask = uni.connectSocket({
|
|
|
url: wsUrl,
|
|
url: wsUrl,
|
|
@@ -2071,6 +2176,7 @@
|
|
|
socketTask.onOpen((res) => {
|
|
socketTask.onOpen((res) => {
|
|
|
console.log("WebSocket连接已打开");
|
|
console.log("WebSocket连接已打开");
|
|
|
this.socket = socketTask;
|
|
this.socket = socketTask;
|
|
|
|
|
+ this.isConnecting = false;
|
|
|
this.isSocketOpen = true;
|
|
this.isSocketOpen = true;
|
|
|
this.reconnectCount = 0;
|
|
this.reconnectCount = 0;
|
|
|
this.resetReconnectState();
|
|
this.resetReconnectState();
|
|
@@ -2081,12 +2187,10 @@
|
|
|
|
|
|
|
|
// 消息接收事件
|
|
// 消息接收事件
|
|
|
socketTask.onMessage((res) => {
|
|
socketTask.onMessage((res) => {
|
|
|
- console.log(res, 'res')
|
|
|
|
|
try {
|
|
try {
|
|
|
const data = JSON.parse(res.data);
|
|
const data = JSON.parse(res.data);
|
|
|
// 处理服务端心跳响应(根据服务端协议调整cmd字段)
|
|
// 处理服务端心跳响应(根据服务端协议调整cmd字段)
|
|
|
if (data.cmd === "heartBeatAck") {
|
|
if (data.cmd === "heartBeatAck") {
|
|
|
- console.log("收到心跳响应");
|
|
|
|
|
this.stopHeartBeat(); // 清除当前超时检测
|
|
this.stopHeartBeat(); // 清除当前超时检测
|
|
|
this.startHeartBeat(); // 重新启动心跳周期
|
|
this.startHeartBeat(); // 重新启动心跳周期
|
|
|
return;
|
|
return;
|
|
@@ -2101,18 +2205,18 @@
|
|
|
console.error("WebSocket连接错误:", err);
|
|
console.error("WebSocket连接错误:", err);
|
|
|
this.isSocketOpen = false;
|
|
this.isSocketOpen = false;
|
|
|
this.stopHeartBeat();
|
|
this.stopHeartBeat();
|
|
|
|
|
+ this.isConnecting = false;
|
|
|
this.handleReconnect(); // 错误直接触发重连
|
|
this.handleReconnect(); // 错误直接触发重连
|
|
|
});
|
|
});
|
|
|
// 连接关闭事件
|
|
// 连接关闭事件
|
|
|
socketTask.onClose((res) => {
|
|
socketTask.onClose((res) => {
|
|
|
console.log("WebSocket连接关闭:", res);
|
|
console.log("WebSocket连接关闭:", res);
|
|
|
this.isSocketOpen = false;
|
|
this.isSocketOpen = false;
|
|
|
|
|
+ this.isConnecting = false;
|
|
|
this.stopHeartBeat(); // 清除心跳定时器(复用之前的停止方法)
|
|
this.stopHeartBeat(); // 清除心跳定时器(复用之前的停止方法)
|
|
|
if (!this.isManualClose && this.reconnectCount < this.maxReconnectAttempts) {
|
|
if (!this.isManualClose && this.reconnectCount < this.maxReconnectAttempts) {
|
|
|
- // this.handleReconnect();
|
|
|
|
|
- } else {
|
|
|
|
|
- console.log("无需重连(手动关闭或正常关闭)");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.handleReconnect();
|
|
|
|
|
+ } else {}
|
|
|
});
|
|
});
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error("创建WebSocket异常:", e);
|
|
console.error("创建WebSocket异常:", e);
|
|
@@ -2185,7 +2289,6 @@
|
|
|
this.handleReconnect(); // 主动触发重连
|
|
this.handleReconnect(); // 主动触发重连
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- console.log("聊天", messageData)
|
|
|
|
|
const oldList = Array.isArray(this.talklist) ? this.talklist : [];
|
|
const oldList = Array.isArray(this.talklist) ? this.talklist : [];
|
|
|
const newList = [...oldList, messageData];
|
|
const newList = [...oldList, messageData];
|
|
|
this.talklist = newList;
|
|
this.talklist = newList;
|
|
@@ -2215,6 +2318,19 @@
|
|
|
this.goodsCard = JSON.parse(socketMessage.data);
|
|
this.goodsCard = JSON.parse(socketMessage.data);
|
|
|
this.isShowGoods = socketMessage.status == 1;
|
|
this.isShowGoods = socketMessage.status == 1;
|
|
|
|
|
|
|
|
|
|
+ } else if (socketMessage.cmd == 'coupon') {
|
|
|
|
|
+ this.couponInfo = JSON.parse(socketMessage.data);
|
|
|
|
|
+ this.isShowCoupon = socketMessage.status === 1;
|
|
|
|
|
+ if (this.isShowCoupon) {
|
|
|
|
|
+ // this.couponTimer = setInterval(() => {
|
|
|
|
|
+ // const couponCountdown = this.handleTime(this.couponInfo.updateTime, this.couponInfo.duration)
|
|
|
|
|
+ // if (!couponCountdown) {
|
|
|
|
|
+ // this.isShowCoupon = false
|
|
|
|
|
+ // clearInterval(this.couponTimer)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }, 1000);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else if (socketMessage.cmd == 'lottery') {
|
|
} else if (socketMessage.cmd == 'lottery') {
|
|
|
|
|
|
|
|
const parsedData = JSON.parse(socketMessage.data || '{}'); // 默认为空对象
|
|
const parsedData = JSON.parse(socketMessage.data || '{}'); // 默认为空对象
|
|
@@ -2246,17 +2362,22 @@
|
|
|
try {
|
|
try {
|
|
|
if (!this.liveUserCalled) {
|
|
if (!this.liveUserCalled) {
|
|
|
this.getliveUser(false);
|
|
this.getliveUser(false);
|
|
|
|
|
+ this.liveUserTotal++;
|
|
|
this.liveUserCalled = true;
|
|
this.liveUserCalled = true;
|
|
|
}
|
|
}
|
|
|
if (socketMessage.avatar) {
|
|
if (socketMessage.avatar) {
|
|
|
- this.liveViewersAvatar.push(socketMessage.avatar)
|
|
|
|
|
|
|
+ const liveViewers = {
|
|
|
|
|
+ userId: socketMessage.userId,
|
|
|
|
|
+ nickName: socketMessage.nickName,
|
|
|
|
|
+ avatar: socketMessage.avatar
|
|
|
|
|
+ }
|
|
|
|
|
+ this.liveViewersData.push(liveViewers)
|
|
|
}
|
|
}
|
|
|
- console.log("人数数组为", this.liveViewersAvatar)
|
|
|
|
|
// 解析用户ID(根据实际接口字段调整,此处假设data含userId)
|
|
// 解析用户ID(根据实际接口字段调整,此处假设data含userId)
|
|
|
const userData = JSON.parse(socketMessage.data || '{}');
|
|
const userData = JSON.parse(socketMessage.data || '{}');
|
|
|
const userId = userData.userId || socketMessage.userId; // 兼容不同字段
|
|
const userId = userData.userId || socketMessage.userId; // 兼容不同字段
|
|
|
if (!userId) return; // 无用户ID不处理
|
|
if (!userId) return; // 无用户ID不处理
|
|
|
- this.liveUserTotal++;
|
|
|
|
|
|
|
+
|
|
|
// 仅新用户(未显示过)才触发提示
|
|
// 仅新用户(未显示过)才触发提示
|
|
|
if (!this.shownEntryUsers.has(userId)) {
|
|
if (!this.shownEntryUsers.has(userId)) {
|
|
|
this.inAndOut = socketMessage;
|
|
this.inAndOut = socketMessage;
|
|
@@ -2274,31 +2395,55 @@
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
console.error("解析entry用户数据失败:", err);
|
|
console.error("解析entry用户数据失败:", err);
|
|
|
}
|
|
}
|
|
|
- } else if (socketMessage.cmd ==
|
|
|
|
|
- 'out') {
|
|
|
|
|
- if (this.liveUserTotal > 0) {
|
|
|
|
|
- this.liveUserTotal--;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if (this.isPageUnloading) {
|
|
|
|
|
- this.inAndOut = socketMessage;
|
|
|
|
|
- this.showWelcomeMessage = true;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 3秒后隐藏提示
|
|
|
|
|
- if (this.welcomeTimer) clearTimeout(this.welcomeTimer);
|
|
|
|
|
- this.welcomeTimer = setTimeout(() => {
|
|
|
|
|
- this.showWelcomeMessage = false;
|
|
|
|
|
- }, 3000);
|
|
|
|
|
- const index = this.liveViewersAvatar.indexOf(socketMessage.avatar);
|
|
|
|
|
|
|
+ // else if (socketMessage.cmd ==
|
|
|
|
|
+ // 'out') {
|
|
|
|
|
+ //
|
|
|
|
|
+ // if (this.liveUserTotal > 0) {
|
|
|
|
|
+ // this.liveUserTotal--;
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // if (this.isPageUnloading) {
|
|
|
|
|
+ // this.inAndOut = socketMessage;
|
|
|
|
|
+ // this.showWelcomeMessage = true;
|
|
|
|
|
+
|
|
|
|
|
+ // // 3秒后隐藏提示
|
|
|
|
|
+ // if (this.welcomeTimer) clearTimeout(this.welcomeTimer);
|
|
|
|
|
+ // this.welcomeTimer = setTimeout(() => {
|
|
|
|
|
+ // this.showWelcomeMessage = false;
|
|
|
|
|
+ // }, 3000);
|
|
|
|
|
+ // const index = this.liveViewersData.indexOf(socketMessage.avatar);
|
|
|
|
|
+ // if (index !== -1) {
|
|
|
|
|
+ // this.liveViewersData.splice(index, 1); // 从索引位置删除1个元素
|
|
|
|
|
+ // }
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // // 非主动离开(如重连导致的假out),直接忽略
|
|
|
|
|
+ // console.log("忽略重连导致的out事件:", socketMessage);
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // }
|
|
|
|
|
+ else if (socketMessage.cmd == 'out') {
|
|
|
|
|
+ console.log("用户离开");
|
|
|
|
|
+ if (this.liveUserTotal > 0) {
|
|
|
|
|
+ this.liveUserTotal--; // 根据userId删除对应的用户数据
|
|
|
|
|
+ const userIdToRemove = socketMessage.userId;
|
|
|
|
|
+ const index = this.liveViewersData.findIndex(item => item.userId === userIdToRemove);
|
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
|
- this.liveViewersAvatar.splice(index, 1); // 从索引位置删除1个元素
|
|
|
|
|
|
|
+ this.liveViewersData.splice(index, 1);
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- // 非主动离开(如重连导致的假out),直接忽略
|
|
|
|
|
- console.log("忽略重连导致的out事件:", socketMessage);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.inAndOut = socketMessage;
|
|
|
|
|
+ this.showWelcomeMessage = true;
|
|
|
|
|
+
|
|
|
|
|
+ // 3秒后隐藏提示
|
|
|
|
|
+ if (this.welcomeTimer) clearTimeout(this.welcomeTimer);
|
|
|
|
|
+ this.welcomeTimer = setTimeout(() => {
|
|
|
|
|
+ this.showWelcomeMessage = false;
|
|
|
|
|
+ }, 3000);
|
|
|
} else if (socketMessage.cmd == 'live_start' || socketMessage.cmd ==
|
|
} else if (socketMessage.cmd == 'live_start' || socketMessage.cmd ==
|
|
|
'live_end') {
|
|
'live_end') {
|
|
|
// this.getliving(this.liveId);
|
|
// this.getliving(this.liveId);
|
|
@@ -2419,7 +2564,7 @@
|
|
|
// 2. 发送失败重试:使用定义后的 retries
|
|
// 2. 发送失败重试:使用定义后的 retries
|
|
|
if (retries > 0) {
|
|
if (retries > 0) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: `发送失败,正在重试(${retries}次)...`,
|
|
|
|
|
|
|
+ title: `发送失败,正在重试(${retries}次)`,
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
});
|
|
});
|
|
|
setTimeout(() => this.sendMsg(retries - 1), 500);
|
|
setTimeout(() => this.sendMsg(retries - 1), 500);
|
|
@@ -2481,6 +2626,7 @@
|
|
|
box-sizing: border-box;
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
.item {
|
|
.item {
|
|
|
|
|
+ display: flex;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
height: 1.7 * 100rpx;
|
|
height: 1.7 * 100rpx;
|
|
|
margin-bottom: 0.16 * 100rpx;
|
|
margin-bottom: 0.16 * 100rpx;
|
|
@@ -2695,6 +2841,7 @@
|
|
|
height: 100rpx;
|
|
height: 100rpx;
|
|
|
margin-right: 20rpx;
|
|
margin-right: 20rpx;
|
|
|
position: relative;
|
|
position: relative;
|
|
|
|
|
+ z-index: 999;
|
|
|
|
|
|
|
|
.tip {
|
|
.tip {
|
|
|
position: absolute;
|
|
position: absolute;
|
|
@@ -2892,7 +3039,7 @@
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
border-radius: 20rpx;
|
|
border-radius: 20rpx;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
- background: linear-gradient(180deg, #f76446 0%, #ffd7d5 27%, #ffffff 100%);
|
|
|
|
|
|
|
+ background: linear-gradient(180deg, #f7823f 0%, #ffd4be 27%, #ffffff 100%);
|
|
|
position: relative;
|
|
position: relative;
|
|
|
|
|
|
|
|
.nav-img {
|
|
.nav-img {
|