Przeglądaj źródła

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-student

guhongwei 4 lat temu
rodzic
commit
91efffa3c6

+ 2 - 1
src/router/index.js

@@ -184,7 +184,8 @@ const routes = [
     component: () => import('../views/user/live.vue'),
     component: () => import('../views/user/live.vue'),
   },
   },
   {
   {
-    path: '/user/liveDetail',
+    path: '/user/liveDetail/:id',
+    name: 'liveDetail',
     meta: { title: '直播详情', isleftarrow: true },
     meta: { title: '直播详情', isleftarrow: true },
     component: () => import('../views/user/liveDetail.vue'),
     component: () => import('../views/user/liveDetail.vue'),
   },
   },

+ 7 - 3
src/views/login.vue

@@ -22,12 +22,16 @@ export default {
     });
     });
     let token = this.$route.query.token;
     let token = this.$route.query.token;
     let user = jwt.decode(token);
     let user = jwt.decode(token);
-    console.log(user);
     localStorage.setItem('user', JSON.stringify(user));
     localStorage.setItem('user', JSON.stringify(user));
     this.$toast.clear();
     this.$toast.clear();
-    if (!this.is_dev) this.toIndex();
+    if (this.redirect_uri) this.$router.push(this.redirect_uri);
+    else if (!this.is_dev) this.toIndex();
+  },
+  computed: {
+    redirect_uri() {
+      return this.$route.query.redirect_uri;
+    },
   },
   },
-  computed: {},
   methods: {
   methods: {
     toIndex() {
     toIndex() {
       this.$router.push({ path: '/' });
       this.$router.push({ path: '/' });

+ 47 - 38
src/views/user/live/detail.vue

@@ -35,6 +35,7 @@ export default {
       microphones: [],
       microphones: [],
       localStream_: [], //流
       localStream_: [], //流
       isInit: false,
       isInit: false,
+      roomNumber: '',
     };
     };
   },
   },
   created() {},
   created() {},
@@ -60,28 +61,16 @@ export default {
     },
     },
     async toLook() {
     async toLook() {
       let roomNumber = `98${this.liveInfo.number}89`;
       let roomNumber = `98${this.liveInfo.number}89`;
+      this.$set(this, `roomNumber`, roomNumber);
       await this.client_.join({ roomId: roomNumber, role: 'anchor' });
       await this.client_.join({ roomId: roomNumber, role: 'anchor' });
-      this.joinRoom(roomNumber);
+      this.channel();
+      this.joinRoom();
       // 订阅其他用户音视频
       // 订阅其他用户音视频
       this.client_.on('stream-subscribed', event => {
       this.client_.on('stream-subscribed', event => {
         const remoteStream = event.stream;
         const remoteStream = event.stream;
-        console.log(remoteStream);
         // 远端流订阅成功,播放远端音视频流
         // 远端流订阅成功,播放远端音视频流
         const usertempid_ = remoteStream.getUserId();
         const usertempid_ = remoteStream.getUserId();
         remoteStream.play('liveScreen');
         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_);
-        //   }
-        // }
       });
       });
 
 
       // 监听远端流增加事件
       // 监听远端流增加事件
@@ -92,34 +81,54 @@ export default {
           console.error('failed to subscribe remoteStream');
           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) {
     async joinRoom(number) {
       const { userid, name } = this.user;
       const { userid, name } = this.user;
       this.$emit('count', { userid, name, number });
       this.$emit('count', { userid, name, number });
     },
     },
+    // 订阅人数
+    channel() {
+      if (!this.roomNumber) {
+        console.warn('未获取到房间号,无法进行订阅');
+        return;
+      }
+      this.$stomp({
+        [`/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);
+        console.log(body);
+        // this.chatList.push(body);
+      }
+    },
   },
   },
   watch: {
   watch: {
     liveInfo: {
     liveInfo: {

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

@@ -9,7 +9,7 @@
             <span>主讲教师:{{ item.teacher }}</span>
             <span>主讲教师:{{ item.teacher }}</span>
           </el-col>
           </el-col>
           <el-col :span="24" class="btn">
           <el-col :span="24" class="btn">
-            <el-button type="primary" size="mini" @click="$router.push({ path: '/user/liveDetail', query: { id: item.id } })">进入直播</el-button>
+            <el-button type="primary" size="mini" @click="$router.push({ name: 'liveDetail', params: { id: item.id } })">进入直播</el-button>
           </el-col>
           </el-col>
         </el-col>
         </el-col>
       </el-col>
       </el-col>

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

@@ -49,13 +49,13 @@ export default {
       }
       }
     },
     },
     async toCount(data) {
     async toCount(data) {
-      console.log(data);
+      await this.personCount(data);
     },
     },
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),
     id() {
     id() {
-      return this.$route.query.id;
+      return this.$route.params.id;
     },
     },
   },
   },
   mounted() {
   mounted() {