PlaylistIndex.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <el-row style="padding-right: 5px; padding-left: 5px; padding-top: 10px; padding-bottom: 5px">
  3. <el-col :md="24">
  4. <div v-if="dataList.length === 0" align="center">
  5. <img src="@/assets/img/not-result.png">
  6. <div>还没有数据呢~</div>
  7. </div>
  8. <div v-if="dataList.length !== 0">
  9. <el-col
  10. v-for="(item, index) in dataList"
  11. :key="index"
  12. :md="6"
  13. :sm="12"
  14. :xs="12"
  15. style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px"
  16. >
  17. <el-card :body-style="{ padding: '0px' }" class="card">
  18. <div class="imgs" style="cursor: pointer" :title="item.albumName">
  19. <router-link target="_blank" :to="`/playlist/${item.albumId}`">
  20. <el-image
  21. lazy
  22. fit="cover"
  23. class="coverImg"
  24. :src="item.coverUrl"
  25. />
  26. <span style="position: absolute; top: 0; left: 60%; color:white"> {{ item.duration }} </span>
  27. <span style="position: absolute; bottom: 0; left: 0; color:white">
  28. <i v-if="item.horizontal" class="el-icon-monitor" />
  29. <i v-else class="el-icon-mobile-phone" />
  30. </span>
  31. <span style="position: absolute; bottom: 0; left: 10%; color:white">
  32. <i class="el-icon-video-play">{{ getVisited(item.view) }}</i>
  33. </span>
  34. <span style="position: absolute; bottom: 0; left: 40%; color:white">
  35. <i class="el-icon-s-comment">{{ getVisited(item.comment) }}</i>
  36. </span>
  37. </router-link>
  38. </div>
  39. <div style="padding: 14px">
  40. <router-link style="text-decoration-line: none" target="_blank" :to="`/playlist/${item.albumId}`">
  41. <span style="left: 0;margin-bottom: 0px;color: black;">{{ item.albumName | ellipsis }}</span>
  42. </router-link>
  43. </div>
  44. <!-- <div style="padding: 14px">
  45. <span style="left: 0;margin-bottom: 0px;color: black;">
  46. <router-link target="_blank" :to="`/vod/user/${item.user.userId}`">
  47. <i class="el-icon-user"> {{ item.user.screenName | ellipsisUsername }} </i></router-link> • {{ item.pubDateStr }}
  48. </span>
  49. </div>-->
  50. </el-card>
  51. </el-col>
  52. <el-pagination
  53. :small="screenWidth <= 768"
  54. hide-on-single-page
  55. layout="prev, pager, next"
  56. :page-size="pageSize"
  57. :current-page="currentPage"
  58. :total="totalSize"
  59. @current-change="handleCurrentChange"
  60. @prev-click="handleCurrentChange"
  61. @next-click="handleCurrentChange"
  62. />
  63. </div>
  64. </el-col>
  65. </el-row>
  66. </template>
  67. <script>
  68. import { getPlaylist } from '@/api/collect'
  69. import { handleVisited } from '@/assets/js/utils'
  70. export default {
  71. name: 'PostAlbumIndex',
  72. filters: {
  73. ellipsis(value) {
  74. if (!value) return ''
  75. const max = 20
  76. if (value.length > max) {
  77. return value.slice(0, max) + '...'
  78. }
  79. return value
  80. },
  81. ellipsisUsername(value) {
  82. if (!value) return ''
  83. const max = 10
  84. if (value.length > max) {
  85. return value.slice(0, max) + '...'
  86. }
  87. return value
  88. }
  89. },
  90. data() {
  91. return {
  92. // 屏幕宽度, 为了控制分页条的大小
  93. screenWidth: document.body.clientWidth,
  94. currentPage: 1,
  95. pageSize: 12,
  96. totalSize: 0,
  97. dataList: [],
  98. queryInfo: {
  99. postType: null,
  100. pn: 1
  101. },
  102. showEmpty: true
  103. }
  104. },
  105. created() {
  106. document.title = '播放列表'
  107. this.getData()
  108. },
  109. mounted() {
  110. // 当窗口宽度改变时获取屏幕宽度
  111. window.onresize = () => {
  112. return () => {
  113. window.screenWidth = document.body.clientWidth
  114. this.screenWidth = window.screenWidth
  115. }
  116. }
  117. },
  118. methods: {
  119. handleCurrentChange(pageNumber) {
  120. this.currentPage = pageNumber
  121. this.getData()
  122. // 回到顶部
  123. scrollTo(0, 0)
  124. },
  125. getData() {
  126. this.dataList = []
  127. getPlaylist(this.currentPage).then(resp => {
  128. if (resp.code === 0) {
  129. this.dataList = resp.data.list
  130. this.totalSize = resp.data.totalSize
  131. } else {
  132. this.$notify({
  133. title: '提示',
  134. message: resp.msg,
  135. type: 'warning',
  136. duration: 3000
  137. })
  138. }
  139. })
  140. },
  141. getVisited(visited) {
  142. return handleVisited(visited)
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped>
  148. /*处于手机屏幕时*/
  149. @media screen and (max-width: 768px){
  150. .movie-list {
  151. padding-top: 8px;
  152. padding-left: 0.5%;
  153. padding-right: 0.5%;
  154. }
  155. .coverImg {
  156. height: 120px !important;
  157. }
  158. }
  159. .movie-list {
  160. padding-top: 15px;
  161. padding-left: 6%;
  162. padding-right: 6%;
  163. }
  164. .coverImg {
  165. width: 100%;
  166. height: 130px;
  167. display: block;
  168. }
  169. .card {
  170. margin-bottom: 20px;
  171. transition: all 0.6s; /*所有属性变化在0.6秒内执行动画*/
  172. }
  173. .imgs {
  174. position: relative;
  175. }
  176. #collection-list {
  177. padding-left: 6%;
  178. padding-right: 6%;
  179. padding-top: 30px;
  180. }
  181. .bread {
  182. font-size: 15px;
  183. }
  184. .movie-list {
  185. padding-top: 15px;
  186. }
  187. .reslut {
  188. color: red;
  189. }
  190. .not-result {
  191. padding-top: 100px;
  192. padding-bottom: 100px;
  193. text-align: center;
  194. }
  195. .remove-slot {
  196. position: absolute;
  197. right: 5px;
  198. bottom: 2px;
  199. }
  200. </style>