Status.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :md="3">
  5. <hot-list />
  6. </el-col>
  7. <el-col :md="18">
  8. <el-row class="movie-list">
  9. <text-card />
  10. </el-row>
  11. <el-row class="movie-list">
  12. <el-tabs v-model="activeName" @tab-click='tabClick'>
  13. <el-tab-pane label="视频" name="video">
  14. <div v-if="activeName === 'video'">
  15. <el-col :md="8">
  16. <el-row v-for="(video, index) in videoList" :key="index" :md="6" :sm="12" :xs="12">
  17. <video-card :video="video" />
  18. </el-row>
  19. </el-col>
  20. </div>
  21. </el-tab-pane>
  22. <el-tab-pane label="状态" name="status">
  23. <div v-if="activeName === 'status'">
  24. <el-col :md="15">
  25. <el-row v-for="(status, index) in statusList" :key="index" :md="15" :sm="12" :xs="12">
  26. <status-card :status="status" />
  27. </el-row>
  28. </el-col>
  29. </div>
  30. </el-tab-pane>
  31. </el-tabs>
  32. </el-row>
  33. </el-col>
  34. <el-col :md="3">
  35. <hot-list />
  36. </el-col>
  37. </el-row>
  38. </div>
  39. </template>
  40. <script>
  41. import TextCard from '@/components/card/TextCard'
  42. import StatusCard from '@/components/card/StatusCard'
  43. import VideoCard from '@/components/card/VideoCard'
  44. import HotList from '@/components/hotlist/HotList'
  45. import { getUserInfo } from '@/utils/auth'
  46. import { statusTimeline, videoTimeline } from '@/api/timeline'
  47. export default {
  48. name: 'Status',
  49. components: { TextCard, StatusCard, VideoCard, HotList },
  50. data() {
  51. return {
  52. // 屏幕宽度, 为了控制分页条的大小
  53. screenWidth: document.body.clientWidth,
  54. currentPage: 1,
  55. videoInfo: null,
  56. statusList: [],
  57. videoList: [],
  58. activeName: 'video'
  59. }
  60. },
  61. created() {
  62. const userInfo = getUserInfo()
  63. if (userInfo != null) {
  64. document.title = userInfo.username + '的时间线'
  65. }
  66. this.currentPage = 1
  67. this.videoTimelineWrapper(this.currentPage)
  68. /*statusTimeline(0, this.currentPage).then(res => {
  69. if (res.code === 0) {
  70. const resData = res.data
  71. this.statusList = resData.list
  72. }
  73. })*/
  74. },
  75. mounted() {
  76. // 当窗口宽度改变时获取屏幕宽度
  77. window.onresize = () => {
  78. return () => {
  79. window.screenWidth = document.body.clientWidth
  80. this.screenWidth = window.screenWidth
  81. }
  82. }
  83. },
  84. methods: {
  85. handleCurrentChange(currentPage) {
  86. this.currentPage = currentPage
  87. this.$store.commit('updatePage', currentPage)
  88. this.$store.dispatch('getPageBean')
  89. // 回到顶部
  90. scrollTo(0, 0)
  91. },
  92. statusTimelineWrapper(pageNumber) {
  93. statusTimeline(0, this.currentPage).then(res => {
  94. if (res.code === 0) {
  95. const resData = res.data
  96. this.statusList = resData.list
  97. }
  98. })
  99. },
  100. videoTimelineWrapper(pageNumber) {
  101. videoTimeline(0, this.currentPage).then(res => {
  102. if (res.code === 0) {
  103. const resData = res.data
  104. this.videoList = resData.list
  105. }
  106. })
  107. },
  108. tabClick(tab) {
  109. const tabName = tab.name
  110. if (tabName === 'video') {
  111. this.videoTimelineWrapper(this.currentPage)
  112. } else if (tabName === 'status') {
  113. this.statusTimelineWrapper(this.currentPage)
  114. }
  115. }
  116. }
  117. }
  118. </script>
  119. <style scoped>
  120. .movie-list {
  121. padding-top: 15px;
  122. padding-left: 3%;
  123. padding-right: 3%;
  124. }
  125. /*处于手机屏幕时*/
  126. @media screen and (max-width: 768px){
  127. .movie-list {
  128. padding-top: 8px;
  129. padding-left: 0.5%;
  130. padding-right: 0.5%;
  131. }
  132. }
  133. </style>