公司官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
5.0 KiB

  1. <script setup>
  2. // 接收案例项数据作为props
  3. const props = defineProps({
  4. item: {
  5. type: Object,
  6. required: true
  7. },
  8. // 是否显示分类标签
  9. showCategory: {
  10. type: Boolean,
  11. default: true
  12. },
  13. // 按钮类型:"link"链接样式 或 "button"按钮样式
  14. buttonType: {
  15. type: String,
  16. default: 'link' // 'link' 或 'button'
  17. }
  18. });
  19. // 点击查看详情事件
  20. const emit = defineEmits(['view-details']);
  21. const viewDetails = () => {
  22. emit('view-details', props.item.id);
  23. };
  24. </script>
  25. <template>
  26. <div class="case-card" data-aos="fade-up" :data-aos-delay="item.delay">
  27. <div class="case-image">
  28. <div v-if="showCategory" class="category-tag">{{ item.categoryName }}</div>
  29. <img :src="item.imageUrl && item.imageUrl.split(',')[0]" :alt="item.title" />
  30. </div>
  31. <div class="case-content">
  32. <h3>{{ item.title }}</h3>
  33. <p>{{ item.description }}</p>
  34. <!-- 根据buttonType渲染不同的按钮样式 -->
  35. <a v-if="buttonType === 'link'" href="#" class="btn-link" @click.prevent="viewDetails">查看详情</a>
  36. <button v-else class="btn-details" @click="viewDetails">查看详情</button>
  37. </div>
  38. </div>
  39. </template>
  40. <style lang="scss" scoped>
  41. /* 导入全局SCSS变量 */
  42. @use '../../assets/scss/main.scss' as *;
  43. // .case-card {
  44. // background: white;
  45. // border-radius: 8px;
  46. // overflow: hidden;
  47. // box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  48. // transition: transform 0.3s ease, box-shadow 0.3s ease;
  49. // &:hover {
  50. // transform: translateY(-10px);
  51. // box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  52. // .case-image img {
  53. // transform: scale(1.05);
  54. // }
  55. // }
  56. // .case-image {
  57. // position: relative;
  58. // img {
  59. // width: 100%;
  60. // height: 300px;
  61. // object-fit: cover;
  62. // transition: transform 0.5s ease;
  63. // }
  64. // .category-tag {
  65. // position: absolute;
  66. // top: 15px;
  67. // right: 15px;
  68. // background-color: rgba(52, 152, 219, 0.9);
  69. // color: white;
  70. // padding: 6px 12px;
  71. // border-radius: 4px;
  72. // font-size: 0.8rem;
  73. // font-weight: 600;
  74. // z-index: 2;
  75. // }
  76. // }
  77. // .case-content {
  78. // padding: 25px;
  79. // h3 {
  80. // font-size: 1.5rem;
  81. // margin-bottom: 15px;
  82. // color: #2c3e50;
  83. // }
  84. // p {
  85. // color: #7f8c8d;
  86. // margin-bottom: 20px;
  87. // }
  88. // }
  89. // }
  90. // .btn-link {
  91. // color: #3498db;
  92. // text-decoration: none;
  93. // font-weight: 600;
  94. // position: relative;
  95. // cursor: pointer;
  96. // &:after {
  97. // content: '';
  98. // position: absolute;
  99. // width: 0;
  100. // height: 2px;
  101. // bottom: -5px;
  102. // left: 0;
  103. // background-color: #3498db;
  104. // transition: width 0.3s ease;
  105. // }
  106. // &:hover {
  107. // &:after {
  108. // width: 100%;
  109. // }
  110. // }
  111. // }
  112. // .btn-details {
  113. // background-color: #3498db;
  114. // color: white;
  115. // border: none;
  116. // padding: 10px 20px;
  117. // border-radius: 4px;
  118. // font-weight: 600;
  119. // cursor: pointer;
  120. // transition: background-color 0.3s ease;
  121. // &:hover {
  122. // background-color: #2980b9;
  123. // }
  124. // }
  125. .case-card {
  126. border-radius: 12px;
  127. overflow: hidden;
  128. box-shadow: $shadow-sm;
  129. transition: transform 0.3s ease, box-shadow 0.3s ease;
  130. background: white;
  131. position: relative;
  132. &:hover {
  133. transform: translateY(-10px);
  134. box-shadow: $shadow-lg;
  135. .case-image img {
  136. transform: scale(1.05);
  137. }
  138. }
  139. .case-image {
  140. position: relative;
  141. overflow: hidden;
  142. img {
  143. width: 100%;
  144. height: 250px;
  145. object-fit: cover;
  146. transition: transform 0.5s ease;
  147. }
  148. }
  149. .category-tag {
  150. position: absolute;
  151. top: 15px;
  152. right: 15px;
  153. background: rgba($primary-color, 0.8);
  154. color: white;
  155. padding: 5px 12px;
  156. border-radius: 20px;
  157. font-size: 12px;
  158. font-weight: 500;
  159. z-index: 1;
  160. }
  161. .case-content {
  162. padding: 25px;
  163. background: white;
  164. h3 {
  165. font-size: 1.3rem;
  166. margin-bottom: 10px;
  167. color: $text-color;
  168. }
  169. p {
  170. color: $text-light;
  171. margin-bottom: 15px;
  172. line-height: 1.6;
  173. }
  174. }
  175. }
  176. .btn-details {
  177. display: inline-block;
  178. padding: 8px 20px;
  179. background: transparent;
  180. border: 1px solid $primary-color;
  181. color: $primary-color;
  182. border-radius: 30px;
  183. font-weight: 500;
  184. cursor: pointer;
  185. transition: all 0.3s ease;
  186. &:hover {
  187. background: $primary-color;
  188. color: white;
  189. }
  190. }
  191. </style>