HistoryVideoCard.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <el-col style="padding-right: 7px; padding-left: 7px">
  3. <div style="cursor: pointer" :title="video.title">
  4. <el-card :body-style="{ padding: '0px' }" class="card">
  5. <router-link target="_blank" :to="`/vod/video/${video.videoId}`">
  6. <div class="imgs">
  7. <el-image
  8. lazy
  9. fit="cover"
  10. :src="video.coverUrl"
  11. class="coverImg"
  12. />
  13. <span style="position: absolute; bottom: 0; left: 0; color:white">
  14. <i v-if="video.horizontal" class="el-icon-monitor" />
  15. <i v-else class="el-icon-mobile-phone" />
  16. </span>
  17. <span style="position: absolute; bottom: 0; left: 10%; color:white">
  18. <i class="el-icon-video-play">{{ getVisited(video.view) }}</i>
  19. </span>
  20. <span style="position: absolute; bottom: 0; left: 30%; color:white">
  21. <i class="el-icon-s-comment">{{ getVisited(video.comment) }}</i>
  22. </span>
  23. <span style="position: absolute; bottom: 0; right: 0; color:white"> {{ video.duration }} </span>
  24. </div>
  25. </router-link>
  26. <el-progress :percentage="setItemProgress(video)" />
  27. <div style="padding: 14px">
  28. <router-link target="_blank" :to="`/vod/video/${video.videoId}`">
  29. <span style="left: 0;margin-bottom: 0px;color: black;">{{ video.title | ellipsis }}</span>
  30. </router-link>
  31. </div>
  32. <div style="padding: 14px">
  33. <span style="left: 0;margin-bottom: 0px;color: black;">
  34. <router-link target="_blank" :to="`/user/${video.user.userId}`">
  35. <i class="el-icon-user"> {{ video.user.screenName | ellipsisUsername }} </i></router-link> • {{ video.publishAt }}
  36. </span>
  37. </div>
  38. </el-card>
  39. </div>
  40. </el-col>
  41. </template>
  42. <script>
  43. import { handleVisited } from 'assets/js/utils'
  44. export default {
  45. name: 'HistoryVideoCard',
  46. filters: {
  47. ellipsis(value) {
  48. if (!value) return ''
  49. const max = 10
  50. if (value.length > max) {
  51. return value.slice(0, max) + '...'
  52. }
  53. return value
  54. },
  55. ellipsisUsername(value) {
  56. if (!value) return ''
  57. const max = 5
  58. if (value.length > max) {
  59. return value.slice(0, max) + '...'
  60. }
  61. return value
  62. }
  63. },
  64. props: {
  65. video: {
  66. type: Object,
  67. default: null
  68. },
  69. // 时间前的描述
  70. dateTit: {
  71. type: String,
  72. default: ''
  73. }
  74. },
  75. methods: {
  76. getVisited(visited) {
  77. return handleVisited(visited)
  78. },
  79. convertTimestamp(value) {
  80. const date = new Date(value * 1000)
  81. var month = date.getMonth()
  82. if (month < 10) {
  83. if (month === 0) {
  84. month = '01'
  85. } else {
  86. month = '0' + month
  87. }
  88. }
  89. var day = date.getDay()
  90. if (day < 10) {
  91. day = '0' + day
  92. }
  93. return month + '-' + day
  94. },
  95. setItemProgress(video) {
  96. const progress = Math.floor(video.currentTime / video.duration * 100)
  97. return progress
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped>
  103. .time {
  104. font-size: 15px;
  105. color: #999;
  106. }
  107. .bottom {
  108. margin-top: 13px;
  109. line-height: 12px;
  110. }
  111. .tit {
  112. font-weight: 700;
  113. font-size: 18px;
  114. height: 50px;
  115. overflow: hidden;
  116. text-overflow: ellipsis;
  117. text-overflow: ellipsisUsername;
  118. display: -webkit-box;
  119. -webkit-line-clamp: 2; /*行数*/
  120. -webkit-box-orient: vertical;
  121. }
  122. .num {
  123. position: relative;
  124. font-size: 15px;
  125. padding-top: 9px;
  126. }
  127. /*处于手机屏幕时*/
  128. @media screen and (max-width: 768px) {
  129. .tit {
  130. font-weight: 600;
  131. font-size: 12px;
  132. height: 32px;
  133. }
  134. .time {
  135. font-size: 10px;
  136. color: #999;
  137. }
  138. .num {
  139. font-size: 9px;
  140. padding-top: 3px;
  141. }
  142. .bottom {
  143. margin-top: 2px;
  144. line-height: 7px;
  145. }
  146. .coverImg {
  147. height: 120px !important;
  148. }
  149. }
  150. .coverImg {
  151. width: 100%;
  152. height: 175px;
  153. display: block;
  154. }
  155. .clearfix:before,
  156. .clearfix:after {
  157. display: table;
  158. content: "";
  159. }
  160. .clearfix:after {
  161. clear: both;
  162. }
  163. .card {
  164. margin-bottom: 20px;
  165. transition: all 0.6s; /*所有属性变化在0.6秒内执行动画*/
  166. }
  167. /*.card:hover {
  168. !*鼠标放上之后元素变成1.06倍大小*!
  169. transform: scale(1.06);
  170. }*/
  171. .imgs {
  172. position: relative;
  173. }
  174. .play-icon {
  175. position: absolute;
  176. /*top: -15px;*/
  177. right: 2%;
  178. bottom: 5px;
  179. z-index: 7;
  180. width: 40px;
  181. }
  182. </style>