Ver Fonte

update Video.vue

reghao há 2 anos atrás
pai
commit
edfc812c30

+ 2 - 2
src/components/VideoPlayer.vue

@@ -31,8 +31,6 @@ export default {
   created() {
   },
   mounted() {
-    SocketInstance.connect()
-
     const videoId = this.videoProp.videoId
     if (this.getUrl) {
       this.getVideoUrl(videoId)
@@ -42,6 +40,8 @@ export default {
     getVideoUrl(videoId) {
       videoUrl(videoId).then(res => {
         if (res.code === 0) {
+          SocketInstance.connect()
+
           const urlType = res.data.type
           if (urlType === 'mp4') {
             const urls = res.data.urls

+ 14 - 7
src/components/comment/Comment.vue

@@ -80,26 +80,33 @@ export default {
       content: '',
       comments: [],
       user: {
-        uid: 11011,
+        uid: 10001,
         nickname: '大西瓜',
-        avatarurl: 'https://oss.reghao.cn/image/BXJD1jDpRL.webp'
+        avatarurl: 'https://picx.zhimg.com/v2-ed8c334e05383b3e914e6a31dd955af8_xl.jpg'
       }
     }
   },
   created() {
     this.comments = [
       {
-        uid: 11011,
+        uid: 10001,
         nickname: '大西瓜',
-        avatarurl: 'https://picx.zhimg.com/v2-6fd63e002c1b9b7ee99cf635608f9467_xl.jpg',
-        content: 'hhhhhhhhhhhhhhh',
+        avatarurl: 'https://picx.zhimg.com/v2-ed8c334e05383b3e914e6a31dd955af8_xl.jpg',
+        content: 'hha',
+        date: new Date()
+      },
+      {
+        uid: 10002,
+        nickname: '草莓',
+        avatarurl: 'https://picx.zhimg.com/v2-77acf2ee1f90de86221acbbbfd7967ae_xl.jpg',
+        content: 'bbc',
         date: new Date()
       },
       {
-        uid: 11012,
+        uid: 10003,
         nickname: '大芒果',
         avatarurl: 'https://picx.zhimg.com/v2-6fd63e002c1b9b7ee99cf635608f9467_xl.jpg',
-        content: 'kkkkkkkkkkkkkkkkk',
+        content: 'kka',
         date: new Date()
       }
     ]

+ 17 - 13
src/views/home/Video.vue

@@ -8,9 +8,9 @@
             :key="index"
             type="info"
             size="mini"
-            :plain="currentCategory !== index"
-            @click="chooseCategory(item, index)"
-          >{{ item }}
+            :plain="currentCategory !== item.id"
+            @click="chooseCategory(item)"
+          >{{ item.name }}
           </el-button>
         </div>
       </el-col>
@@ -23,8 +23,8 @@
             :key="index"
             type="warning"
             size="mini"
-            :plain="currentChildCategory !== index"
-            @click="getVideoList(item.id, index)"
+            :plain="currentChildCategory !== item.id"
+            @click="getVideoList(item.id)"
           >{{ item.name }}
           </el-button>
         </div>
@@ -92,7 +92,7 @@ export default {
       videoList: [],
       prevId: '0',
       nextId: '0',
-      categoryId: 2,
+      categoryId: 1,
       currentIndex: 0,
       currentCategory: 0,
       currentChildCategory: 0,
@@ -114,9 +114,13 @@ export default {
       if (res.code === 0) {
         for (let i = 0; i < res.data.length; i++) {
           const name = res.data[i].name
-          this.category.push(name)
-          this.categoryMap.Set(name, res.data[i])
+          this.category.push(res.data[i])
+          this.categoryMap.Set(res.data[i].id, res.data[i])
         }
+
+        this.currentCategory = 1
+        this.childCategory = this.categoryMap.Get(this.currentCategory).children
+        this.currentChildCategory = 19
       } else {
         this.$notify({
           title: '提示',
@@ -186,12 +190,12 @@ export default {
         })
       })
     },
-    chooseCategory(item, index) {
-      this.currentCategory = index
-      this.childCategory = this.categoryMap.Get(item).children
+    chooseCategory(item) {
+      this.currentCategory = item.id
+      this.childCategory = this.categoryMap.Get(item.id).children
     },
-    getVideoList(categoryId, index) {
-      this.currentChildCategory = index
+    getVideoList(categoryId) {
+      this.currentChildCategory = categoryId
       this.categoryId = categoryId;
       this.prevId = 0
       this.nextId = 0

+ 2 - 2
src/views/home/VideoPage.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-row class="movie-list">
+  <el-row v-if="video !== null" class="movie-list">
     <el-col :md="15">
       <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
         <el-card class="box-card">
@@ -115,7 +115,7 @@
     <el-col :md="9">
       <el-row>
         <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
-          <user-avatar-card :userAvatar="user" />
+          <user-avatar-card v-if="user !== null" :userAvatar="user" />
         </el-row>
         <el-row v-if="showPlaylist" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
           <el-card class="box-card">