Procházet zdrojové kódy

更新按分区获取视频接口

reghao před 2 roky
rodič
revize
0a921ab0ad
2 změnil soubory, kde provedl 14 přidání a 18 odebrání
  1. 4 5
      src/api/video.js
  2. 10 13
      src/views/home/Video.vue

+ 4 - 5
src/api/video.js

@@ -16,9 +16,9 @@ const videoApi = {
   userVideoPostApi: '/api/content/video/user',
   userVideoCardApi: '/api/content/video/card/user',
 
+  videoPageApi: '/api/content/video/page',
   videoRecommendApi: '/api/content/video/recommend',
   similarVideoApi: '/api/content/video/similar',
-  videoPageApi: '/api/content/video/page',
   videoTagApi: '/api/content/video/tag',
   hotVideoApi: '/api/content/video/hot',
   userContentDataApi: '/api/content/userdata',
@@ -102,10 +102,9 @@ export function similarVideo(videoId) {
   return get(videoApi.similarVideoApi + '?videoId=' + videoId)
 }
 
-// 视频分页接口
-export function videoPage(pageNumber, prevId, nextId, categoryId) {
-  return get(videoApi.videoPageApi +
-    '?pageNumber=' + pageNumber + '&prevId=' + prevId + '&nextId=' + nextId + '&categoryId=' + categoryId)
+// 视频分类接口
+export function categoryVideos(categoryId, nextId) {
+  return get(videoApi.videoPageApi + '?categoryId=' + categoryId + '&nextId=' + nextId)
 }
 
 // 播放记录

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

@@ -76,7 +76,7 @@
 import VideoCard from 'components/card/VideoCard'
 import HotVideo from '@/components/card/HotVideo'
 
-import { videoCategory, videoPage} from '@/api/video'
+import { videoCategory, categoryVideos} from '@/api/video'
 
 export default {
   name: 'Video',
@@ -133,7 +133,7 @@ export default {
         duration: 3000
       })
     })
-    this.videoPageWrapper(this.currentPage, this.prevId, this.nextId, this.categoryId)
+    this.videoPageWrapper(this.categoryId, this.nextId)
   },
   mounted() {
     // 当窗口宽度改变时获取屏幕宽度
@@ -147,31 +147,28 @@ export default {
   methods: {
     prevClick(pageNumber) {
       this.currentPage = pageNumber
-      this.videoPageWrapper(this.currentPage, this.prevId, this.prevId, this.categoryId)
+      this.videoPageWrapper(this.categoryId, this.prevId)
       // 回到顶部
       scrollTo(0, 0)
     },
     nextClick(pageNumber) {
       this.currentPage = pageNumber
-      this.videoPageWrapper(this.currentPage, this.prevId, this.nextId, this.categoryId)
+      this.videoPageWrapper(this.categoryId, this.nextId)
       // 回到顶部
       scrollTo(0, 0)
     },
-    videoPageWrapper(pageNumber, prevId, nextId, categoryId) {
-      videoPage(pageNumber, prevId, nextId, categoryId).then(res => {
+    videoPageWrapper(categoryId, nextId) {
+      categoryVideos(categoryId, nextId).then(res => {
         if (res.code === 0) {
           const resData = res.data
-          if (resData.list.length > 0) {
-            this.showEmpty = false
-          } else {
-            this.showEmpty = true
-          }
+          this.showEmpty = resData.list.length <= 0;
 
           this.videoList = resData.list
           this.totalPages = resData.totalPages
           this.totalSize = resData.totalSize
-          this.prevId = resData.prevId
           this.nextId = resData.nextId
+
+          this.prevId = nextId
         } else {
           this.$notify({
             title: '提示',
@@ -201,7 +198,7 @@ export default {
       this.currentPage = 1
 
       this.videoList = []
-      this.videoPageWrapper(this.currentPage, this.prevId, this.nextId, this.categoryId)
+      this.videoPageWrapper(this.categoryId, this.nextId)
     }
   }
 }