1
0

article-card.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="article.spec.cover" mode="aspectFill"></cache-image>
  5. <!-- <image class="thumbnail" lazy-load :src="$utils.checkThumbnailUrl(article.spec.cover)" 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. 浏览
  20. <text class="number">{{ article.stats.visit }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
  28. export default {
  29. name: 'article-card',
  30. components: { tmTags },
  31. props: {
  32. from: {
  33. type: String,
  34. default: ''
  35. },
  36. article: {
  37. type: Object,
  38. default: () => {}
  39. }
  40. },
  41. computed: {
  42. cardType() {
  43. // tb_image_text=上图下文
  44. // tb_text_image=上文下图
  45. if (this.from == 'home' && this.globalAppSettings.layout.home == 'h_row_col2') {
  46. if (!['tb_image_text', 'tb_text_image', 'only_text'].some(x => x == this.globalAppSettings.layout.cardType)) {
  47. return [this.from, this.globalAppSettings.layout.home, 'tb_image_text'];
  48. }
  49. return [this.from, this.globalAppSettings.layout.home, this.globalAppSettings.layout.cardType];
  50. }
  51. return [this.globalAppSettings.layout.home, this.globalAppSettings.layout.cardType];
  52. }
  53. },
  54. methods: {
  55. fnClickEvent() {
  56. this.$emit('on-click', this.article);
  57. }
  58. }
  59. };
  60. </script>
  61. <style scoped lang="scss">
  62. .article-card {
  63. display: flex;
  64. box-sizing: border-box;
  65. margin: 0 24rpx;
  66. padding: 24rpx;
  67. border-radius: 12rpx;
  68. background-color: #ffff;
  69. box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
  70. overflow: hidden;
  71. margin-bottom: 24rpx;
  72. &.h_row_col1 {
  73. display: flex;
  74. align-items: center;
  75. }
  76. &.home {
  77. &.h_row_col2 {
  78. margin: 12rpx;
  79. .left {
  80. width: 100%;
  81. height: 200rpx;
  82. .thumbnail {
  83. ::v-deep uni-image {
  84. border-radius: 6rpx 6rpx 0 0 !important;
  85. }
  86. }
  87. }
  88. .right {
  89. .title {
  90. display: flex;
  91. align-items: center;
  92. font-size: 26rpx;
  93. font-weight: bold;
  94. .is-top {
  95. height: 36rpx;
  96. margin-right: 10rpx;
  97. line-height: 36rpx;
  98. vertical-align: 4rpx;
  99. transform: scale(0.9);
  100. }
  101. }
  102. .foot {
  103. justify-content: space-between;
  104. .create-time {
  105. font-size: 24rpx;
  106. .time-label {
  107. display: none;
  108. }
  109. }
  110. .visits {
  111. font-size: 24rpx;
  112. margin-left: 0;
  113. }
  114. }
  115. }
  116. &.tb_text_image {
  117. padding: 12rpx;
  118. .left .thumbnail {
  119. ::v-deep {
  120. uni-image {
  121. border-radius: 6rpx !important;
  122. }
  123. }
  124. }
  125. }
  126. &.only_text {
  127. padding: 24rpx;
  128. .right .foot {
  129. .create-time {
  130. .time-label {
  131. display: none;
  132. }
  133. }
  134. .visits {
  135. font-size: 24rpx;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. &.lr_image_text {}
  142. &.lr_text_image {
  143. .left {
  144. order: 2;
  145. padding-left: 30rpx;
  146. }
  147. .right {
  148. order: 1;
  149. padding-left: 0;
  150. }
  151. }
  152. &.tb_image_text {
  153. flex-direction: column;
  154. padding: 24rpx;
  155. .left {
  156. width: 100%;
  157. height: 340rpx;
  158. .thumbnail {
  159. ::v-deep uni-image {
  160. border-radius: 6rpx 6rpx 0 0 !important;
  161. }
  162. }
  163. }
  164. .right {
  165. padding-left: 0;
  166. padding: 24rpx 0;
  167. padding-bottom: 0;
  168. width: 100%;
  169. .foot {
  170. justify-content: flex-start;
  171. .create-time {
  172. .time-label {
  173. display: inline-block;
  174. }
  175. }
  176. .visits {
  177. margin-left: 24rpx;
  178. }
  179. }
  180. }
  181. }
  182. &.tb_text_image {
  183. flex-direction: column;
  184. .left {
  185. width: 100%;
  186. height: 340rpx;
  187. order: 2;
  188. margin-top: 24rpx;
  189. }
  190. .right {
  191. padding-left: 0;
  192. width: 100%;
  193. order: 1;
  194. .foot {
  195. justify-content: flex-start;
  196. .create-time {
  197. .time-label {
  198. display: inline-block;
  199. }
  200. }
  201. .visits {
  202. margin-left: 24rpx;
  203. }
  204. }
  205. }
  206. }
  207. &.only_text {
  208. padding: 36rpx;
  209. .left {
  210. display: none;
  211. }
  212. .right {
  213. padding-left: 0;
  214. .content {
  215. margin-top: 24rpx;
  216. }
  217. .foot {
  218. justify-content: flex-start;
  219. margin-top: 24rpx;
  220. .create-time {
  221. .time-label {
  222. display: inline-block;
  223. }
  224. }
  225. .visits {
  226. margin-left: 24rpx;
  227. }
  228. }
  229. }
  230. }
  231. .left {
  232. width: 240rpx;
  233. height: 180rpx;
  234. .thumbnail {
  235. width: 100%;
  236. height: 100%;
  237. border-radius: 12rpx;
  238. }
  239. }
  240. .right {
  241. width: 0;
  242. flex-grow: 1;
  243. display: flex;
  244. flex-direction: column;
  245. padding-left: 30rpx;
  246. box-sizing: border-box;
  247. .title {
  248. display: flex;
  249. align-items: center;
  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: 6rpx 12rpx;
  263. box-shadow: none !important;
  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>