article-card.vue 5.8 KB

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