Status.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :md="18">
  5. <text-card />
  6. </el-col>
  7. <el-col :md="6">
  8. <hot-list />
  9. </el-col>
  10. </el-row>
  11. <el-row id="movie-list">
  12. <el-col :md="18">
  13. <el-row v-for="(video, index) in videoList" :key="index" :md="16" :sm="12" :xs="12">
  14. <status-card :video="video" />
  15. </el-row>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. </template>
  20. <script>
  21. import TextCard from '@/components/card/TextCard'
  22. import StatusCard from '@/components/card/StatusCard'
  23. import HotList from '@/components/hotlist/HotList'
  24. import { statusRecommend } from '@/api/status'
  25. export default {
  26. name: 'Status',
  27. components: { TextCard, StatusCard, HotList },
  28. data() {
  29. return {
  30. // 屏幕宽度, 为了控制分页条的大小
  31. screenWidth: document.body.clientWidth,
  32. currentPage: 1,
  33. videoInfo: null,
  34. videoList: []
  35. }
  36. },
  37. created() {
  38. this.currentPage = 1
  39. statusRecommend(this.currentPage).then(res => {
  40. if (res.code === 0) {
  41. const resData = res.data
  42. this.videoList = resData.list
  43. }
  44. })
  45. },
  46. mounted() {
  47. // 当窗口宽度改变时获取屏幕宽度
  48. window.onresize = () => {
  49. return () => {
  50. window.screenWidth = document.body.clientWidth
  51. this.screenWidth = window.screenWidth
  52. }
  53. }
  54. },
  55. methods: {
  56. handleCurrentChange(currentPage) {
  57. this.currentPage = currentPage
  58. this.$store.commit('updatePage', currentPage)
  59. this.$store.dispatch('getPageBean')
  60. // 回到顶部
  61. scrollTo(0, 0)
  62. }
  63. }
  64. }
  65. </script>
  66. <style scoped>
  67. #movie-list {
  68. padding-top: 15px;
  69. padding-left: 3%;
  70. padding-right: 3%;
  71. }
  72. /*处于手机屏幕时*/
  73. @media screen and (max-width: 768px){
  74. #movie-list {
  75. padding-top: 8px;
  76. padding-left: 0.5%;
  77. padding-right: 0.5%;
  78. }
  79. }
  80. </style>