article-card.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="article-card " :class="cardType" @click="fnClickEvent('card')">
  3. <view class="left">
  4. <cache-image class="thumbnail" radius="6rpx" :url="$utils.checkThumbnailUrl(article.spec.cover)" :fileMd5="$utils.checkThumbnailUrl(article.spec.cover)" mode="aspectFill"></cache-image>
  5. <!-- <image class="thumbnail" lazy-load :src="$utils.checkThumbnailUrl(article.thumbnail)" mode="aspectFill"></image> -->
  6. </view>
  7. <view class="right">
  8. <view class="title">
  9. <text class="is-top bg-gradient-blue-accent" v-if="article.spec.pinned">置顶</text>
  10. <text class="title-text text-overflow">{{ article.spec.title }}</text>
  11. </view>
  12. <view class="content text-overflow-2">{{ article.status.excerpt }}</view>
  13. <view class="foot">
  14. <view class="create-time">
  15. <text class="time-label">发布时间:</text>
  16. {{ { d: article.spec.publishTime, f: 'yyyy-MM-dd' } | formatTime }}
  17. </view>
  18. <view class="visits">
  19. <!-- <tm-icons :size="24" name="icon-filter-fill"></tm-icons> -->
  20. 浏览
  21. <text class="number">{{ article.stats.visit }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
  29. export default {
  30. name: 'article-card',
  31. components: { tmTags },
  32. props: {
  33. from: {
  34. type: String,
  35. default: ''
  36. },
  37. article: {
  38. type: Object,
  39. default: () => {}
  40. }
  41. },
  42. computed: {
  43. cardType() {
  44. // tb_image_text=上图下文
  45. // tb_text_image=上文下图
  46. if (this.from == 'home' && this.globalAppSettings.layout.home == 'h_row_col2') {
  47. if (!['tb_image_text', 'tb_text_image', 'only_text'].some(x => x == this.globalAppSettings.layout.cardType)) {
  48. return [this.from, this.globalAppSettings.layout.home, 'tb_image_text'];
  49. }
  50. return [this.from, this.globalAppSettings.layout.home, this.globalAppSettings.layout.cardType];
  51. }
  52. return [this.globalAppSettings.layout.home, this.globalAppSettings.layout.cardType];
  53. }
  54. },
  55. methods: {
  56. fnClickEvent() {
  57. this.$emit('on-click', this.article);
  58. }
  59. }
  60. };
  61. </script>
  62. <style scoped lang="scss">
  63. .article-card {
  64. display: flex;
  65. box-sizing: border-box;
  66. margin: 0 24rpx;
  67. padding: 24rpx;
  68. border-radius: 12rpx;
  69. background-color: #ffff;
  70. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
  71. overflow: hidden;
  72. margin-bottom: 24rpx;
  73. &.h_row_col1 {
  74. display: flex;
  75. align-items: center;
  76. }
  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. &.lr_text_image {
  144. .left {
  145. order: 2;
  146. padding-left: 30rpx;
  147. }
  148. .right {
  149. order: 1;
  150. padding-left: 0;
  151. }
  152. }
  153. &.tb_image_text {
  154. flex-direction: column;
  155. padding: 24rpx;
  156. .left {
  157. width: 100%;
  158. height: 340rpx;
  159. .thumbnail {
  160. ::v-deep uni-image {
  161. border-radius: 6rpx 6rpx 0 0 !important;
  162. }
  163. }
  164. }
  165. .right {
  166. padding-left: 0;
  167. padding: 24rpx 0;
  168. padding-bottom: 0;
  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: 340rpx;
  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. align-items: center;
  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: 6rpx 12rpx;
  264. box-shadow: none !important;
  265. }
  266. &-text {
  267. color: #303133;
  268. }
  269. }
  270. .content {
  271. display: -webkit-box;
  272. font-size: 26rpx;
  273. color: #909399;
  274. height: 80rpx;
  275. margin-top: 14rpx;
  276. line-height: 42rpx;
  277. }
  278. .foot {
  279. display: flex;
  280. font-size: 24rpx;
  281. justify-content: space-between;
  282. align-items: center;
  283. color: #909399;
  284. margin-top: 18rpx;
  285. .create-time {
  286. font-size: 26rpx;
  287. .time-label {
  288. display: none;
  289. }
  290. }
  291. .visits {
  292. .number {
  293. padding: 0 6rpx;
  294. font-size: 26rpx;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. </style>