lrf402788946 4 年之前
父節點
當前提交
3633cb99b4
共有 2 個文件被更改,包括 12 次插入8 次删除
  1. 7 6
      src/views/user/live/detail.vue
  2. 5 2
      src/views/user/liveDetail.vue

+ 7 - 6
src/views/user/live/detail.vue

@@ -42,7 +42,6 @@ export default {
     // 初始化
     async initclient() {
       this.userMainId = 'sub-' + this.user.userid;
-      console.log(this.userMainId);
       // const res = await this.gensignFetch({ userid: this.userMainId });
       // if (this.$checkRes(res)) {
       this.client_ = await TRTC.createClient({
@@ -60,15 +59,15 @@ export default {
       this.microphones = await TRTC.getMicrophones();
     },
     async toLook() {
-      console.log(`roomid:98${this.liveInfo.number}89`);
-      await this.client_.join({ roomId: `98${this.liveInfo.number}89`, role: 'anchor' });
+      let roomNumber = `98${this.liveInfo.number}89`;
+      await this.client_.join({ roomId: roomNumber, role: 'anchor' });
+      this.joinRoom(roomNumber);
       // 订阅其他用户音视频
       this.client_.on('stream-subscribed', event => {
         const remoteStream = event.stream;
         console.log(remoteStream);
         // 远端流订阅成功,播放远端音视频流
         const usertempid_ = remoteStream.getUserId();
-        console.log('111' + remoteStream.getUserId());
         remoteStream.play('liveScreen');
         // if (usertempid_) {
         //   const usersplit_ = usertempid_.substring(0, 5);
@@ -88,7 +87,6 @@ export default {
       // 监听远端流增加事件
       this.client_.on('stream-added', event => {
         const remoteStream = event.stream;
-        console.log('222' + remoteStream.getType());
         // 订阅远端音频和视频流
         this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
           console.error('failed to subscribe remoteStream');
@@ -118,13 +116,16 @@ export default {
         }
       });
     },
+    async joinRoom(number) {
+      const { userid, name } = this.user;
+      this.$emit('count', { userid, name, number });
+    },
   },
   watch: {
     liveInfo: {
       immediate: true,
       deep: true,
       handler(val) {
-        console.log(val);
         if (val && val.number && !this.init) {
           this.initclient();
           this.getDevices();

+ 5 - 2
src/views/user/liveDetail.vue

@@ -6,7 +6,7 @@
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
         <el-col :span="24" class="main">
-          <liveInfos :liveInfo="liveInfo"></liveInfos>
+          <liveInfos :liveInfo="liveInfo" @count="toCount"></liveInfos>
         </el-col>
       </el-col>
     </el-row>
@@ -41,13 +41,16 @@ export default {
     }
   },
   methods: {
-    ...liveroom(['fetch']),
+    ...liveroom(['fetch', 'personCount']),
     async searchInfo() {
       const res = await this.fetch(this.id);
       if (this.$checkRes(res)) {
         this.$set(this, `liveInfo`, res.data);
       }
     },
+    async toCount(data) {
+      console.log(data);
+    },
   },
   computed: {
     ...mapState(['user']),