import { defineComponent } from "vue"; import styles from './index.module.less' import { ElButton } from'element-plus' import event, { LIVE_EVENT_MESSAGE } from '/src/components/live-broadcast/event'; import { state } from '/src/state' import dayjs from 'dayjs'; import Empty from "/src/components/empty"; import runtime, * as RuntimeUtils from '/src/components/live-broadcast/runtime' export default defineComponent({ props: { data: { type: Array, default: () => ([]) } }, data() { return { joinList: {} as {[key: string]: any}, // 连麦学生列表 loadingJoin: false, // 连麦列表状态 } }, computed: { count() { let count = 0 for (const key in this.joinList) { if (Object.prototype.hasOwnProperty.call(this.joinList, key)) { const item = this.joinList[key]; if (item.type === 3) { count += 1 } if (count > 3) { break } } } return count }, }, mounted() { event.on(LIVE_EVENT_MESSAGE['RC:Chatroom:SeatApply'], this.onSeatApply); event.on(LIVE_EVENT_MESSAGE['RM:RTC:SwitchRole'], this.onSwitchRole); }, methods: { onSeatApply(evt: any) { if (evt.type === 3) { this.joinList[evt.audienceId] = { name: evt.audienceName, id: evt.audienceId, type: evt.type, } } }, agree(item: any) { if (this.count > 3) { return } const data = { ...item, audienceName: item.name, audienceId: item.id, teacherId: state.user?.id, teacherName: state.user?.realName, type: 1, } this.joinList[item.id] = data RuntimeUtils.sendMessage(data, 'SeatResponse') }, refuse() { }, onSwitchRole(evt: any) { if (this.joinList[evt.userId] && evt.role === 2) { delete this.joinList[evt.userId] } } }, render() { const list = Object.values(this.joinList) return (
{item.name}