|
|
@@ -73,13 +73,13 @@
|
|
|
<!-- @click="toggleViewerList" -->
|
|
|
<view v-if="Array.isArray(filteredViewers)" class="viewers-section">
|
|
|
<view v-for="(item, index) in (filteredViewers ||[])" :key="index">
|
|
|
- <image v-if="item.avatar" class="viewer-avatar mr4" :src="item.avatar" />
|
|
|
- <view v-else class="viewer-avatar-placeholder mr4"
|
|
|
+ <image v-if="item" class="viewer-avatar mr4" :src="item" />
|
|
|
+ <!-- <view v-else class="viewer-avatar-placeholder mr4"
|
|
|
:style="{ backgroundColor: getUserRandomColor(item.userId) }">
|
|
|
<text class="avatar-initial">{{ getNicknameInitial(item.nickName) }}</text>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
</view>
|
|
|
- <view class="viewer-count ">{{formattedWatchCount || 0 }}</view>
|
|
|
+ <view class="viewer-count ">{{virtualHuman || 0 }}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -194,7 +194,8 @@
|
|
|
:class="{ 'input-focused': isFocus }" @focus="inputFocus" @blur="inputBlur"
|
|
|
cursor-spacing="100" :adjust-position="false" :disabled="isEnd" />
|
|
|
<!-- v-if="isFocus&&!isIOS" -->
|
|
|
- <view class="send-button" :class="liveItem.showType == 1 ? 'send2' : ''" @click="sendMsg()">发送</view>
|
|
|
+ <view class="send-button" :class="liveItem.showType == 1 ? 'send2' : ''" @click="sendMsg()">
|
|
|
+ 发送</view>
|
|
|
</view>
|
|
|
<!-- :class="{ 'action-buttons-hidden': isFocus }" -->
|
|
|
<view class="action-buttons" v-if="!isFocus">
|
|
|
@@ -554,16 +555,16 @@
|
|
|
<input placeholder="请搜索商品" v-model="inputInfo" @input="handleSearchInput" />
|
|
|
</view>
|
|
|
<view class="x-f">
|
|
|
- <view class="shopping-action-button mr30" @click="navgetTo('/pages_shopping/live/order')">
|
|
|
- <image class="action-button-icon"
|
|
|
- src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/carts.png" />
|
|
|
- <view class="action-button-label">订单</view>
|
|
|
- </view>
|
|
|
- <view class="shopping-action-button" @click="(isMore = true), (shopping = false)">
|
|
|
- <image class="action-button-icon"
|
|
|
- src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/search2.png" />
|
|
|
- <view class="action-button-label">更多</view>
|
|
|
- </view>
|
|
|
+ <view class="shopping-action-button mr30" @click="navgetTo('/pages_shopping/live/order')">
|
|
|
+ <image class="action-button-icon"
|
|
|
+ src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/carts.png" />
|
|
|
+ <view class="action-button-label">订单</view>
|
|
|
+ </view>
|
|
|
+ <view class="shopping-action-button" @click="(isMore = true), (shopping = false)">
|
|
|
+ <image class="action-button-icon"
|
|
|
+ src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/search2.png" />
|
|
|
+ <view class="action-button-label">更多</view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -686,6 +687,11 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ fakeAvatar: Array.from({
|
|
|
+ length: 11
|
|
|
+ }, (_, i) =>
|
|
|
+ `https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/avatar${i + 1}.png`),
|
|
|
+ virtualHuman: null,
|
|
|
userlogo: false,
|
|
|
listTabs: [{
|
|
|
name: '讨论',
|
|
|
@@ -948,7 +954,7 @@
|
|
|
},
|
|
|
onPullDownRefresh() {
|
|
|
this.getLiveMsg(this.liveItem);
|
|
|
- this.getliveUser();
|
|
|
+ // this.getliveUser();
|
|
|
setTimeout(() => {
|
|
|
uni.stopPullDownRefresh();
|
|
|
}, 1000);
|
|
|
@@ -1058,17 +1064,31 @@
|
|
|
return this.$store.state.appid
|
|
|
},
|
|
|
// 观看人数
|
|
|
- formattedWatchCount() {
|
|
|
- return this.formatNumber(this.liveUserTotal || 0);
|
|
|
- },
|
|
|
+ // formattedWatchCount() {
|
|
|
+ // return this.formatNumber(this.liveUserTotal || 0);
|
|
|
+ // },
|
|
|
//点赞人数
|
|
|
formattedLikeCount() {
|
|
|
return this.formatNumber(this.liveViewData.like || 0);
|
|
|
},
|
|
|
filteredViewers() {
|
|
|
- const safeLiveViewers = Array.isArray(this.liveViewersData) ? this.liveViewersData : [];
|
|
|
- // 截取前3项
|
|
|
- return safeLiveViewers.slice(0, 3);
|
|
|
+ // 只取前3个观众
|
|
|
+ // const safeLiveViewers = Array.isArray(this.liveViewersData) ? this.liveViewersData.slice(0, 3) : [];
|
|
|
+ const safeLiveViewers = []
|
|
|
+ console.log("头像11到底是什么",this.fakeAvatar)
|
|
|
+ // 如果有假头像数组,用假头像替换原有的头像
|
|
|
+ if (this.fakeAvatar && this.fakeAvatar.length > 0) {
|
|
|
+ return safeLiveViewers.map((item, index) => {
|
|
|
+ // 为每个显示的头像从fakeAvatar中随机选择一个
|
|
|
+ const randomIndex = Math.floor(Math.random() * this.fakeAvatar.length);
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ avatar: this.fakeAvatar[randomIndex] // 替换为假头像
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return safeLiveViewers;
|
|
|
},
|
|
|
isCurrentUserWon() {
|
|
|
if (!Array.isArray(this.prizeInfo) || !this.userInfo?.userId) {
|
|
|
@@ -1277,8 +1297,10 @@
|
|
|
},
|
|
|
async haveLogin() {
|
|
|
this.userInfo = uni.getStorageSync('userInfo');
|
|
|
- // this.userData = uni.getStorageSync('userData');
|
|
|
- await this.getUserInfo();
|
|
|
+ if (this.userInfo) {
|
|
|
+ await this.getUserInfo();
|
|
|
+ }
|
|
|
+
|
|
|
// this.initTime();
|
|
|
if (this.liveId) {
|
|
|
// 先获取直播间信息
|
|
|
@@ -1304,7 +1326,7 @@
|
|
|
// await this.getUserInfo();
|
|
|
// }
|
|
|
// },
|
|
|
-
|
|
|
+
|
|
|
// 静默登录
|
|
|
goLogin(data) {
|
|
|
let provider = 'weixin'
|
|
|
@@ -1611,9 +1633,9 @@
|
|
|
this.talklist = this.talklist.slice(-50);
|
|
|
}
|
|
|
// 清理观众数据
|
|
|
- if (this.liveViewersData.length > 100) {
|
|
|
- this.liveViewersData = this.liveViewersData.slice(-100);
|
|
|
- }
|
|
|
+ // if (this.liveViewersData.length > 100) {
|
|
|
+ // this.liveViewersData = this.liveViewersData.slice(-100);
|
|
|
+ // }
|
|
|
|
|
|
// 清理虚拟数据
|
|
|
if (this.liveViewers.length > 100) {
|
|
|
@@ -3209,48 +3231,48 @@
|
|
|
},
|
|
|
|
|
|
// 获取直播间用户
|
|
|
- async getliveUser(isLoadMore = false) {
|
|
|
- this.viewLoading = true;
|
|
|
-
|
|
|
- try {
|
|
|
- const res = await watchUserList(this.liveId, this.viewPageSize, this.viewPageNum, false);
|
|
|
- console.log("getliveUser",res);
|
|
|
- if (res.code === 200) {
|
|
|
- const userRows = Array.isArray(res.rows) ? res.rows : [];
|
|
|
-
|
|
|
- let array = userRows.map((item) => ({
|
|
|
- avatar: item.avatar || '',
|
|
|
- userId: item.userId || '',
|
|
|
- nickName: item.nickName || '未命名'
|
|
|
- }));
|
|
|
-
|
|
|
- // 虚拟数据
|
|
|
- let virtualData = [];
|
|
|
- let virtualTotal = res.total * 10;
|
|
|
- this.liveUserTotal = virtualTotal;
|
|
|
- for (let i = 0; i < virtualTotal; i++) {
|
|
|
- let data = {
|
|
|
- avatar: '',
|
|
|
- userId: '8565' + i,
|
|
|
- nickName: '微信用户'
|
|
|
- };
|
|
|
- virtualData.push(data);
|
|
|
- }
|
|
|
- this.liveViewersData = [...array, ...virtualData];
|
|
|
-
|
|
|
- const newRows = Array.isArray(res.rows) ? res.rows : [];
|
|
|
- const currentViewers = Array.isArray(this.liveViewers) ? this.liveViewers : [];
|
|
|
-
|
|
|
- let viewlist = isLoadMore ? [...currentViewers, ...newRows] : newRows;
|
|
|
- this.liveViewers = [...viewlist, ...virtualData];
|
|
|
- this.viewPageNum++;
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('获取观众列表失败:', error);
|
|
|
- } finally {
|
|
|
- this.viewLoading = false;
|
|
|
- }
|
|
|
- },
|
|
|
+ // async getliveUser(isLoadMore = false) {
|
|
|
+ // this.viewLoading = true;
|
|
|
+
|
|
|
+ // try {
|
|
|
+ // const res = await watchUserList(this.liveId, this.viewPageSize, this.viewPageNum, false);
|
|
|
+ // console.log("getliveUser", res);
|
|
|
+ // if (res.code === 200) {
|
|
|
+ // const userRows = Array.isArray(res.rows) ? res.rows : [];
|
|
|
+
|
|
|
+ // let array = userRows.map((item) => ({
|
|
|
+ // avatar: item.avatar || '',
|
|
|
+ // userId: item.userId || '',
|
|
|
+ // nickName: item.nickName || '未命名'
|
|
|
+ // }));
|
|
|
+
|
|
|
+ // // 虚拟数据
|
|
|
+ // let virtualData = [];
|
|
|
+ // let virtualTotal = res.total * 10;
|
|
|
+ // this.liveUserTotal = virtualTotal;
|
|
|
+ // for (let i = 0; i < virtualTotal; i++) {
|
|
|
+ // let data = {
|
|
|
+ // avatar: '',
|
|
|
+ // userId: '8565' + i,
|
|
|
+ // nickName: '微信用户'
|
|
|
+ // };
|
|
|
+ // virtualData.push(data);
|
|
|
+ // }
|
|
|
+ // this.liveViewersData = [...array, ...virtualData];
|
|
|
+
|
|
|
+ // const newRows = Array.isArray(res.rows) ? res.rows : [];
|
|
|
+ // const currentViewers = Array.isArray(this.liveViewers) ? this.liveViewers : [];
|
|
|
+
|
|
|
+ // let viewlist = isLoadMore ? [...currentViewers, ...newRows] : newRows;
|
|
|
+ // this.liveViewers = [...viewlist, ...virtualData];
|
|
|
+ // this.viewPageNum++;
|
|
|
+ // }
|
|
|
+ // } catch (error) {
|
|
|
+ // console.error('获取观众列表失败:', error);
|
|
|
+ // } finally {
|
|
|
+ // this.viewLoading = false;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
|
|
|
//小黄车搜索商品
|
|
|
handleSearchInput() {
|
|
|
@@ -3625,9 +3647,9 @@
|
|
|
// 清除之前的重连定时器
|
|
|
this.resetReconnectState();
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- this.getliveUser(false);
|
|
|
- }, 1000);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // this.getliveUser(false);
|
|
|
+ // }, 1000);
|
|
|
|
|
|
const now = new Date();
|
|
|
this.timestamp = now.getTime(); // 生成签名
|
|
|
@@ -3982,7 +4004,7 @@
|
|
|
} else if (socketMessage.cmd == 'entry') {
|
|
|
try {
|
|
|
if (!this.liveUserCalled) {
|
|
|
- await this.getliveUser(false);
|
|
|
+ // await this.getliveUser(false);
|
|
|
this.liveUserCalled = true;
|
|
|
}
|
|
|
const userIdToEntry = socketMessage.userId;
|
|
|
@@ -4039,7 +4061,6 @@
|
|
|
this.showWelcomeMessage = false;
|
|
|
}, 3000);
|
|
|
} else if (socketMessage.cmd == 'live_start' || socketMessage.cmd == 'live_end') {
|
|
|
- console.log("直播关闭在这里>>>>>>关闭")
|
|
|
// 开始直播,关闭直播
|
|
|
if (this.liveStartTimer) {
|
|
|
clearInterval(this.liveStartTimer);
|
|
|
@@ -4058,6 +4079,10 @@
|
|
|
msg: socketMessage.msg,
|
|
|
status: true
|
|
|
};
|
|
|
+ } else if (socketMessage.cmd == 'userCount') {
|
|
|
+ // 广播在线人数
|
|
|
+ this.virtualHuman = socketMessage.data * 10
|
|
|
+
|
|
|
} else if (socketMessage.cmd == 'deleteMsg') {
|
|
|
const index = this.talklist.findIndex(item => item.msgId == socketMessage.msg);
|
|
|
if (index !== -1) {
|
|
|
@@ -4570,6 +4595,7 @@
|
|
|
transform: translateZ(0);
|
|
|
will-change: transform;
|
|
|
backface-visibility: hidden;
|
|
|
+
|
|
|
&.chat-area-container2 {
|
|
|
flex: 1;
|
|
|
min-height: 0; // 重要:允许收缩到0
|
|
|
@@ -4581,7 +4607,7 @@
|
|
|
}
|
|
|
|
|
|
&.chat-area-container3 {
|
|
|
-
|
|
|
+
|
|
|
max-height: 40%;
|
|
|
flex: 1;
|
|
|
min-height: 0; // 重要:允许收缩到0
|
|
|
@@ -4751,12 +4777,13 @@
|
|
|
min-width: 80rpx;
|
|
|
text-align: center;
|
|
|
flex-shrink: 0;
|
|
|
+
|
|
|
&.send2 {
|
|
|
background-color: #2fa9f1;
|
|
|
color: #ffffff;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
.action-buttons {
|