reghao 2 лет назад
Родитель
Сommit
2ad27cde4a
3 измененных файлов с 52 добавлено и 40 удалено
  1. 27 17
      src/views/home/Index.vue
  2. 8 6
      src/views/home/Video.vue
  3. 17 17
      src/views/user/UserRelation.vue

+ 27 - 17
src/views/home/Index.vue

@@ -1,21 +1,30 @@
 <template>
   <div>
-    <!--电影列表,与推荐列表-->
-    <el-row v-if="dataList.length !== 0" id="movie-list"
-            v-infinite-scroll="load"
-            infinite-scroll-disabled="loading"
-            infinite-scroll-distance="10">
-      <!--电影列表-->
-      <el-col :md="24">
-        <el-col v-for="(item, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
-          <video-card :video="item" />
-        </el-col>
+    <el-row id="movie-list">
+      <el-col :md="18">
+        <!--电影列表,与推荐列表-->
+        <el-row
+          v-if="dataList.length !== 0"
+          v-infinite-scroll="load"
+          infinite-scroll-disabled="loading"
+          infinite-scroll-distance="10"
+        >
+          <!--电影列表-->
+          <el-col :md="24">
+            <el-col v-for="(item, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
+              <video-card :video="item" />
+            </el-col>
+          </el-col>
+        </el-row>
+        <el-row v-else class="not-result">
+          <el-col :span="12" :offset="6">
+            <img src="@/assets/img/icon/not-collection.png">
+            <div>推荐数据正在计算中</div>
+          </el-col>
+        </el-row>
       </el-col>
-    </el-row>
-    <el-row v-else class="not-result">
-      <el-col :span="12" :offset="6">
-        <img src="@/assets/img/icon/not-collection.png">
-        <div>推荐数据正在计算中</div>
+      <el-col :md="6">
+        <hot-video />
       </el-col>
     </el-row>
   </div>
@@ -23,11 +32,12 @@
 
 <script>
 import VideoCard from '@/components/card/VideoCard'
+import HotVideo from '@/components/card/HotVideo'
 import { videoRecommend } from '@/api/video'
 
 export default {
   name: 'Index',
-  components: { VideoCard },
+  components: { VideoCard, HotVideo },
   data() {
     return {
       // 屏幕宽度, 为了控制分页条的大小
@@ -35,7 +45,7 @@ export default {
       nextId: '1',
       dataList: [],
       loading: false,
-      max: 0,
+      max: 0
     }
   },
   created() {

+ 8 - 6
src/views/home/Video.vue

@@ -4,7 +4,7 @@
     <el-row id="movie-list">
       <!--电影列表-->
       <el-col :md="18">
-        <el-col v-for="(video, index) in dataList" v-if="totalSize !== 0" :key="index" :md="6" :sm="12" :xs="12">
+        <el-col v-for="(video, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
           <video-card :video="video" />
         </el-col>
         <!--
@@ -27,8 +27,7 @@
 
       <!--热播列表-->
       <el-col :md="6">
-        <v-jstree :data="treeNode" whole-row @item-click="itemClick" />
-        <hot-video />
+        <v-jstree :data="treeNode" @item-click="itemClick" />
       </el-col>
     </el-row>
     <el-row v-if="totalSize === 0" class="not-result">
@@ -42,14 +41,13 @@
 
 <script>
 import VideoCard from 'components/card/VideoCard'
-import HotVideo from '@/components/card/HotVideo'
 import VJstree from 'vue-jstree'
 
 import { videoCategory, categoryVideos } from '@/api/video'
 
 export default {
   name: 'Video',
-  components: { VideoCard, HotVideo, VJstree },
+  components: { VideoCard, VJstree },
   data() {
     return {
       // 屏幕宽度, 为了控制分页条的大小
@@ -128,7 +126,11 @@ export default {
       })
     },
     itemClick(node) {
-      this.categoryId = node.model.value
+      const model = node.model
+      if (model.children.length === 0) {
+        this.categoryId = model.value
+      }
+
       this.videoPageWrapper(this.categoryId, this.currentPage)
     }
   }

+ 17 - 17
src/views/user/UserRelation.vue

@@ -7,7 +7,7 @@
             <el-row>
               <el-col :md="1">
                 <el-avatar>
-                  <el-image :src="user.avatarUrl"/>
+                  <el-image :src="user.avatarUrl" />
                 </el-avatar>
               </el-col>
               <el-col :md="23">
@@ -21,7 +21,7 @@
                   :icon="followButton.icon"
                   @click="followUser(user.userId)"
                 >
-                  <span>{{followButton.text}}</span>
+                  <span>{{ followButton.text }}</span>
                 </el-button>
                 <el-button
                   type="danger"
@@ -39,24 +39,24 @@
     </el-row>
     <el-row>
       <el-col :md="24" class="movie-list">
-        <el-tabs v-model="activeName" @tab-click='tabClick'>
+        <el-tabs v-model="activeName" @tab-click="tabClick">
           <el-tab-pane name="following">
             <span slot="label">
-              Ta 的关注<el-badge :value="this.user.following" :max="9999" class="item" type="warning"/>
+              Ta 的关注<el-badge :value="this.user.following" :max="9999" class="item" type="warning" />
             </span>
             <div v-if="activeName === 'following'">
               <el-col v-for="(user, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
-                <user-avatar-card :userAvatar="user"></user-avatar-card>
+                <user-avatar-card :user-avatar="user" />
               </el-col>
             </div>
           </el-tab-pane>
           <el-tab-pane name="follower">
             <span slot="label">
-              Ta 的粉丝<el-badge :value="this.user.follower" :max="9999" class="item" type="warning"/>
+              Ta 的粉丝<el-badge :value="this.user.follower" :max="9999" class="item" type="warning" />
             </span>
             <div v-if="activeName === 'follower'">
               <el-col v-for="(user, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
-                <user-card :user="user"></user-card>
+                <user-card :user="user" />
               </el-col>
             </div>
           </el-tab-pane>
@@ -89,7 +89,7 @@
 <script>
 import UserAvatarCard from '@/components/card/UserAvatarCard'
 
-import { getUserInfo, getUserFollowing, getUserFollower, checkRelation, followUser, unfollowUser } from "@/api/user";
+import { getUserInfo, getUserFollowing, getUserFollower, checkRelation, followUser, unfollowUser } from '@/api/user'
 
 export default {
   name: 'Home',
@@ -109,7 +109,12 @@ export default {
       pageSize: 12,
       totalSize: 0,
       dataList: [],
-      showEmpty: true,
+      showEmpty: true
+    }
+  },
+  watch: {
+    $route() {
+      this.$router.go()
     }
   },
   created() {
@@ -118,10 +123,10 @@ export default {
       if (res.code === 0) {
         this.user = res.data
         const path = this.$route.path
-        if (path.endsWith("following")) {
+        if (path.endsWith('following')) {
           this.activeName = 'following'
           document.title = this.user.screenName + '的关注'
-        } else if (path.endsWith("follower")) {
+        } else if (path.endsWith('follower')) {
           this.activeName = 'follower'
           document.title = this.user.screenName + '的粉丝'
         } else {
@@ -148,16 +153,11 @@ export default {
       }
     }
   },
-  watch: {
-    $route(){
-      this.$router.go()
-    }
-  },
   methods: {
     handleCurrentChange(pageNumber) {
       this.currentPage = pageNumber
       this.getData()
-      /*if (this.activeName === 'following') {
+      /* if (this.activeName === 'following') {
         getUserFollowing(this.userId).then(res => {
           if (res.code === 0) {
             this.dataList = res.data