Sfoglia il codice sorgente

1.更新用户主页
2.更新用户关系页
3.更新 VideoCard.vue

reghao 2 anni fa
parent
commit
c570a59555

+ 7 - 6
src/api/video.js

@@ -12,12 +12,13 @@ const videoApi = {
   videoUrlApi: '/api/content/video/url',
   videoDownloadApi: '/api/content/video/download',
   videoDeleteApi: '/api/content/video/delete',
+  userVideoPostApi: '/api/content/video/user',
+  userVideoCardApi: '/api/content/video/card/user',
 
   videoRecommendApi: '/api/content/video/recommend',
   similarVideoApi: '/api/content/video/similar',
   videoPageApi: '/api/content/video/page',
   videoTagApi: '/api/content/video/tag',
-  userVideoPostApi: '/api/content/video/user',
   hotVideoApi: '/api/content/video/hot',
   userContentDataApi: '/api/content/userdata',
   playerRecordApi: '/api/media/video/play/record',
@@ -106,11 +107,6 @@ export function submitPlayRecord(playerRecord) {
   return post(videoApi.playerRecordApi, playerRecord)
 }
 
-// 用户视频列表
-export function userVideoList(pageNumber, userId, lastId) {
-  return get(videoApi.userVideoPostApi + '?pageNumber=' + pageNumber + '&userId=' + userId + '&lastId=' + lastId)
-}
-
 export function userVideoPost(pageNumber) {
   return get(videoApi.userVideoPostApi + '?pageNumber=' + pageNumber)
 }
@@ -119,6 +115,11 @@ export function getUserVideoPost(videoId) {
   return get(videoApi.userVideoPostApi + '/' + videoId)
 }
 
+// 用户视频列表
+export function userVideoCard(pageNumber, userId) {
+  return get(videoApi.userVideoCardApi + '?pageNumber=' + pageNumber + '&userId=' + userId)
+}
+
 // 用户最近投稿的视频
 export function userRecentlyVideoList(userId) {
   return get(videoApi.userRecentlyVideoListApi + '?userId=' + userId)

+ 7 - 1
src/components/card/VideoCard.vue

@@ -30,7 +30,13 @@
         </div>
         <div v-if="video.user !== undefined && video.user !== null" style="padding: 14px">
           <span style="left: 0;margin-bottom: 0px;color: black;">
-            <router-link target="_blank" :to="`/user/${video.user.userId}`"><i class="el-icon-user"> {{ video.user.screenName }} </i></router-link> · {{ convertTimestamp(video.pubDate) }}
+            <router-link target="_blank" :to="`/user/${video.user.userId}`">
+              <i class="el-icon-user"> {{ video.user.screenName }} </i></router-link> • {{ video.pubDateStr }}
+          </span>
+        </div>
+        <div v-if="video.user === undefined || video.user === null" style="padding: 14px">
+          <span style="left: 0;margin-bottom: 0px;color: black;">
+            {{ video.pubDateStr }}
           </span>
         </div>
       </el-card>

+ 15 - 39
src/views/user/Home.vue

@@ -56,7 +56,7 @@
               视频<el-badge :value="userContentData.videoCount" :max="9999" class="item" type="warning"/>
             </span>
             <div v-if="activeName === 'video'">
-              <el-col v-for="(video, index) in videoList" :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>
             </div>
@@ -136,7 +136,7 @@ import ImageAlbumCard from '@/components/card/ImageAlbumCard'
 import AudioCard from '@/components/card/AudioCard'
 
 import { getUserInfo, getUserFollowing, getUserFollower, checkRelation, followUser, unfollowUser } from "@/api/user";
-import { userVideoList, getUserContentData } from "@/api/video";
+import { getUserContentData, userVideoCard } from "@/api/video";
 import { getUserAlbums } from "@/api/image";
 import { getUserAudio } from "@/api/audio";
 import { userStatus } from "@/api/status";
@@ -159,10 +159,6 @@ export default {
       pageSize: 12,
       totalSize: 0,
       dataList: [],
-      videoList: [],
-      statusList: [],
-      followerList: [],
-      followingList: [],
       showEmpty: true,
       userContentData: null
     }
@@ -231,21 +227,9 @@ export default {
     handleCurrentChange(pageNumber) {
       this.currentPage = pageNumber
       if (this.activeName === 'video') {
-        this.userVideoListWrapper(this.currentPage, this.userId, this.lastId)
+        this.userVideoListWrapper(this.currentPage, this.userId)
       } else if (this.activeName === 'status') {
-        this.userStatusListWrapper(this.currentPage, this.userId, this.lastId)
-      } else if (this.activeName === 'following') {
-        getUserFollowing(this.userId).then(res => {
-          if (res.code === 0) {
-            this.followingList = res.data
-          }
-        })
-      } else if (this.activeName === 'follower') {
-        getUserFollower(this.userId).then(res => {
-          if (res.code === 0) {
-            this.followerList = res.data
-          }
-        })
+        this.userStatusListWrapper(this.currentPage, this.userId)
       }
 
       // 回到顶部
@@ -264,10 +248,9 @@ export default {
       this.$router.push(path)
     },
     getData() {
+      this.dataList = []
       if (this.activeName === 'video') {
-        this.currentPage = 1
-        this.lastId = 0
-        this.userVideoListWrapper(this.currentPage, this.userId, this.lastId)
+        this.userVideoListWrapper(this.currentPage, this.userId)
       } else if (this.activeName === 'image') {
         getUserAlbums(this.userId).then(res => {
           if (res.code === 0) {
@@ -283,8 +266,6 @@ export default {
           }
         })
       } else if (this.activeName === 'audio') {
-        this.currentPage = 1
-        this.lastId = 0
         getUserAudio(this.userId).then(res => {
           if (res.code === 0) {
             const resData = res.data.list
@@ -299,12 +280,9 @@ export default {
           }
         })
       } else if (this.activeName === 'article') {
-        this.currentPage = 1
-        this.lastId = 0
+        // todo
       } else if (this.activeName === 'status') {
-        this.currentPage = 1
-        this.lastId = 0
-        this.userStatusListWrapper(this.currentPage, this.userId, this.lastId)
+        this.userStatusListWrapper(this.currentPage, this.userId)
       }
     },
     followUser(userId) {
@@ -327,15 +305,13 @@ export default {
     sendMessage(userId) {
       console.log('发送消息')
     },
-    userVideoListWrapper(pageNumber, userId, lastId) {
-      userVideoList(pageNumber, userId, lastId).then(res => {
+    userVideoListWrapper(pageNumber, userId) {
+      userVideoCard(pageNumber, userId).then(res => {
         if (res.code === 0) {
           const resData = res.data
-          this.videoList = resData.list
+          this.dataList = resData.list
           this.totalSize = resData.totalSize
-          this.lastId = resData.lastId
-
-          if (this.videoList.length !== 0) {
+          if (this.dataList.length !== 0) {
             this.showEmpty = false
           } else {
             this.showEmpty = true
@@ -343,11 +319,11 @@ export default {
         }
       })
     },
-    userStatusListWrapper(pageNumber, userId, lastId) {
+    userStatusListWrapper(pageNumber, userId) {
       userStatus(userId, pageNumber).then(res => {
         if (res.code === 0) {
-          this.statusList = res.data.list
-          if (this.statusList.length === 0) {
+          this.dataList = res.data.list
+          if (this.dataList.length === 0) {
             this.showEmpty = true
           } else {
             this.showEmpty = false

+ 7 - 10
src/views/user/UserRelation.vue

@@ -46,7 +46,7 @@
             </span>
             <div v-if="activeName === 'following'">
               <el-col v-for="(user, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
-                <user-card :user="user"></user-card>
+                <user-avatar-card :userAvatar="user"></user-avatar-card>
               </el-col>
             </div>
           </el-tab-pane>
@@ -87,13 +87,13 @@
 </template>
 
 <script>
-import UserCard from '@/components/card/UserCard'
+import UserAvatarCard from '@/components/card/UserAvatarCard'
 
 import { getUserInfo, getUserFollowing, getUserFollower, checkRelation, followUser, unfollowUser } from "@/api/user";
 
 export default {
   name: 'Home',
-  components: { UserCard},
+  components: { UserAvatarCard },
   data() {
     return {
       // 屏幕宽度, 为了控制分页条的大小
@@ -154,14 +154,10 @@ export default {
     }
   },
   methods: {
-    initPagination() {
-      this.pageSize = 12
-      this.currentPage = 1
-      this.totalSize = 0
-    },
     handleCurrentChange(pageNumber) {
       this.currentPage = pageNumber
-      if (this.activeName === 'following') {
+      this.getData()
+      /*if (this.activeName === 'following') {
         getUserFollowing(this.userId).then(res => {
           if (res.code === 0) {
             this.dataList = res.data
@@ -173,7 +169,7 @@ export default {
             this.dataList = res.data
           }
         })
-      }
+      }*/
 
       // 回到顶部
       scrollTo(0, 0)
@@ -191,6 +187,7 @@ export default {
       this.$router.push(path)
     },
     getData() {
+      this.dataList = []
       if (this.activeName === 'following') {
         getUserFollowing(this.userId).then(res => {
           if (res.code === 0) {