tui-section.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="tui-section" :style="{margin:margin,background:background,padding:padding}">
  3. <view class="tui-section__title" @tap="handleClick">
  4. <view class="tui-section__decorate" v-if="isLine"
  5. :style="{background:lineColor,width:lineWidth+'rpx',left:`-${lineRight}rpx`,top:lineGap+'rpx',bottom:lineGap+'rpx',borderRadius:lineCap==='circle'?`${lineWidth}rpx`:0}">
  6. </view>
  7. <slot name="left"></slot>
  8. <text :style="{fontSize:size+'rpx',color:color,fontWeight:fontWeight}" v-if="title">{{title}}</text>
  9. <slot></slot>
  10. </view>
  11. <view class="tui-section__sub" :style="{paddingTop:descrTop+'rpx'}" v-if="descr">
  12. <text class="tui-section__descr" :style="{fontSize:descrSize+'rpx',color:descrColor}"
  13. >{{descr}}</text>
  14. </view>
  15. <slot name="descr"></slot>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: "tuiSection",
  21. emits: ['click'],
  22. props: {
  23. title: {
  24. type: String,
  25. default: ''
  26. },
  27. size: {
  28. type: [Number, String],
  29. default: 32
  30. },
  31. color: {
  32. type: String,
  33. default: '#333'
  34. },
  35. fontWeight: {
  36. type: [Number, String],
  37. default: 400
  38. },
  39. descr: {
  40. type: String,
  41. default: ''
  42. },
  43. descrSize: {
  44. type: [Number, String],
  45. default: 24
  46. },
  47. descrColor: {
  48. type: String,
  49. default: '#7a7a7a'
  50. },
  51. descrTop: {
  52. type: [Number, String],
  53. default: 16
  54. },
  55. isLine: {
  56. type: Boolean,
  57. default: false
  58. },
  59. lineWidth: {
  60. type: [Number, String],
  61. default: 8
  62. },
  63. lineColor: {
  64. type: String,
  65. default: '#5677fc'
  66. },
  67. //square、circle
  68. lineCap: {
  69. type: String,
  70. default: 'circle'
  71. },
  72. lineRight: {
  73. type: [Number, String],
  74. default: 16
  75. },
  76. lineGap: {
  77. type: [Number, String],
  78. default: 4
  79. },
  80. background: {
  81. type: String,
  82. default: 'transparent'
  83. },
  84. padding: {
  85. type: String,
  86. default: '20rpx 30rpx'
  87. },
  88. margin: {
  89. type: String,
  90. default: '0'
  91. }
  92. },
  93. methods: {
  94. handleClick() {
  95. this.$emit('click', {
  96. title: this.title
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped>
  103. .tui-section {
  104. /* #ifndef APP-NVUE */
  105. width: 100%;
  106. box-sizing: border-box;
  107. /* #endif */
  108. }
  109. .tui-section__title {
  110. position: relative;
  111. /* #ifndef APP-NVUE */
  112. display: flex;
  113. word-break: break-all;
  114. flex-shrink: 0;
  115. /* #endif */
  116. flex-direction: row;
  117. align-items: center;
  118. }
  119. .tui-section__decorate {
  120. position: absolute;
  121. }
  122. .tui-section__sub {
  123. /* #ifndef APP-NVUE */
  124. word-break: break-all;
  125. /* #endif */
  126. }
  127. .tui-section__descr {
  128. font-weight: 400;
  129. }
  130. </style>