lrf402788946 преди 4 години
родител
ревизия
dc0f3d6981
променени са 3 файла, в които са добавени 39 реда и са изтрити 45 реда
  1. 7 2
      src/views/login.vue
  2. 31 42
      src/views/user/live/detail.vue
  3. 1 1
      src/views/user/liveDetail.vue

+ 7 - 2
src/views/login.vue

@@ -25,9 +25,14 @@ export default {
     console.log(user);
     localStorage.setItem('user', JSON.stringify(user));
     this.$toast.clear();
-    if (!this.is_dev) this.toIndex();
+    if (redirect_uri) this.$router.push({ path: this.redirect_uri });
+    else if (!this.is_dev) this.toIndex();
+  },
+  computed: {
+    redirect_uri() {
+      return this.$route.query.redirect_uri;
+    },
   },
-  computed: {},
   methods: {
     toIndex() {
       this.$router.push({ path: '/' });

+ 31 - 42
src/views/user/live/detail.vue

@@ -35,6 +35,7 @@ export default {
       microphones: [],
       localStream_: [], //流
       isInit: false,
+      roomNumber: '',
     };
   },
   created() {},
@@ -60,29 +61,16 @@ export default {
     },
     async toLook() {
       let roomNumber = `98${this.liveInfo.number}89`;
+      this.$set(this, `roomNumber`, roomNumber);
       await this.client_.join({ roomId: roomNumber, role: 'anchor' });
-      this.channel(roomNumber);
-      this.joinRoom(roomNumber);
+      this.channel();
+      this.joinRoom();
       // 订阅其他用户音视频
       this.client_.on('stream-subscribed', event => {
         const remoteStream = event.stream;
-        console.log(remoteStream);
         // 远端流订阅成功,播放远端音视频流
         const usertempid_ = remoteStream.getUserId();
         remoteStream.play('liveScreen');
-        // if (usertempid_) {
-        //   const usersplit_ = usertempid_.substring(0, 5);
-        //   if (usersplit_ === 'other') {
-        //     const id_ = 'othe-video-' + usertempid_;
-        //     remoteStream.play(id_);
-        //   } else if (usersplit_ === 'wxxcx') {
-        //     const id_ = 'look-video-' + usertempid_;
-        //     remoteStream.play(id_);
-        //   } else if (usersplit_ === 'meetu') {
-        //     const id_ = 'look-video-' + usertempid_;
-        //     remoteStream.play(id_);
-        //   }
-        // }
       });
 
       // 监听远端流增加事件
@@ -93,46 +81,47 @@ export default {
           console.error('failed to subscribe remoteStream');
         });
       });
-      this.client_.on('stream-removed', event => {
-        const remoteStream = event.stream;
-        console.log('stop----');
-        const usertempid_ = remoteStream.getUserId();
-        if (usertempid_) {
-          const usersplit_ = usertempid_.substring(0, 5);
-          if (usersplit_ === 'other') {
-            this.index_ = this.index_ - 1;
-          }
-        }
-        remoteStream.stop();
-      });
-      this.client_.on('mute-video', event => {
-        const remoteStream = event.stream;
-        // 订阅远端音频和视频流
-        const usertempid_ = remoteStream.getUserId();
-        if (usertempid_) {
-          const usersplit_ = usertempid_.substring(0, 4);
-          if (usersplit_ === 'othe') {
-            this.index_ = this.index_ - 1;
-          }
-        }
-      });
+      // this.client_.on('stream-removed', event => {
+      //   const remoteStream = event.stream;
+      //   console.log('stop----');
+      //   const usertempid_ = remoteStream.getUserId();
+      //   if (usertempid_) {
+      //     const usersplit_ = usertempid_.substring(0, 5);
+      //     if (usersplit_ === 'other') {
+      //       this.index_ = this.index_ - 1;
+      //     }
+      //   }
+      //   remoteStream.stop();
+      // });
+      // this.client_.on('mute-video', event => {
+      //   const remoteStream = event.stream;
+      //   // 订阅远端音频和视频流
+      //   const usertempid_ = remoteStream.getUserId();
+      //   if (usertempid_) {
+      //     const usersplit_ = usertempid_.substring(0, 4);
+      //     if (usersplit_ === 'othe') {
+      //       this.index_ = this.index_ - 1;
+      //     }
+      //   }
+      // });
     },
     async joinRoom(number) {
       const { userid, name } = this.user;
       this.$emit('count', { userid, name, number });
     },
     // 订阅人数
-    channel(roomNumber) {
-      if (!roomNumber) {
+    channel() {
+      if (!this.roomNumber) {
         console.warn('未获取到房间号,无法进行订阅');
         return;
       }
       this.$stomp({
-        [`/exchange/liveroom-personcount/${roomNumber}`]: this.onMessage,
+        [`/exchange/liveroom-personcount/${this.roomNumber}`]: this.onMessage,
       });
     },
     onMessage(message) {
       let body = _.get(message, 'body');
+      console.log(body);
       if (body) {
         if (body == '消息已查收') return;
         body = JSON.parse(body);

+ 1 - 1
src/views/user/liveDetail.vue

@@ -49,7 +49,7 @@ export default {
       }
     },
     async toCount(data) {
-      console.log(data);
+      await this.personCount(data);
     },
   },
   computed: {