VideoCard.vue 4.6 KB

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