banner-card.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="banner-card" :style="{ background: bgColor }" @click="handleClick">
  3. <view class="card-content">
  4. <view class="text-content">
  5. <text class="title">{{ title }}</text>
  6. <text class="subtitle">{{ subtitle }}</text>
  7. </view>
  8. <image v-if="image" :src="image" mode="aspectFit" class="card-image"></image>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'BannerCard',
  15. props: {
  16. title: {
  17. type: String,
  18. required: true
  19. },
  20. subtitle: {
  21. type: String,
  22. default: ''
  23. },
  24. image: {
  25. type: String,
  26. default: ''
  27. },
  28. bgColor: {
  29. type: String,
  30. default: '#FFE8CC'
  31. }
  32. },
  33. methods: {
  34. handleClick() {
  35. this.$emit('click');
  36. }
  37. }
  38. };
  39. </script>
  40. <style lang="scss" scoped>
  41. .banner-card {
  42. border-radius: 16rpx;
  43. padding: 24rpx;
  44. margin-bottom: 20rpx;
  45. .card-content {
  46. display: flex;
  47. align-items: center;
  48. justify-content: space-between;
  49. .text-content {
  50. flex: 1;
  51. display: flex;
  52. flex-direction: column;
  53. .title {
  54. font-size: 28rpx;
  55. color: #333333;
  56. font-weight: 500;
  57. margin-bottom: 8rpx;
  58. }
  59. .subtitle {
  60. font-size: 24rpx;
  61. color: #666666;
  62. }
  63. }
  64. .card-image {
  65. width: 120rpx;
  66. height: 120rpx;
  67. margin-left: 20rpx;
  68. }
  69. }
  70. }
  71. </style>