join-model.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { defineComponent } from "vue";
  2. import styles from './index.module.less'
  3. import event, { LIVE_EVENT_MESSAGE } from '/src/components/live-broadcast/event';
  4. import { state } from '/src/state'
  5. import dayjs from 'dayjs';
  6. import Empty from "/src/components/empty";
  7. import runtime, * as RuntimeUtils from '/src/components/live-broadcast/runtime'
  8. export default defineComponent({
  9. props: {
  10. data: {
  11. type: Array,
  12. default: () => ([])
  13. }
  14. },
  15. data() {
  16. return {
  17. joinList: [] as any[], // 连麦学生列表
  18. loadingJoin: false, // 连麦列表状态
  19. }
  20. },
  21. mounted() {
  22. event.on(LIVE_EVENT_MESSAGE['RC:Chatroom:SeatApply'], this.onSeatApply);
  23. },
  24. methods: {
  25. onSeatApply(evt: any) {
  26. console.log(evt)
  27. if (evt.type === 3) {
  28. this.joinList.push({
  29. name: evt.audienceName,
  30. id: evt.audienceId,
  31. type: evt.type,
  32. })
  33. }
  34. },
  35. agree() {
  36. RuntimeUtils.sendMessage({
  37. audienceId: '1094335',
  38. audienceName: '小伙伴',
  39. teacherId: state.user?.id,
  40. teacherName: state.user?.realName,
  41. type: 1,
  42. }, 'SeatResponse')
  43. },
  44. refuse() {},
  45. },
  46. render() {
  47. console.log(this.joinList.length)
  48. return (
  49. <div style={{ minHeight: '100%', position: 'relative' }}>
  50. {this.joinList.length > 0 ? this.joinList.map((item : any) => (
  51. <div class={styles.itemContent}>
  52. <img src="/src/assets/home/placehorder-icon.png" alt="" />
  53. <div class={styles.itemInfo}>
  54. <div class={styles.itemName}>
  55. <p class={styles.userName}>{item.name}</p>
  56. </div>
  57. {item.type === 3 ? (
  58. <div class={styles.joinText}>
  59. <div class={styles.join}>
  60. 申请连麦
  61. </div>
  62. <div class={styles.btn} onClick={this.agree}>上麦</div>
  63. </div>
  64. ) : (
  65. <div class={styles.joinText}>
  66. <div class={styles.join}>
  67. 正在连麦
  68. </div>
  69. <div class={styles.btn} onClick={this.refuse}>下麦</div>
  70. </div>
  71. )}
  72. </div>
  73. </div>
  74. )) : this.loadingJoin ? <div class={styles.loadingStyle} v-loading={this.loadingJoin} element-loading-background="rgba(0, 0, 0, 0.8)"></div> : <Empty text="暂无学员发起连麦!" icon="noData-no-join" />}
  75. </div>
  76. )
  77. }
  78. })