uni-section.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. 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. /* #endif */
  70. font-weight: normal;
  71. }
  72. /* #ifndef APP-NVUE */
  73. /* #endif */
  74. .uni-section__head {
  75. flex-direction: row;
  76. justify-content: center;
  77. align-items: center;
  78. margin-right: 10px;
  79. }
  80. .line {
  81. height: 15px;
  82. background-color: #c0c0c0;
  83. border-radius: 5px;
  84. width: 3px;
  85. }
  86. .circle {
  87. width: 8px;
  88. height: 8px;
  89. border-top-right-radius: 50px;
  90. border-top-left-radius: 50px;
  91. border-bottom-left-radius: 50px;
  92. border-bottom-right-radius: 50px;
  93. background-color: #c0c0c0;
  94. }
  95. .uni-section__content {
  96. flex-direction: column;
  97. flex: 1;
  98. color: #333;
  99. }
  100. .uni-section__content-title {
  101. font-size: 14px;
  102. color: #333;
  103. }
  104. .distraction {
  105. flex-direction: row;
  106. align-items: center;
  107. }
  108. .uni-section__content-sub {
  109. font-size: 12px;
  110. color: #999;
  111. }
  112. </style>