uni-section.vue 2.7 KB

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