uni-section.vue 2.5 KB

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