Article.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div>
  3. <el-row id="movie-list">
  4. <el-col :md="18">
  5. <el-card :if="!video" :body-style="{ padding: '0px' }" class="card">
  6. <div slot="header" class="clearfix">
  7. <span>文章列表</span>
  8. <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>
  9. </div>
  10. <div v-for="(video, index) in videoList" :key="index" :md="6" :sm="12" :xs="12">
  11. <article-card :video="video" />
  12. </div>
  13. </el-card>
  14. </el-col>
  15. </el-row>
  16. <el-row v-if="showEmpty" class="not-result">
  17. <el-col :span="12" :offset="6">
  18. <img src="@/assets/img/icon/not-result.png">
  19. <div>没有文章数据</div>
  20. </el-col>
  21. </el-row>
  22. </div>
  23. </template>
  24. <script>
  25. import ArticleCard from 'components/card/ArticleCard'
  26. import {videoRecommend} from "@/api/video";
  27. export default {
  28. name: 'Article',
  29. components: { ArticleCard },
  30. data() {
  31. return {
  32. // 屏幕宽度, 为了控制分页条的大小
  33. screenWidth: document.body.clientWidth,
  34. currentPage: 1,
  35. videoList: [],
  36. video: null,
  37. showEmpty: true
  38. }
  39. },
  40. created() {
  41. document.title = '文章'
  42. this.currentPage = 1
  43. videoRecommend(this.currentPage).then(res => {
  44. if (res.code === 0) {
  45. const resData = res.data
  46. this.videoList = resData.list
  47. this.video = resData.list[0]
  48. }
  49. })
  50. // console.log(this.$store.state.videos);
  51. // 当页面挂载时,页码变为1
  52. //this.$store.commit('updatePage', 1)
  53. },
  54. mounted() {
  55. // 当窗口宽度改变时获取屏幕宽度
  56. window.onresize = () => {
  57. return () => {
  58. window.screenWidth = document.body.clientWidth
  59. this.screenWidth = window.screenWidth
  60. }
  61. }
  62. },
  63. methods: {
  64. handleCurrentChange(currentPage) {
  65. this.currentPage = currentPage
  66. this.$store.commit('updatePage', currentPage)
  67. this.$store.dispatch('getPageBean')
  68. // 回到顶部
  69. scrollTo(0, 0)
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. #movie-list {
  76. padding-top: 15px;
  77. padding-left: 6%;
  78. padding-right: 6%;
  79. }
  80. .not-result {
  81. padding-top: 100px;
  82. padding-bottom: 100px;
  83. text-align: center;
  84. }
  85. .pagination {
  86. text-align: center;
  87. padding: 10px;
  88. }
  89. /*处于手机屏幕时*/
  90. @media screen and (max-width: 768px){
  91. #movie-list {
  92. padding-top: 8px;
  93. padding-left: 0.5%;
  94. padding-right: 0.5%;
  95. }
  96. }
  97. </style>