Ver Fonte

更新视频分页页面

reghao há 2 anos atrás
pai
commit
0ae61ca831
3 ficheiros alterados com 39 adições e 17541 exclusões
  1. 1 17534
      package-lock.json
  2. 7 0
      src/api/video.js
  3. 31 7
      src/views/home/Video.vue

Diff do ficheiro suprimidas por serem muito extensas
+ 1 - 17534
package-lock.json


+ 7 - 0
src/api/video.js

@@ -3,6 +3,7 @@ import { get, post } from '@/utils/request'
 const videoApi = {
   videoRecommendApi: '/api/content/video/recommend',
   similarVideoApi: '/api/content/video/similar',
+  videoPageApi: '/api/content/video/page',
   videoInfoApi: '/api/content/video/detail',
   videoCategoryApi: '/api/content/video/category',
   videoTagApi: '/api/content/video/tag',
@@ -25,11 +26,17 @@ export function videoRecommend(page) {
 export function videoTag(tag, page) {
   return get(videoApi.videoTagApi + '?tag=' + tag + '&page=' + page)
 }
+
 // 相似视频接口
 export function similarVideo(videoId) {
   return get(videoApi.similarVideoApi + '?videoId=' + videoId)
 }
 
+// 视频分页接口
+export function videoPage(pageNumber, lastId) {
+  return get(videoApi.videoPageApi + '?pageNumber=' + pageNumber + '&lastId=' + lastId)
+}
+
 // 视频详情接口
 export function videoInfo(videoId) {
   return get(videoApi.videoInfoApi + '/' + videoId)

+ 31 - 7
src/views/home/Video.vue

@@ -59,7 +59,7 @@
 import VideoCard from 'components/card/VideoCard'
 import Recommend from 'components/recommend/Recommend'
 import HotList from 'components/hotlist/HotList'
-import { videoCategory, videoRecommend} from '@/api/video'
+import { videoCategory, videoPage} from '@/api/video'
 
 export default {
   name: 'Video',
@@ -72,6 +72,7 @@ export default {
       pageSize: 12,
       totalPages: 0,
       videoList: [],
+      lastId: 0,
       currentIndex: 0,
       videoCategory: [
         { cname: '全部', cid: 11010 },
@@ -92,7 +93,26 @@ export default {
     videoCategory().then(res => {
       console.log(res.data)
     })
-    this.videoRecommendWrapper(this.currentPage)
+
+    const query = this.$route.query
+    var pageNumber = query.pageNumber
+    if (pageNumber !== undefined) {
+      this.currentPage = pageNumber
+    }
+
+    var lastId = query.lastId
+    if (lastId !== undefined) {
+      this.lastId = lastId
+    }
+
+    this.$router.push({
+      path: '/video',
+      query: {
+        pageNumber: this.currentPage,
+        lastId: this.lastId
+      }
+    });
+    this.videoPageWrapper(this.currentPage, this.lastId)
   },
   mounted() {
     // 当窗口宽度改变时获取屏幕宽度
@@ -106,21 +126,25 @@ export default {
   methods: {
     handleCurrentChange(pageNumber) {
       this.currentPage = pageNumber
-      console.log('选择分页')
-
       this.$router.push({
-        path: path
+        path: '/video',
+        query: {
+          pageNumber: this.currentPage,
+          lastId: this.lastId
+        }
       });
 
+      this.videoPageWrapper(this.currentPage, this.lastId)
       // 回到顶部
       scrollTo(0, 0)
     },
-    videoRecommendWrapper(pageNumber) {
-      videoRecommend(pageNumber).then(res => {
+    videoPageWrapper(pageNumber, lastId) {
+      videoPage(pageNumber, lastId).then(res => {
         if (res.code === 0) {
           const resData = res.data
           this.videoList = resData.list
           this.totalPages = resData.totalPages
+          this.lastId = resData.lastId
         }
       })
     },

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff