|
|
@@ -0,0 +1,102 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <!--电影列表,与推荐列表-->
|
|
|
+ <el-row id="movie-list">
|
|
|
+ <!--电影列表-->
|
|
|
+ <el-col :md="24">
|
|
|
+ <el-col v-for="(video, index) in videoList" :key="index" :md="6" :sm="12" :xs="12">
|
|
|
+ <image-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-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import ImageCard from 'components/card/ImageCard'
|
|
|
+import { videoRecommend } from '@/api/video'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'Discover',
|
|
|
+ components: { ImageCard },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 屏幕宽度, 为了控制分页条的大小
|
|
|
+ screenWidth: document.body.clientWidth,
|
|
|
+ currentPage: 1,
|
|
|
+ videoList: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ document.title = '发现'
|
|
|
+ this.currentPage = 1
|
|
|
+ videoRecommend(this.currentPage).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ const resData = res.data
|
|
|
+ this.videoList = resData.list
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // console.log(this.$store.state.videos);
|
|
|
+ // 当页面挂载时,页码变为1
|
|
|
+ this.$store.commit('updatePage', 1)
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // 当窗口宽度改变时获取屏幕宽度
|
|
|
+ window.onresize = () => {
|
|
|
+ return () => {
|
|
|
+ window.screenWidth = document.body.clientWidth
|
|
|
+ this.screenWidth = window.screenWidth
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleCurrentChange(currentPage) {
|
|
|
+ this.currentPage = currentPage
|
|
|
+ this.$store.commit('updatePage', currentPage)
|
|
|
+ this.$store.dispatch('getPageBean')
|
|
|
+ // 回到顶部
|
|
|
+ scrollTo(0, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+#movie-list {
|
|
|
+ padding-top: 15px;
|
|
|
+ padding-left: 6%;
|
|
|
+ padding-right: 6%;
|
|
|
+}
|
|
|
+
|
|
|
+.pagination {
|
|
|
+ text-align: center;
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+/*处于手机屏幕时*/
|
|
|
+@media screen and (max-width: 768px){
|
|
|
+ #movie-list {
|
|
|
+ padding-top: 8px;
|
|
|
+ padding-left: 0.5%;
|
|
|
+ padding-right: 0.5%;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|