uni-section.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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: 'UniTitle',
  25. props: {
  26. type: {
  27. type: String,
  28. default: ''
  29. },
  30. title: {
  31. type: String,
  32. default: ''
  33. },
  34. subTitle: {
  35. type: String,
  36. default: ''
  37. }
  38. },
  39. data() {
  40. return {}
  41. },
  42. watch: {
  43. title(newVal) {
  44. if (uni.report && newVal !== '') {
  45. uni.report('title', newVal)
  46. }
  47. }
  48. },
  49. methods: {
  50. onClick() {
  51. this.$emit('click')
  52. }
  53. }
  54. }
  55. </script>
  56. <style scoped>
  57. .uni-section {
  58. position: relative;
  59. /* #ifndef APP-NVUE */
  60. display: flex;
  61. /* #endif */
  62. margin-top: 10px;
  63. flex-direction: row;
  64. align-items: center;
  65. padding: 0 10px;
  66. height: 50px;
  67. background-color: #f8f8f8;
  68. /* #ifdef APP-NVUE */
  69. border-bottom-color: #e5e5e5;
  70. border-bottom-style: solid;
  71. border-bottom-width: 0.5px;
  72. /* #endif */
  73. font-weight: normal;
  74. }
  75. /* #ifndef APP-NVUE */
  76. .uni-section:after {
  77. position: absolute;
  78. bottom: 0;
  79. right: 0;
  80. left: 0;
  81. height: 1px;
  82. content: '';
  83. -webkit-transform: scaleY(.5);
  84. transform: scaleY(.5);
  85. background-color: #e5e5e5;
  86. }
  87. /* #endif */
  88. .uni-section__head {
  89. flex-direction: row;
  90. justify-content: center;
  91. align-items: center;
  92. margin-right: 10px;
  93. }
  94. .line {
  95. height: 15px;
  96. background-color: #c0c0c0;
  97. border-radius: 5px;
  98. width: 3px;
  99. }
  100. .circle {
  101. width: 8px;
  102. height: 8px;
  103. border-top-right-radius: 50px;
  104. border-top-left-radius: 50px;
  105. border-bottom-left-radius: 50px;
  106. border-bottom-right-radius: 50px;
  107. background-color: #c0c0c0;
  108. }
  109. .uni-section__content {
  110. flex-direction: column;
  111. flex: 1;
  112. color: #333;
  113. }
  114. .uni-section__content-title {
  115. font-size: 14px;
  116. color: #333;
  117. }
  118. .distraction {
  119. flex-direction: row;
  120. align-items: center;
  121. }
  122. .uni-section__content-sub {
  123. font-size: 12px;
  124. color: #999;
  125. }
  126. </style>