CommonSection.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="ui-section-card" :class="{ 'no-margin-top': isFirst }">
  3. <view class="section-header" v-if="title">
  4. <text class="title-icon"></text>
  5. <text class="title-text">{{ title }}</text>
  6. <view class="header-extra">
  7. <slot name="extra"></slot>
  8. </view>
  9. </view>
  10. <view class="section-body">
  11. <slot></slot>
  12. </view>
  13. </view>
  14. </template>
  15. <script setup lang="ts">
  16. /**
  17. * UI 通用组件 - 区块容器
  18. * 封装统一的卡片外观、带蓝色竖条的标题栏
  19. */
  20. defineProps<{
  21. /** 标题文字 */
  22. title?: string;
  23. /** 是否为页面第一个区块(移除顶部外边距) */
  24. isFirst?: boolean;
  25. }>();
  26. </script>
  27. <style lang="scss" scoped>
  28. .ui-section-card {
  29. background-color: #ffffff;
  30. border-radius: 20rpx;
  31. padding: 30rpx;
  32. margin-top: 24rpx;
  33. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
  34. overflow: hidden;
  35. &.no-margin-top {
  36. margin-top: 0;
  37. }
  38. .section-header {
  39. display: flex;
  40. align-items: center;
  41. margin-bottom: 24rpx;
  42. position: relative;
  43. .title-icon {
  44. width: 8rpx;
  45. height: 32rpx;
  46. background: linear-gradient(180deg, #1c9bfd 0%, #007aff 100%);
  47. border-radius: 4rpx;
  48. margin-right: 16rpx;
  49. }
  50. .title-text {
  51. font-size: 32rpx;
  52. font-weight: 600;
  53. color: #343a3f;
  54. flex: 1;
  55. }
  56. .header-extra {
  57. flex-shrink: 0;
  58. }
  59. }
  60. .section-body {
  61. width: 100%;
  62. }
  63. }
  64. </style>