import { defineComponent } from "vue"; import * as RuntimeUtils from '/src/components/live-broadcast/runtime' import styles from './index.module.less' 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"; export default defineComponent({ props: { data: { type: Array, default: () => ([]) } }, data() { return { lookList: [] as any[], // 观看学生列表 loadingLook: false, // 观看列表状态 } }, mounted() { this.loadingLook = true event.on(LIVE_EVENT_MESSAGE["RC:Chatroom:Welcome"], this.onWelcome); setTimeout(() => { this.loadingLook = false; }, 2000); }, methods: { onWelcome(value: any) { console.log(value) if (value && value.user) { const sendTime = dayjs(value.$EventMessage.sentTime || new Date()).format('HH:mm:ss') let tempObj = { name: value.user.name, id: value.user.id, sendTime } // 判断是否有同一个人 let isExist = false; this.lookList.forEach((item: any) => { if (item.id === tempObj.id) { isExist = true } }) if (!isExist) { this.lookList.push(tempObj); } this.loadingLook = false } } }, render() { return (
{this.lookList.length > 0 ? this.lookList.map((item : any) => (
)) : this.loadingLook ?
: }
) } })