article-card.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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: 24rpx;
  157. .left {
  158. width: 100%;
  159. height: 340rpx;
  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 0;
  169. padding-bottom: 0;
  170. width: 100%;
  171. .foot {
  172. justify-content: flex-start;
  173. .create-time {
  174. .time-label {
  175. display: inline-block;
  176. }
  177. }
  178. .visits {
  179. margin-left: 24rpx;
  180. }
  181. }
  182. }
  183. }
  184. &.tb_text_image {
  185. flex-direction: column;
  186. .left {
  187. width: 100%;
  188. height: 340rpx;
  189. order: 2;
  190. margin-top: 24rpx;
  191. }
  192. .right {
  193. padding-left: 0;
  194. width: 100%;
  195. order: 1;
  196. .foot {
  197. justify-content: flex-start;
  198. .create-time {
  199. .time-label {
  200. display: inline-block;
  201. }
  202. }
  203. .visits {
  204. margin-left: 24rpx;
  205. }
  206. }
  207. }
  208. }
  209. &.only_text {
  210. padding: 36rpx;
  211. .left {
  212. display: none;
  213. }
  214. .right {
  215. padding-left: 0;
  216. .content {
  217. margin-top: 24rpx;
  218. }
  219. .foot {
  220. justify-content: flex-start;
  221. margin-top: 24rpx;
  222. .create-time {
  223. .time-label {
  224. display: inline-block;
  225. }
  226. }
  227. .visits {
  228. margin-left: 24rpx;
  229. }
  230. }
  231. }
  232. }
  233. .left {
  234. width: 240rpx;
  235. height: 180rpx;
  236. .thumbnail {
  237. width: 100%;
  238. height: 100%;
  239. border-radius: 12rpx;
  240. }
  241. }
  242. .right {
  243. width: 0;
  244. flex-grow: 1;
  245. display: flex;
  246. flex-direction: column;
  247. padding-left: 30rpx;
  248. box-sizing: border-box;
  249. .title {
  250. display: flex;
  251. font-size: 30rpx;
  252. color: var(--main-text-color);
  253. .is-top {
  254. height: 40rpx;
  255. padding: 0 12rpx;
  256. margin-right: 10rpx;
  257. line-height: 40rpx;
  258. font-size: 24rpx;
  259. white-space: nowrap;
  260. vertical-align: 4rpx;
  261. color: #fff;
  262. background-image: -webkit-linear-gradient(0deg, #3ca5f6 0, #a86af9 100%);
  263. border-radius: 4rpx 12rpx;
  264. }
  265. &-text {
  266. color: #303133;
  267. }
  268. }
  269. .content {
  270. display: -webkit-box;
  271. font-size: 26rpx;
  272. color: #909399;
  273. height: 80rpx;
  274. margin-top: 14rpx;
  275. line-height: 42rpx;
  276. }
  277. .foot {
  278. display: flex;
  279. font-size: 24rpx;
  280. justify-content: space-between;
  281. align-items: center;
  282. color: #909399;
  283. margin-top: 18rpx;
  284. .create-time {
  285. font-size: 26rpx;
  286. .time-label {
  287. display: none;
  288. }
  289. }
  290. .visits {
  291. .number {
  292. padding: 0 6rpx;
  293. font-size: 26rpx;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. </style>