需要添加直播接口

This commit is contained in:
cbb
2026-01-12 17:52:15 +08:00
parent 83fec2617c
commit 13af9eb303
281 changed files with 313157 additions and 104 deletions

View File

@@ -0,0 +1,313 @@
<template>
<view class="bottom-drawer-container" v-if="modelValue">
<view class="drawer-overlay" @tap="close"></view>
<view class="bottom-drawer" :class="{ 'drawer-open': modelValue }">
<view class="drawer-header">
<view class="user-info">
<image class="user-avatar" :src="userInfo?.avatarURL || defaultAvatarURL" mode="aspectFill" />
<view class="user-details">
<view class="name-badge-row">
<text class="user-name">{{ userInfo?.userName || userInfo?.userID || '' }}</text>
<!-- <view class="badge">
<image class="badge-icon" src="/static/images/heart.png" mode="aspectFit" />
<text class="badge-text">65</text>
</view> -->
</view>
<text class="user-id">ID: {{ userInfo?.userID || '' }}</text>
</view>
</view>
<!-- <view class="follow-button" @tap="followUser">
<text class="follow-text">Follow</text>
</view> -->
</view>
<view class="drawer-content">
<view class="drawer-actions">
<!-- <view class="action-btn" @tap="muteSpeak">
<view class="action-btn-image-container">
<image class="action-btn-image" v-if="userInfo?.isMessageDisabled" src="/static/images/unmute-speak.png"
mode="aspectFit" />
<image class="action-btn-image" v-else src="/static/images/mute-speak.png" mode="aspectFit" />
</view>
<text class="action-btn-content" v-if="userInfo?.isMessageDisabled">解除禁言</text>
<text class="action-btn-content" v-else>禁言</text>
</view> -->
<view class="action-btn" @tap="kickOut">
<view class="action-btn-image-container">
<image class="action-btn-image" src="/static/images/kick-out-room.png" mode="aspectFit" />
</view>
<text class="action-btn-content">踢出房间</text>
</view>
</view>
<!-- <view class="divider-line-container">
<view class="divider-line"></view>
</view> -->
</view>
</view>
</view>
</template>
<script setup>
import {
ref
} from 'vue';
import {
useLiveListState
} from "@/uni_modules/tuikit-atomic-x/state/LiveListState";
import {
useLiveAudienceState
} from "@/uni_modules/tuikit-atomic-x/state/LiveAudienceState";
const {
currentLive
} = useLiveListState();
const {
setAdministrator,
revokeAdministrator,
kickUserOutOfRoom,
disableSendMessage
} = useLiveAudienceState(uni?.$liveID);
const defaultAvatarURL = 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_01.png';
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
userInfo: {
type: Object,
},
liveID: {
type: String,
}
});
const emit = defineEmits(['update:modelValue']);
const close = () => {
emit('update:modelValue', false);
};
const muteSpeak = () => {
console.log(
`mute or unMute speak, liveID: ${props.liveID}, isMessageDisabled: ${props?.userInfo?.isMessageDisabled}`);
const params = {
liveID: uni?.$liveID,
userID: props?.userInfo?.userID,
isDisable: !props?.userInfo?.isMessageDisabled,
};
if (props?.userInfo?.isMessageDisabled) {
disableSendMessage(params);
} else {
disableSendMessage(params);
}
close();
};
const kickOut = () => {
console.log('kick out from room', props?.userInfo?.userID);
uni.showModal({
content: `确认踢出${props?.userInfo?.userName || props?.userInfo?.userID}吗?`,
success: (res) => {
if (res.confirm) {
kickUserOutOfRoom({
liveID: uni?.$liveID,
userID: props?.userInfo?.userID,
success: () => {
close()
console.log(`kickUserOutOfRoom success`);
},
fail: (errCode, errMsg) => {
console.log(`kickUserOutOfRoom fail errCode: ${errCode}, errMsg: ${errMsg}`);
},
});
}
}
});
};
const followUser = () => {
console.warn('== 关注用户 ', userInfo?.userName);
// 这里可以添加关注用户的逻辑
uni.showToast({
title: '关注成功',
icon: 'success'
});
}
</script>
<style>
.bottom-drawer-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
top: 0;
z-index: 1000;
}
.drawer-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
}
.bottom-drawer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(34, 38, 46, 1);
border-top-left-radius: 32rpx;
border-top-right-radius: 32rpx;
transform: translateY(100%);
transition-property: transform;
transition-duration: 0.3s;
transition-timing-function: ease;
height: 400rpx;
flex-direction: column;
}
.drawer-open {
transform: translateY(0);
}
.drawer-header {
padding: 40rpx 48rpx;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.user-info {
display: flex;
flex-direction: row;
align-items: center;
}
.user-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 40rpx;
border-width: 2rpx;
border-color: #ffffff;
margin-right: 20rpx;
}
.user-details {
display: flex;
flex-direction: column;
}
.name-badge-row {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 8rpx;
}
.user-name {
color: #ffffff;
font-size: 32rpx;
font-weight: 500;
margin-right: 16rpx;
}
.badge {
display: flex;
flex-direction: row;
align-items: center;
background-color: #8B5CF6;
padding: 4rpx 12rpx;
border-radius: 16rpx;
}
.badge-icon {
width: 24rpx;
height: 24rpx;
margin-right: 8rpx;
}
.badge-text {
color: #ffffff;
font-size: 24rpx;
font-weight: 500;
}
.user-id {
color: rgba(255, 255, 255, 0.7);
font-size: 24rpx;
}
.follow-button {
background-color: #007AFF;
padding: 12rpx 32rpx;
border-radius: 32rpx;
/* height: 64rpx; */
}
.follow-text {
color: #ffffff;
font-size: 28rpx;
font-weight: 500;
}
.drawer-content {
height: 400rpx;
justify-content: flex-start;
padding: 0 48rpx;
}
.drawer-actions {
display: flex;
flex-direction: row;
}
.action-btn {
flex-direction: column;
align-items: center;
margin-left: 10rpx;
height: 160rpx;
width: 120rpx
}
.action-btn-image-container {
width: 100rpx;
height: 100rpx;
background-color: rgba(43, 44, 48, 1);
margin-bottom: 16rpx;
border-radius: 20rpx;
justify-content: center;
align-items: center;
}
.action-btn-image {
width: 50rpx;
height: 50rpx;
}
.action-btn-content {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.9);
}
.divider-line-container {
height: 68rpx;
justify-content: center;
position: relative;
}
.divider-line {
width: 268rpx;
height: 10rpx;
border-radius: 200rpx;
background-color: #ffffff;
position: absolute;
bottom: 16rpx;
}
</style>

View File

@@ -0,0 +1,300 @@
<template>
<view class="bottom-drawer-container" v-if="modelValue">
<view class="drawer-overlay" @tap="close"></view>
<view class="bottom-drawer" :class="{ 'drawer-open': modelValue }">
<view class="live-audience-list">
<view class="audience-header">
<text class="audience-title">在线观众</text>
</view>
<scroll-view class="audience-content" scroll-y @scroll="handleScroll" :scroll-top="scrollTop">
<view v-if="audienceList.length > 0" class="audience-grid">
<view v-for="audience in audienceList" :key="audience.userID" class="audience-item">
<view class="audience-info">
<view class="audience-avatar-container">
<image class="audience-avatar" :src="audience.avatarURL || defaultAvatarURL" mode="aspectFill" />
</view>
<view class="audience-item-right">
<view class="audience-detail">
<text class="audience-name" :numberOfLines="1">{{ audience.userName || audience.userID }}</text>
<view v-if="audience.tag" class="audience-tag">
<text class="tag-text">{{ audience.tag }}</text>
</view>
</view>
<view class="audience-more" v-if="loginUserInfo?.userID === currentLive.liveOwner.userID"
@tap="audienceOperator(audience)">
<text class="more-text">···</text>
</view>
</view>
</view>
</view>
</view>
<view v-if="audienceList.length === 0" class="empty-state">
<text class="empty-text">暂无观众</text>
<view></view>
</view>
<view v-if="isLoading" class="loading-state">
<image src="/static/images/loading.png" mode="aspectFit" class="loading-image" />
</view>
</scroll-view>
</view>
</view>
<AudienceActionPanel v-model="isShowAudienceActionPanel" :userInfo="selectedAudience" :liveID="liveID">
</AudienceActionPanel>
</view>
</template>
<script setup>
import {
ref,
onMounted
} from 'vue';
import AudienceActionPanel from '@/uni_modules/tuikit-atomic-x/components/LiveAudienceList/AudienceActionPanel.nvue';
import {
useLiveAudienceState
} from "@/uni_modules/tuikit-atomic-x/state/LiveAudienceState";
import {
useLoginState
} from "@/uni_modules/tuikit-atomic-x/state/LoginState";
import {
useLiveListState
} from "@/uni_modules/tuikit-atomic-x/state/LiveListState";
const {
currentLive
} = useLiveListState();
const {
loginUserInfo
} = useLoginState();
const {
audienceList,
audienceListCursor
} = useLiveAudienceState(uni?.$liveID);
const defaultAvatarURL = 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_01.png';
const isLoading = ref(false);
const currentCursor = ref(0);
const scrollTop = ref(0);
const isShowAudienceActionPanel = ref(false);
const selectedAudience = ref(null);
const safeArea = ref({
left: 0,
right: 0,
top: 0,
bottom: 0,
width: 375,
height: 750,
});
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
currentViewerCount: {
type: Number,
default: 0,
},
liveID: {
type: String,
}
});
const emit = defineEmits(['update:modelValue']);
const close = () => {
emit('update:modelValue', false);
};
// 初始化加载
onMounted(() => {
uni.getSystemInfo({
success: (res) => {
safeArea.value = res.safeArea;
}
});
});
const handleScroll = (e) => {
if (currentCursor.value === 0) return;
const {
scrollHeight,
scrollTop: currentScrollTop
} = e.detail;
scrollTop.value = currentScrollTop;
if (scrollHeight - currentScrollTop < 100) {
// loadAudiences(currentCursor.value);
}
};
const audienceOperator = (audience) => {
selectedAudience.value = audience;
isShowAudienceActionPanel.value = true;
};
</script>
<style>
.bottom-drawer-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
top: 0;
z-index: 1000;
}
.drawer-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
}
.bottom-drawer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: #1F2024;
border-top-left-radius: 32rpx;
border-top-right-radius: 32rpx;
transform: translateY(100%);
transition-property: transform;
transition-duration: 0.3s;
transition-timing-function: ease;
height: 1000rpx;
}
.drawer-open {
transform: translateY(0);
}
.live-audience-list {
flex: 1;
}
.audience-header {
padding: 32rpx;
flex-direction: row;
align-items: center;
display: flex;
height: 100rpx;
position: relative;
}
.empty-state {
padding: 64rpx;
justify-content: center;
align-items: center;
}
.empty-text {
color: #999999;
font-size: 28rpx;
}
.audience-title {
font-size: 32rpx;
color: #ffffff;
font-weight: 400;
flex: 1;
text-align: center;
line-height: 100rpx;
}
.audience-content {
flex: 1;
padding: 0 32rpx;
}
.audience-grid {
flex-direction: column;
}
.audience-item {
padding: 16rpx 0;
}
.audience-info {
flex-direction: row;
align-items: center;
}
.audience-avatar-container {
width: 80rpx;
height: 80rpx;
margin-right: 20rpx;
}
.audience-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 40rpx;
}
.audience-item-right {
flex: 1;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.audience-detail {
flex-direction: row;
align-items: center;
}
.audience-name {
font-size: 28rpx;
color: #ffffff;
margin-right: 12rpx;
max-width: 300rpx;
lines: 1;
overflow: hidden;
text-overflow: ellipsis;
}
.audience-tag {
background-color: #007AFF;
border-radius: 6rpx;
padding: 4rpx 12rpx;
}
.tag-text {
color: #ffffff;
font-size: 24rpx;
}
.audience-more {
padding: 0 20rpx;
}
.more-text {
font-size: 40rpx;
color: #ffffff;
font-weight: bold;
}
.empty-state,
.loading-state {
padding: 32rpx;
justify-content: center;
align-items: center;
}
.empty-text {
color: rgba(255, 255, 255, 0.6);
font-size: 28rpx;
}
.loading-image {
width: 48rpx;
height: 48rpx;
}
</style>