添加直播间功能,直播间右上角人数需要完善

This commit is contained in:
cbb
2026-01-14 17:57:17 +08:00
parent 0c88d29dce
commit db1b797b68
10 changed files with 632 additions and 87 deletions

View File

@@ -16,7 +16,7 @@
<view class="stream-info">
<image class="avatar" :src="currentLive?.liveOwner?.avatarURL || defaultAvatarURL" mode="aspectFill" />
<view class="stream-details">
<text class="stream-title"
<text class="stream-title"
:numberOfLines="1">{{ currentLive?.liveOwner?.userName || currentLive?.liveOwner?.userID}}</text>
</view>
<!-- <view
@@ -36,7 +36,8 @@
<image class="participant-avatar" :src="user?.avatarURL || defaultAvatarURL" mode="aspectFill" />
</view>
<view class="participant-count">
<text class="count-text">{{ audienceList.length }}</text>
<text v-if="topNUmber" class="count-text">{{ audienceList.length }}</text>
<text v-else class="count-text">{{ audienceList.length }}</text>
</view>
</view>
<view class="control-icons" @click.stop="navigateBack()">
@@ -58,6 +59,7 @@
<view class="footer">
<BarrageInput></BarrageInput>
<view class="action-buttons">
<image v-if="activityData?.id" class="action-btn" @click="isShowActivity = true" src="/static/images/activity.png" />
<image class="action-btn" @click="showNetworkQualityPanel()" src="/static/images/dashboard.png" />
<image class="action-btn" @click="showGiftPicker()" src="/static/images/live-gift.png" />
<image class="action-btn" :class="{ 'disabled': shouldDisableCoGuestButton }"
@@ -71,6 +73,8 @@
</view>
</view>
<!-- 活动信息 :showData="activityData" -->
<ActivityInfo v-model="isShowActivity" v-model:info="activityData" :roomId="liveID" ></ActivityInfo>
<UserInfoPanel v-model="isShowUserInfoPanel" :userInfo="clickUserInfo" :isShowAnchor="isShowAnchorInfo">
</UserInfoPanel>
<LiveAudienceList v-model="isShowAudienceList"></LiveAudienceList>
@@ -94,7 +98,7 @@
</template>
<script setup lang="ts">
import { imDataEndLive } from '@/api/tui-kit'
import { imDataEndLive, getLiveActivityDetail, getLiveActivityRecord } from '@/api/tui-kit'
import { onLoad } from '@dcloudio/uni-app';
import { ref, onMounted, computed, onUnmounted, watch, nextTick } from 'vue';
import UserInfoPanel from '@/uni_modules/tuikit-atomic-x/components/LiveStreamView/UserInfoPanel.nvue';
@@ -127,8 +131,13 @@
const { disconnect, connected, cancelApplication } = useCoGuestState(uni?.$liveID)
const { addGiftListener, removeGiftListener } = useGiftState(uni?.$liveID);
const { connected: hostConnected } = useCoHostState(uni?.$liveID)
import ActivityInfo from './components/activity-info.vue'
import { LIVE_BUSINESS } from '@/constants/live-keys'
const dom = uni.requireNativePlugin('dom')
const isShowActivity = ref(false)
const activityData = ref({})
const systemInfo = ref({});
const safeArea = ref({
left: 0,
@@ -185,6 +194,7 @@
const exitSheetItems = ref(['退出直播间'])
const coGuestSheetItems = ref(['取消连麦申请'])
const coGuestSheetTitle = ref('')
const topNUmber = ref('')
// 监听座位变化:当自身不在 seatList 时,将本地连麦状态重置为 IDLE
@@ -201,11 +211,45 @@
}
}, { immediate: true, deep: true });
// 监听自定义消息列表更新
watch(messageList, (newMessages) => {
if (newMessages && newMessages.length > 0) {
console.log('弹幕消息列表更新:', newMessages);
if (newMessages.some(v => v.businessID === LIVE_BUSINESS.ADMIN)) {
console.log('管理员消息====================', newMessages.find(v => v.businessID === LIVE_BUSINESS.ADMIN))
topNUmber.value = newMessages.find(v => v.businessID === LIVE_BUSINESS.ADMIN).data;
}
if (newMessages.some(v => v.businessID === LIVE_BUSINESS.SIGN)) {
activityData.value = {
...JSON.parse(newMessages.find(v => v.businessID === LIVE_BUSINESS.SIGN)?.data),
isParticipated: false
};
isShowActivity.value = true;
}
}
});
// 页面加载
onLoad((options) => {
console.warn('Live page onLoad = ', options);
liveID.value = options?.liveID;
getLiveActivityDetail(liveID.value).then(res => {
if (res?.data && res.data.status === 1) {
// status: 0-未开始 1-进行中 2-已结束 3-已取消
console.log('活动数据============= ', res.data);
getLiveActivityRecord(res.data.activityId).then(show => {
activityData.value = {
...res.data,
isParticipated: show.data
};
console.log('是否参加============= ', show);
isShowActivity.value = !show.data;
})
} else {
isShowActivity.value = false;
}
})
if (liveID.value) {
joinLive({
liveID: liveID.value,