Ver código fonte

链接修改

wolyshaw 3 anos atrás
pai
commit
b475b9f0e7

+ 1 - 0
src/components/live-broadcast/event.ts

@@ -8,6 +8,7 @@ export const LIVE_EVENT_MESSAGE = {
   'RC:Chatroom:SeatsCtrl': 'SeatsCtrl',
   'RC:Chatroom:ChatBan': 'ChatBan',
   'RC:Chatroom:SeatApply': 'SeatApply',
+  'RC:Chatroom:SeatResponse': 'SeatResponse',
   'RM:RTC:TrackUnpublish': 'TrackUnpublish',
   'RM:RTC:SwitchRole': 'SwitchRole',
   'RM:RTC:UserLeave': 'UserLeave',

+ 1 - 0
src/components/live-message/model/join-model.tsx

@@ -39,6 +39,7 @@ export default defineComponent({
   },
   mounted() {
     event.on(LIVE_EVENT_MESSAGE['RC:Chatroom:SeatApply'], this.onSeatApply);
+    event.on(LIVE_EVENT_MESSAGE['RC:Chatroom:SeatResponse'], this.onSeatApply);
     event.on(LIVE_EVENT_MESSAGE['RM:RTC:UserLeave'], this.onSeatApply);
     event.on(LIVE_EVENT_MESSAGE['RM:RTC:SwitchRole'], this.onSwitchRole);
   },

+ 17 - 6
src/components/live-message/model/look-model.tsx

@@ -1,5 +1,5 @@
 import { defineComponent } from "vue";
-import * as RuntimeUtils from '/src/components/live-broadcast/runtime'
+import runtime, * 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'
@@ -49,7 +49,21 @@ export default defineComponent({
 
         this.loadingLook = false
       }
-    }
+    },
+    async invteUser(item: any) {
+      const roomUids = await runtime.joinedRoom?.getRemoteUserIds() || []
+      if (roomUids.length < 3) {
+        const data = {
+          audienceName: item.name,
+          audienceId: item.id,
+          teacherId: state.user?.id,
+          teacherName: state.user?.realName,
+          type: 1,
+        }
+        // this.joinList[item.id] = data
+        RuntimeUtils.sendMessage(data, 'SeatApply')
+      }
+    },
   },
   render() {
     return (
@@ -60,10 +74,7 @@ export default defineComponent({
             <div class={styles.itemInfo} >
               <div class={styles.itemName}>
                 <p class={styles.userName}>{item.name}</p>
-                <a href="javascript:;" class={styles.btn} onClick={() => RuntimeUtils.sendMessage(
-                  {seatBan:false, ...RuntimeUtils.getSendMessageUser()},
-                  'SeatsCtrl'
-                )}>上麦</a>
+                <a href="javascript:;" class={styles.btn} onClick={() => this.invteUser(item)}>上麦</a>
               </div>
             </div>
           </div>