article-card.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="article-card " :class="cardType" @click="fnClickEvent('card')">
  3. <view class="left">
  4. <cache-image
  5. class="thumbnail"
  6. radius="12rpx"
  7. :url="$utils.checkThumbnailUrl(article.thumbnail)"
  8. :fileMd5="$utils.checkThumbnailUrl(article.thumbnail)"
  9. mode="aspectFill"
  10. ></cache-image>
  11. <!-- <image class="thumbnail" lazy-load :src="$utils.checkThumbnailUrl(article.thumbnail)" mode="aspectFill"></image> -->
  12. </view>
  13. <view class="right">
  14. <view class="title">
  15. <text class="is-top" v-if="article.topped">置顶</text>
  16. <text class="title-text text-overflow">{{ article.title }}</text>
  17. </view>
  18. <view class="content text-overflow-2">{{ article.summary }}</view>
  19. <view class="foot">
  20. <view class="create-time">
  21. <text class="time-label">发布时间:</text>
  22. {{ { d: article.createTime, f: 'yyyy-MM-dd' } | formatTime }}
  23. </view>
  24. <view class="visits">
  25. <!-- <tm-icons :size="24" name="icon-filter-fill"></tm-icons> -->
  26. 浏览
  27. <text class="number">{{ article.visits }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'article-card',
  36. props: {
  37. from: {
  38. type: String,
  39. default: ''
  40. },
  41. article: {
  42. type: Object,
  43. default: () => {}
  44. }
  45. },
  46. computed: {
  47. cardType() {
  48. // tb_image_text=上图下文
  49. // tb_text_image=上文下图
  50. if (this.from == 'home' && this.globalAppSettings.layout.home == 'h_row_col2') {
  51. if (!['tb_image_text', 'tb_text_image', 'only_text'].some(x => x == this.globalAppSettings.layout.cardType)) {
  52. return [this.from, this.globalAppSettings.layout.home, 'tb_image_text'];
  53. }
  54. return [this.from, this.globalAppSettings.layout.home, this.globalAppSettings.layout.cardType];
  55. }
  56. return [this.globalAppSettings.layout.home, this.globalAppSettings.layout.cardType];
  57. }
  58. },
  59. methods: {
  60. fnClickEvent() {
  61. this.$emit('on-click', this.article);
  62. }
  63. }
  64. };
  65. </script>
  66. <style scoped lang="scss">
  67. .article-card {
  68. display: flex;
  69. box-sizing: border-box;
  70. margin: 0 24rpx;
  71. padding: 32rpx;
  72. border-radius: 12rpx;
  73. background-color: #ffff;
  74. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
  75. overflow: hidden;
  76. margin-bottom: 24rpx;
  77. &.home {
  78. &.h_row_col2 {
  79. margin: 12rpx;
  80. .left {
  81. width: 100%;
  82. height: 200rpx;
  83. .thumbnail {
  84. ::v-deep uni-image {
  85. border-radius: 6rpx 6rpx 0 0 !important;
  86. }
  87. }
  88. }
  89. .right {
  90. .title {
  91. display: flex;
  92. align-items: center;
  93. font-size: 26rpx;
  94. font-weight: bold;
  95. .is-top {
  96. height: 36rpx;
  97. margin-right: 10rpx;
  98. line-height: 36rpx;
  99. vertical-align: 4rpx;
  100. transform: scale(0.9);
  101. }
  102. }
  103. .foot {
  104. justify-content: space-between;
  105. .create-time {
  106. font-size: 24rpx;
  107. .time-label {
  108. display: none;
  109. }
  110. }
  111. .visits {
  112. font-size: 24rpx;
  113. margin-left: 0;
  114. }
  115. }
  116. }
  117. &.tb_text_image {
  118. padding: 12rpx;
  119. .left .thumbnail {
  120. ::v-deep {
  121. uni-image {
  122. border-radius: 6rpx !important;
  123. }
  124. }
  125. }
  126. }
  127. &.only_text {
  128. padding: 24rpx;
  129. .right .foot {
  130. .create-time {
  131. .time-label {
  132. display: none;
  133. }
  134. }
  135. .visits {
  136. font-size: 24rpx;
  137. }
  138. }
  139. }
  140. }
  141. }
  142. &.lr_image_text {
  143. }
  144. &.lr_text_image {
  145. .left {
  146. order: 2;
  147. padding-left: 30rpx;
  148. }
  149. .right {
  150. order: 1;
  151. padding-left: 0;
  152. }
  153. }
  154. &.tb_image_text {
  155. flex-direction: column;
  156. padding: 0;
  157. .left {
  158. width: 100%;
  159. height: 300rpx;
  160. .thumbnail {
  161. ::v-deep uni-image {
  162. border-radius: 6rpx 6rpx 0 0 !important;
  163. }
  164. }
  165. }
  166. .right {
  167. padding-left: 0;
  168. padding: 24rpx;
  169. width: 100%;
  170. .foot {
  171. justify-content: flex-start;
  172. .create-time {
  173. .time-label {
  174. display: inline-block;
  175. }
  176. }
  177. .visits {
  178. margin-left: 24rpx;
  179. }
  180. }
  181. }
  182. }
  183. &.tb_text_image {
  184. flex-direction: column;
  185. .left {
  186. width: 100%;
  187. height: 260rpx;
  188. order: 2;
  189. margin-top: 24rpx;
  190. }
  191. .right {
  192. padding-left: 0;
  193. width: 100%;
  194. order: 1;
  195. .foot {
  196. justify-content: flex-start;
  197. .create-time {
  198. .time-label {
  199. display: inline-block;
  200. }
  201. }
  202. .visits {
  203. margin-left: 24rpx;
  204. }
  205. }
  206. }
  207. }
  208. &.only_text {
  209. padding: 36rpx;
  210. .left {
  211. display: none;
  212. }
  213. .right {
  214. padding-left: 0;
  215. .content {
  216. margin-top: 24rpx;
  217. }
  218. .foot {
  219. justify-content: flex-start;
  220. margin-top: 24rpx;
  221. .create-time {
  222. .time-label {
  223. display: inline-block;
  224. }
  225. }
  226. .visits {
  227. margin-left: 24rpx;
  228. }
  229. }
  230. }
  231. }
  232. .left {
  233. width: 240rpx;
  234. height: 180rpx;
  235. .thumbnail {
  236. width: 100%;
  237. height: 100%;
  238. border-radius: 12rpx;
  239. }
  240. }
  241. .right {
  242. width: 0;
  243. flex-grow: 1;
  244. display: flex;
  245. flex-direction: column;
  246. padding-left: 30rpx;
  247. box-sizing: border-box;
  248. .title {
  249. display: flex;
  250. font-size: 30rpx;
  251. color: var(--main-text-color);
  252. .is-top {
  253. height: 40rpx;
  254. padding: 0 12rpx;
  255. margin-right: 10rpx;
  256. line-height: 40rpx;
  257. font-size: 24rpx;
  258. white-space: nowrap;
  259. vertical-align: 4rpx;
  260. color: #fff;
  261. background-image: -webkit-linear-gradient(0deg, #3ca5f6 0, #a86af9 100%);
  262. border-radius: 4rpx 12rpx;
  263. }
  264. &-text {
  265. color: #303133;
  266. }
  267. }
  268. .content {
  269. display: -webkit-box;
  270. font-size: 26rpx;
  271. color: #909399;
  272. height: 80rpx;
  273. margin-top: 14rpx;
  274. line-height: 42rpx;
  275. }
  276. .foot {
  277. display: flex;
  278. font-size: 24rpx;
  279. justify-content: space-between;
  280. align-items: center;
  281. color: #909399;
  282. margin-top: 18rpx;
  283. .create-time {
  284. font-size: 26rpx;
  285. .time-label {
  286. display: none;
  287. }
  288. }
  289. .visits {
  290. .number {
  291. padding: 0 6rpx;
  292. font-size: 26rpx;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. </style>