uni-section.vue 2.7 KB

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