uni-section.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="uni-section">
  3. <view class="uni-section-header" nvue>
  4. <view v-if="type" class="uni-section__head">
  5. <view :class="type" class="uni-section__head-tag" />
  6. </view>
  7. <view class="uni-section__content">
  8. <text :class="{'distraction':!subTitle}" :style="{color:color}"
  9. class="uni-section__content-title">{{ title }}</text>
  10. <text v-if="subTitle" class="uni-section__content-sub">{{ subTitle }}</text>
  11. </view>
  12. </view>
  13. <view :style="{padding: padding ? '10px' : ''}">
  14. <slot />
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. /**
  20. * Section 标题栏
  21. * @description 标题栏
  22. * @property {String} type = [line|circle] 标题装饰类型
  23. * @value line 竖线
  24. * @value circle 圆形
  25. * @property {String} title 主标题
  26. * @property {String} subTitle 副标题
  27. */
  28. export default {
  29. name: 'UniSection',
  30. emits: ['click'],
  31. props: {
  32. type: {
  33. type: String,
  34. default: ''
  35. },
  36. title: {
  37. type: String,
  38. default: ''
  39. },
  40. color: {
  41. type: String,
  42. default: '#333'
  43. },
  44. subTitle: {
  45. type: String,
  46. default: ''
  47. },
  48. padding: {
  49. type: Boolean,
  50. default: false
  51. }
  52. },
  53. data() {
  54. return {}
  55. },
  56. watch: {
  57. title(newVal) {
  58. if (uni.report && newVal !== '') {
  59. uni.report('title', newVal)
  60. }
  61. }
  62. },
  63. methods: {
  64. onClick() {
  65. this.$emit('click')
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. $uni-primary: #2979ff !default;
  72. .uni-section {
  73. background-color: #fff;
  74. // overflow: hidden;
  75. margin-top: 10px;
  76. border-radius: 15rpx;
  77. }
  78. .uni-section-header {
  79. position: relative;
  80. /* #ifndef APP-NVUE */
  81. display: flex;
  82. /* #endif */
  83. flex-direction: row;
  84. align-items: center;
  85. padding: 12px 10px;
  86. // height: 50px;
  87. font-weight: normal;
  88. }
  89. .uni-section__head {
  90. flex-direction: row;
  91. justify-content: center;
  92. align-items: center;
  93. margin-right: 10px;
  94. }
  95. .line {
  96. height: 12px;
  97. background-color: $uni-primary;
  98. border-radius: 10px;
  99. width: 4px;
  100. }
  101. .circle {
  102. width: 8px;
  103. height: 8px;
  104. border-top-right-radius: 50px;
  105. border-top-left-radius: 50px;
  106. border-bottom-left-radius: 50px;
  107. border-bottom-right-radius: 50px;
  108. background-color: $uni-primary;
  109. }
  110. .uni-section__content {
  111. /* #ifndef APP-NVUE */
  112. display: flex;
  113. /* #endif */
  114. flex-direction: column;
  115. flex: 1;
  116. color: #333;
  117. }
  118. .uni-section__content-title {
  119. font-size: 14px;
  120. color: $uni-primary;
  121. }
  122. .distraction {
  123. flex-direction: row;
  124. align-items: center;
  125. }
  126. .uni-section__content-sub {
  127. font-size: 12px;
  128. color: #999;
  129. line-height: 16px;
  130. margin-top: 2px;
  131. }
  132. </style>