BaseImgCard.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script setup lang="ts">
  2. import type { INewsItem } from "@/types/data";
  3. defineProps<{
  4. data: INewsItem[],
  5. type: string
  6. }>();
  7. const jumpNewsPage = (item: INewsItem) => {
  8. window.open(item.content);
  9. }
  10. </script>
  11. <template>
  12. <section class="base-card-container">
  13. <div class="grid grid-cols-1 md:grid-cols-3 gap-y-[10px] md:gap-[24px]">
  14. <div class="card-item" v-for="(item, index) in data" :key="index" data-aos="fade-up"
  15. :data-aos-delay="(index + 1) * 100">
  16. <div class="img-wrap" @click="jumpNewsPage(item)">
  17. <!-- @/assets/image/carbo/img-lca-02.png -->
  18. <img :src="item.photo" alt="">
  19. </div>
  20. <div :class="['text-wrap', { 'time-wrap': type === 'news' }]">
  21. <p class="time" v-if="type">{{ item.time }}</p>
  22. <p class="title font-bold" @click="jumpNewsPage(item)">{{ item.title }}</p>
  23. <p class="desc" v-if="!type">{{ item.desc }}</p>
  24. <p class="text" v-if="type">{{ item.source }}</p>
  25. </div>
  26. </div>
  27. </div>
  28. </section>
  29. </template>
  30. <style scoped lang="scss">
  31. .base-card-container {
  32. .card-item {
  33. border-radius: 8px;
  34. overflow: hidden;
  35. box-shadow: 0px 8px 30px 0px #C3D6E93D;
  36. transition: all 0.3s;
  37. &:hover {
  38. .title {
  39. color: #2A68FF;
  40. }
  41. }
  42. .img-wrap {
  43. height: 258px;
  44. cursor: pointer;
  45. img {
  46. width: 100%;
  47. height: 100%;
  48. transition: all 0.3s;
  49. }
  50. }
  51. .text-wrap,
  52. .time-wrap {
  53. position: relative;
  54. height: 188px;
  55. padding: 18px 28px;
  56. margin-top: -55px;
  57. border-radius: 8px 8px 0px 0px;
  58. background: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, #FFFFFF 13.49%, #FFFFFF 100%);
  59. .time {
  60. font-size: 16px;
  61. line-height: 26px;
  62. color: #797979;
  63. }
  64. .title {
  65. text-align: left;
  66. font-size: 22px;
  67. line-height: 36px;
  68. text-overflow: ellipsis;
  69. overflow: hidden;
  70. word-break: break-all;
  71. white-space: nowrap;
  72. cursor: pointer;
  73. }
  74. .desc,
  75. .text {
  76. font-size: 16px;
  77. line-height: 28px;
  78. text-align: justify;
  79. color: #565F83;
  80. }
  81. .text {
  82. font-size: 18px;
  83. }
  84. }
  85. .time-wrap {
  86. height: auto;
  87. .title {
  88. padding: 4px 0;
  89. }
  90. }
  91. &:hover {
  92. img {
  93. scale: 1.05;
  94. }
  95. }
  96. }
  97. }
  98. </style>