PostAlbumView.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <el-row class="movie-list">
  3. <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
  4. <el-card class="box-card" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
  5. <div slot="header" class="clearfix">
  6. <span>播放列表 - <span style="color: blue">{{ albumName }}</span></span>
  7. </div>
  8. </el-card>
  9. </el-row>
  10. <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
  11. <el-col :md="24">
  12. <div v-if="dataList.length === 0" align="center">
  13. <img src="@/assets/img/icon/not-result.png">
  14. <div>还没有收藏呢~</div>
  15. </div>
  16. <div v-if="dataList.length !== 0">
  17. <el-col
  18. v-for="(item, index) in dataList"
  19. :key="index"
  20. :md="6"
  21. :sm="12"
  22. :xs="12"
  23. style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px"
  24. >
  25. <el-card :body-style="{ padding: '0px' }" class="card">
  26. <div v-if="postType === 1" class="imgs">
  27. <el-image
  28. lazy
  29. fit="cover"
  30. class="coverImg"
  31. :src="item.thumbnailUrl"
  32. @click="showImages(index)"
  33. />
  34. </div>
  35. <div v-if="postType === 2" class="imgs" style="cursor: pointer" :title="item.title">
  36. <router-link target="_blank" :to="`/video/${item.videoId}`">
  37. <el-image
  38. lazy
  39. fit="cover"
  40. class="coverImg"
  41. :src="item.coverUrl"
  42. />
  43. <span style="position: absolute; top: 0; left: 60%; color:white"> {{ item.duration }} </span>
  44. <span style="position: absolute; bottom: 0; left: 0; color:white">
  45. <i v-if="item.horizontal" class="el-icon-monitor" />
  46. <i v-else class="el-icon-mobile-phone" />
  47. </span>
  48. <span style="position: absolute; bottom: 0; left: 10%; color:white">
  49. <i class="el-icon-video-play">{{ getVisited(item.view) }}</i>
  50. </span>
  51. <span style="position: absolute; bottom: 0; left: 40%; color:white">
  52. <i class="el-icon-s-comment">{{ getVisited(item.comment) }}</i>
  53. </span>
  54. </router-link>
  55. </div>
  56. <div v-if="postType === 2" style="padding: 14px">
  57. <router-link style="text-decoration-line: none" target="_blank" :to="`/video/${item.videoId}`">
  58. <span style="left: 0;margin-bottom: 0px;color: black;">{{ item.title | ellipsis }}</span>
  59. </router-link>
  60. </div>
  61. <div v-if="postType === 2" style="padding: 14px">
  62. <span style="left: 0;margin-bottom: 0px;color: black;">
  63. <router-link target="_blank" :to="`/user/${item.user.userId}`">
  64. <i class="el-icon-user"> {{ item.user.screenName | ellipsisUsername }} </i></router-link> • {{ item.pubDateStr }}
  65. </span>
  66. </div>
  67. </el-card>
  68. </el-col>
  69. <el-pagination
  70. :small="screenWidth <= 768"
  71. hide-on-single-page
  72. layout="prev, pager, next"
  73. :page-size="pageSize"
  74. :current-page="currentPage"
  75. :total="totalSize"
  76. @current-change="handleCurrentChange"
  77. @prev-click="handleCurrentChange"
  78. @next-click="handleCurrentChange"
  79. />
  80. </div>
  81. </el-col>
  82. </el-row>
  83. </el-row>
  84. </template>
  85. <script>
  86. import {
  87. collectItem, getAlbumItems
  88. } from '@/api/collect'
  89. import { handleVisited } from '@/assets/js/utils'
  90. import { getUserInfo } from '@/api/user'
  91. export default {
  92. name: 'PostAlbumView',
  93. filters: {
  94. ellipsis(value) {
  95. if (!value) return ''
  96. const max = 20
  97. if (value.length > max) {
  98. return value.slice(0, max) + '...'
  99. }
  100. return value
  101. },
  102. ellipsisUsername(value) {
  103. if (!value) return ''
  104. const max = 10
  105. if (value.length > max) {
  106. return value.slice(0, max) + '...'
  107. }
  108. return value
  109. }
  110. },
  111. data() {
  112. return {
  113. // 屏幕宽度, 为了控制分页条的大小
  114. screenWidth: document.body.clientWidth,
  115. currentPage: 1,
  116. pageSize: 12,
  117. totalSize: 0,
  118. dataList: [],
  119. favlistId: 1,
  120. contentType: 1001,
  121. albumId: null,
  122. albumName: null,
  123. postType: null,
  124. user: null
  125. }
  126. },
  127. created() {
  128. document.title = '播放列表'
  129. this.albumId = this.$route.params.albumId
  130. this.getAlbumItemsWrapper()
  131. },
  132. methods: {
  133. handleCurrentChange(pageNumber) {
  134. this.currentPage = pageNumber
  135. this.dataList = []
  136. this.getAlbumItemsWrapper()
  137. // 回到顶部
  138. scrollTo(0, 0)
  139. },
  140. getAlbumItemsWrapper() {
  141. getAlbumItems(this.currentPage, this.albumId).then(resp => {
  142. if (resp.code === 0) {
  143. const respData = resp.data
  144. this.albumName = respData.albumName
  145. this.postType = respData.postType
  146. this.dataList = respData.pageList.list
  147. this.totalSize = respData.pageList.totalSize
  148. getUserInfo(respData.createBy).then(resp => {
  149. if (resp.code === 0) {
  150. this.user = resp.data
  151. document.title = this.user.screenName + '的播放列表'
  152. }
  153. })
  154. }
  155. })
  156. },
  157. onReturnAlbum() {
  158. this.$router.push('/post/album')
  159. },
  160. showImages(index) {
  161. const imageUrls = []
  162. for (const i of this.dataList) {
  163. imageUrls.push(i.originalUrl)
  164. }
  165. this.$viewerApi({
  166. images: imageUrls,
  167. options: {
  168. initialViewIndex: index,
  169. movable: true,
  170. fullscreen: false,
  171. keyboard: true
  172. }
  173. })
  174. },
  175. getVisited(visited) {
  176. return handleVisited(visited)
  177. },
  178. onSetCover(item) {
  179. const jsonData = {}
  180. jsonData.albumId = this.albumId
  181. if (this.postType === 1) {
  182. jsonData.postId = item.imageFileId
  183. } else if (this.postType === 2) {
  184. jsonData.postId = item.videoId
  185. }
  186. jsonData.action = 3
  187. collectItem(jsonData).then(res => {
  188. if (res.code === 0) {
  189. this.$message({
  190. type: 'success',
  191. message: '封面已更新!'
  192. })
  193. this.$router.go(0)
  194. }
  195. })
  196. },
  197. // 移除收藏
  198. onDeleteItem(item) {
  199. this.$confirm('确认删除本收藏?', '提示', {
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消',
  202. type: 'warning'
  203. }).then(() => {
  204. const jsonData = {}
  205. jsonData.albumId = this.albumId
  206. if (this.postType === 1) {
  207. jsonData.postId = item.imageFileId
  208. } else if (this.postType === 2) {
  209. jsonData.postId = item.videoId
  210. }
  211. jsonData.action = 2
  212. collectItem(jsonData).then(res => {
  213. if (res.code === 0) {
  214. this.$message({
  215. type: 'success',
  216. message: '移除成功!'
  217. })
  218. this.$router.go(0)
  219. }
  220. })
  221. }).catch(() => {
  222. this.$message({
  223. type: 'info',
  224. message: '已取消'
  225. })
  226. })
  227. }
  228. }
  229. }
  230. </script>
  231. <style scoped>
  232. /*处于手机屏幕时*/
  233. @media screen and (max-width: 768px){
  234. .movie-list {
  235. padding-top: 8px;
  236. padding-left: 0.5%;
  237. padding-right: 0.5%;
  238. }
  239. .coverImg {
  240. height: 120px !important;
  241. }
  242. }
  243. .movie-list {
  244. padding-top: 15px;
  245. padding-left: 6%;
  246. padding-right: 6%;
  247. }
  248. .coverImg {
  249. width: 100%;
  250. height: 130px;
  251. display: block;
  252. }
  253. .card {
  254. margin-bottom: 20px;
  255. transition: all 0.6s; /*所有属性变化在0.6秒内执行动画*/
  256. }
  257. .imgs {
  258. position: relative;
  259. }
  260. #collection-list {
  261. padding-left: 6%;
  262. padding-right: 6%;
  263. padding-top: 30px;
  264. }
  265. .bread {
  266. font-size: 15px;
  267. }
  268. .movie-list {
  269. padding-top: 15px;
  270. }
  271. .reslut {
  272. color: red;
  273. }
  274. .not-result {
  275. padding-top: 100px;
  276. padding-bottom: 100px;
  277. text-align: center;
  278. }
  279. .remove-slot {
  280. position: absolute;
  281. right: 5px;
  282. bottom: 2px;
  283. }
  284. </style>