You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 line
1.7KB

  1. <template>
  2. <div class="new-container">
  3. <div class="new-text">最新视频</div>
  4. <div class="new-content">
  5. <el-row :gutter="20">
  6. <el-col v-for="item in videoData.list" :key="item.id" :span="6">
  7. <public-video :media-data="item" @handleVideoClick="handleVideoClick" />
  8. </el-col>
  9. </el-row>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import PublicVideo from '@/layout/components/PublicVideo'
  15. import { mapGetters, mapActions } from 'vuex'
  16. export default {
  17. name: 'Dashboard',
  18. components: {
  19. PublicVideo
  20. },
  21. data() {
  22. return {
  23. currentVideo: ''
  24. }
  25. },
  26. computed: {
  27. ...mapGetters([
  28. 'videoData',
  29. 'navMenuData'
  30. ])
  31. },
  32. created() {
  33. this.getVideos({ limit: 12, page: 1 })
  34. },
  35. methods: {
  36. ...mapActions({
  37. getVideos: 'videos/fetchVideoList'
  38. }),
  39. handleVideoClick(videoObj) {
  40. if (!this.currentVideo) {
  41. this.currentVideo = videoObj
  42. videoObj['video'].play()
  43. } else {
  44. if (this.currentVideo['id'] === videoObj['id']) {
  45. if (!videoObj['playState']) {
  46. videoObj['video'].play()
  47. } else {
  48. videoObj['video'].pause()
  49. }
  50. } else {
  51. this.currentVideo['video'].pause()
  52. this.currentVideo = videoObj
  53. videoObj['video'].play()
  54. }
  55. }
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .new {
  62. &-container {
  63. padding: 30px;
  64. height: 100vh;
  65. overflow-y: auto;
  66. background: #f2f4f8;
  67. }
  68. &-content {
  69. margin-bottom: 30px;
  70. }
  71. &-text {
  72. font-size: 30px;
  73. line-height: 46px;
  74. }
  75. }
  76. .el-row {
  77. background: #f2f4f8;
  78. }
  79. .el-col {
  80. border-radius: 4px;
  81. margin: 10px auto;
  82. }
  83. </style>