VideoTag.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div>
  3. <!--电影列表,与推荐列表-->
  4. <el-row id="movie-list">
  5. <el-breadcrumb
  6. class="bread"
  7. separator-class="el-icon-arrow-right"
  8. >
  9. <el-breadcrumb-item>
  10. 系统中有<span class="result"> {{ totalSize }} </span> 个视频包含 <span class="result">{{ tag }}</span> 标签
  11. </el-breadcrumb-item>
  12. </el-breadcrumb>
  13. <!--电影列表-->
  14. <el-col v-loading="loading">
  15. <el-col v-for="(video, index) in dataList" :key="index" :md="6" :sm="12" :xs="12">
  16. <video-card :video="video" />
  17. </el-col>
  18. <!-- <el-col v-if="totalSize === 0" class="not-result" :md="6" :sm="12" :xs="12">
  19. <img src="@/assets/img/not-result.png">
  20. <div>没有视频数据</div>
  21. </el-col>-->
  22. <!--
  23. 分页按钮:
  24. page-size:每页显示条数
  25. total:总条数
  26. hide-on-single-page: 页数为一时隐藏
  27. -->
  28. <el-col :span="24" class="pagination">
  29. <el-pagination
  30. :small="screenWidth <= 768"
  31. layout="prev, pager, next"
  32. :page-size="pageSize"
  33. :current-page="currentPage"
  34. :total="totalSize"
  35. @current-change="handleCurrentChange"
  36. />
  37. </el-col>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </template>
  42. <script>
  43. import VideoCard from 'components/card/VideoCard'
  44. import { getTagVideos } from '@/api/video'
  45. export default {
  46. name: 'VideoTag',
  47. components: { VideoCard },
  48. data() {
  49. return {
  50. // 屏幕宽度, 为了控制分页条的大小
  51. screenWidth: document.body.clientWidth,
  52. currentPage: 1,
  53. pageSize: 12,
  54. totalSize: 0,
  55. dataList: [],
  56. tag: null,
  57. categoryId: 1,
  58. treeNode: [],
  59. defaultProps: {
  60. children: 'children',
  61. label: 'label',
  62. value: 'value'
  63. },
  64. loading: false
  65. }
  66. },
  67. created() {
  68. this.tag = this.$route.params.tag
  69. document.title = '包含 ' + this.tag + ' 标签的视频'
  70. this.getTagVideosWrapper(this.tag, this.currentPage)
  71. },
  72. mounted() {
  73. // 当窗口宽度改变时获取屏幕宽度
  74. window.onresize = () => {
  75. return () => {
  76. window.screenWidth = document.body.clientWidth
  77. this.screenWidth = window.screenWidth
  78. }
  79. }
  80. },
  81. methods: {
  82. handleNodeClick(data) {
  83. this.currentPage = 1
  84. this.dataList = []
  85. this.categoryId = data.value
  86. this.getTagVideosWrapper(this.tag, this.currentPage)
  87. },
  88. handleCurrentChange(currentPage) {
  89. this.currentPage = currentPage
  90. this.getTagVideosWrapper(this.tag, this.currentPage)
  91. // 回到顶部
  92. scrollTo(0, 0)
  93. },
  94. getTagVideosWrapper(tag, currentPage) {
  95. /* const loading = this.$loading({
  96. lock: true,
  97. text: 'Loading',
  98. spinner: 'el-icon-loading',
  99. background: 'rgba(0, 0, 0, 0.7)'
  100. })*/
  101. this.loading = true
  102. getTagVideos(tag, currentPage).then(resp => {
  103. // loading.close()
  104. this.loading = false
  105. if (resp.code === 0) {
  106. const respData = resp.data
  107. this.dataList = respData.list
  108. this.totalSize = respData.totalSize
  109. } else {
  110. this.$notify({
  111. title: '提示',
  112. message: resp.msg,
  113. type: 'error',
  114. duration: 3000
  115. })
  116. }
  117. }).catch(error => {
  118. // loading.close()
  119. this.loading = false
  120. this.$notify({
  121. title: '提示',
  122. message: error.message,
  123. type: 'warning',
  124. duration: 3000
  125. })
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped>
  132. /*处于手机屏幕时*/
  133. @media screen and (max-width: 768px){
  134. #movie-list {
  135. padding-top: 8px;
  136. padding-left: 0.5%;
  137. padding-right: 0.5%;
  138. }
  139. .category-btn {
  140. padding-left: 0.5%;
  141. padding-right: 0.5%;
  142. padding-top: 3%;
  143. text-align: center;
  144. }
  145. }
  146. #movie-list {
  147. padding-top: 15px;
  148. padding-left: 6%;
  149. padding-right: 6%;
  150. }
  151. .result {
  152. color: red;
  153. }
  154. .pagination {
  155. text-align: center;
  156. padding: 10px;
  157. }
  158. </style>