SelectedRecommend.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="keep-group">
  3. <div class="flex-r-c">
  4. <div class="title-group flex-r-c center left">
  5. <h5>{{ title }}</h5>
  6. </div>
  7. </div>
  8. <div class="hot-keep-group flex-r-c wrap">
  9. <div class="card-item flex-r-c" v-for="item in options" :key="item.id" @click="goContent(item)">
  10. <div class="mini-img-group">
  11. <img :src="item.img" alt="" @error="handleError">
  12. <i :class="'el-icon-jy-' + item.type" />
  13. </div>
  14. <div class="flex-c-c">
  15. <div class="flex">
  16. <div class="title-text van-multi-ellipsis--l2">{{ item.title }}</div>
  17. </div>
  18. <div class="money-group center left">
  19. {{ item.docTags }}
  20. </div>
  21. <div class="flex-c-c info-text">
  22. <span v-if="item.contribution">贡献者: {{ item.contribution }}</span>
  23. <div class="info-text-group flex-r-c center left">
  24. <span v-if="item.viewTimes">{{ SetViewUnit(item.viewTimes) }}浏览</span>
  25. <span v-if="item.page">共{{ item.page }}页</span>
  26. <span v-if="item.size">{{ item.size | sizeFormatter }}</span>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. export default {
  36. name: 'SelectedRecommend',
  37. props: {
  38. title: {
  39. type: String,
  40. default: '精选推荐'
  41. },
  42. options: {
  43. type: Array,
  44. default: () => []
  45. }
  46. },
  47. data() {
  48. return {}
  49. },
  50. methods: {
  51. handleError(img) {
  52. img.target.src = require('../assets/images/error.png')
  53. },
  54. SetViewUnit(num) {
  55. let newNum = 0
  56. if (!num) return 0
  57. if (num > 10000) {
  58. newNum = (num / 10000).toFixed(1) + 'w'
  59. } else {
  60. newNum = num
  61. }
  62. return newNum
  63. },
  64. goContent(item) {
  65. this.$emit('click', item)
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .keep-group {
  72. margin-top: 38px;
  73. padding-bottom: 50px;
  74. @include diy-icon('iconJianYu', 24, 24);
  75. @include diy-icon('pdf', 24);
  76. @include diy-icon('word', 24);
  77. @include diy-icon('excel', 24);
  78. @include diy-icon('ppt', 24);
  79. .title-group {
  80. margin-bottom: 16px;
  81. h5 {
  82. color: #1D1D1D;
  83. font-family: Microsoft YaHei;
  84. font-size: 18px;
  85. font-weight: 400;
  86. line-height: 28px;
  87. letter-spacing: 0px;
  88. text-align: left;
  89. margin-right: 9px;
  90. }
  91. }
  92. .card-item {
  93. cursor: pointer;
  94. justify-content: flex-start;
  95. padding: 8px 0 12px;
  96. box-sizing: border-box;
  97. &:hover {
  98. .title-text {
  99. color: #2ABED1;
  100. }
  101. }
  102. .money-group {
  103. display: block;
  104. margin-top: 18px;
  105. width: 180px;
  106. overflow: hidden;
  107. white-space: nowrap;
  108. text-overflow: ellipsis;
  109. font-size: 13px;
  110. line-height: 22px;
  111. color: #999999;
  112. }
  113. .mini-img-group {
  114. flex-shrink: 0;
  115. position: relative;
  116. border-radius: 4px;
  117. border: 1px solid #ececec;
  118. width: 80px;
  119. height: 112px;
  120. margin-right: 16px;
  121. overflow: hidden;
  122. display: flex;
  123. flex-direction: row;
  124. align-items: center;
  125. justify-content: center;
  126. img {
  127. width: 100%;
  128. }
  129. i {
  130. position: absolute;
  131. right: 0;
  132. bottom: 0;
  133. }
  134. }
  135. .info-text-group {
  136. span {
  137. display: inline-block;
  138. &:last-child {
  139. &::after {
  140. content: unset;
  141. }
  142. }
  143. &::after {
  144. content: "|";
  145. padding: 0 4px;
  146. color: #ececec;
  147. }
  148. }
  149. }
  150. .info-text {
  151. font-family: Microsoft YaHei;
  152. font-style: normal;
  153. font-weight: normal;
  154. font-size: 13px;
  155. line-height: 24px;
  156. color: #999999;
  157. }
  158. .red-text {
  159. color: #FF3A20;
  160. font-family: Microsoft YaHei;
  161. font-style: normal;
  162. font-weight: normal;
  163. font-size: 18px;
  164. line-height: 28px;
  165. }
  166. .title-text {
  167. width: 183px;
  168. font-family: Microsoft YaHei;
  169. font-style: normal;
  170. font-weight: normal;
  171. font-size: 16px;
  172. line-height: 24px;
  173. color: #1D1D1D;
  174. word-wrap: break-word;
  175. }
  176. }
  177. .van-ellipsis {
  178. overflow: hidden;
  179. white-space: nowrap;
  180. text-overflow: ellipsis;
  181. }
  182. .van-multi-ellipsis--l2 {
  183. display: -webkit-box;
  184. overflow: hidden;
  185. text-overflow: ellipsis;
  186. -webkit-line-clamp: 2;
  187. -webkit-box-orient: vertical;
  188. }
  189. .hot-keep-group {
  190. .card-item {
  191. width: 279px;
  192. overflow: hidden;
  193. }
  194. }
  195. }
  196. .in-app {
  197. // 工作台内适配
  198. .hot-keep-group {
  199. justify-content: flex-start !important;
  200. @media screen and (max-width: 1248px) {
  201. .card-item {
  202. margin-right: 41px;
  203. }
  204. }
  205. @media screen and (min-width: 1248px) {
  206. .card-item {
  207. margin-right: 104px;
  208. }
  209. }
  210. }
  211. }
  212. </style>