|
|
@@ -1,42 +1,22 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-row>
|
|
|
+<!-- <el-row>
|
|
|
<el-col :md="12">
|
|
|
- <!--影片分类按钮-->
|
|
|
<category-btn />
|
|
|
</el-col>
|
|
|
<el-col :md="12">
|
|
|
- <!--猜您喜欢-->
|
|
|
<recommend />
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
+ </el-row>-->
|
|
|
<!--电影列表,与推荐列表-->
|
|
|
- <el-row id="movie-list">
|
|
|
+ <el-row id="movie-list"
|
|
|
+ v-infinite-scroll="load">
|
|
|
<!--电影列表-->
|
|
|
<el-col :md="24">
|
|
|
<el-col v-for="(video, index) in videoList" :key="index" :md="6" :sm="12" :xs="12">
|
|
|
<video-card :video="video" />
|
|
|
</el-col>
|
|
|
- <!--
|
|
|
- 分页按钮:
|
|
|
- page-size:每页显示条数
|
|
|
- total:总条数
|
|
|
- hide-on-single-page: 页数为一时隐藏
|
|
|
- -->
|
|
|
- <el-col :span="24" class="pagination">
|
|
|
- <el-pagination
|
|
|
- background
|
|
|
- :small="screenWidth <= 768"
|
|
|
- hide-on-single-page
|
|
|
- layout="prev, pager, next"
|
|
|
- :current-page="$store.state.activePage"
|
|
|
- :page-size="6"
|
|
|
- :total="$store.state.pageBean.totalCount"
|
|
|
- @current-change="handleCurrentChange"
|
|
|
- />
|
|
|
- </el-col>
|
|
|
</el-col>
|
|
|
-
|
|
|
<!--热播列表-->
|
|
|
<!-- <el-col :md="6">
|
|
|
<hot-list />
|
|
|
@@ -59,20 +39,15 @@ export default {
|
|
|
// 屏幕宽度, 为了控制分页条的大小
|
|
|
screenWidth: document.body.clientWidth,
|
|
|
currentPage: 1,
|
|
|
- videoList: []
|
|
|
+ videoList: [],
|
|
|
+ loading: true
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.currentPage = 1
|
|
|
- videoRecommend(this.currentPage).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data
|
|
|
- this.videoList = resData.list
|
|
|
- }
|
|
|
- })
|
|
|
+ this.videoRecommendWrapper(this.currentPage)
|
|
|
// console.log(this.$store.state.videos);
|
|
|
// 当页面挂载时,页码变为1
|
|
|
- this.$store.commit('updatePage', 1)
|
|
|
+ // this.$store.commit('updatePage', 1)
|
|
|
},
|
|
|
mounted() {
|
|
|
// 当窗口宽度改变时获取屏幕宽度
|
|
|
@@ -84,12 +59,40 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- handleCurrentChange(currentPage) {
|
|
|
- this.currentPage = currentPage
|
|
|
- this.$store.commit('updatePage', currentPage)
|
|
|
- this.$store.dispatch('getPageBean')
|
|
|
- // 回到顶部
|
|
|
- scrollTo(0, 0)
|
|
|
+ videoRecommendWrapper(pageNumber) {
|
|
|
+ videoRecommend(pageNumber).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ const resList = res.data.list
|
|
|
+ if (resList.length === 0) {
|
|
|
+ this.loading = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const item of res.data.list) {
|
|
|
+ this.videoList.push(item)
|
|
|
+ }
|
|
|
+ this.currentPage +=1
|
|
|
+ } else {
|
|
|
+ this.$notify(
|
|
|
+ {
|
|
|
+ title: '提示',
|
|
|
+ message: '获取数据失败, 请重新刷新页面',
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ load() {
|
|
|
+ if (!this.loading || this.currentPage > 20) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('滚动加载第 ' + this.currentPage + ' 页')
|
|
|
+ setTimeout(() => {
|
|
|
+ this.videoRecommendWrapper(this.currentPage)
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
}
|
|
|
}
|