tui-list-cell.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view
  3. class="tui-list-class tui-list-cell"
  4. :class="[
  5. arrow ? 'tui-cell-arrow' : '',
  6. arrow && arrowRight ? '' : 'tui-arrow-right',
  7. unlined ? 'tui-cell-unlined' : '',
  8. lineLeft ? 'tui-line-left' : '',
  9. lineRight ? 'tui-line-right' : '',
  10. arrow && arrowColor ? 'tui-arrow-' + arrowColor : '',
  11. radius ? 'tui-radius' : ''
  12. ]"
  13. :hover-class="hover ? 'tui-cell-hover' : ''"
  14. :style="{ backgroundColor: backgroundColor, fontSize: size + 'rpx', color: color, padding: padding }"
  15. :hover-stay-time="150"
  16. @tap="handleClick"
  17. >
  18. <slot></slot>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'tuiListCell',
  24. emits: ['click'],
  25. props: {
  26. //是否有箭头
  27. arrow: {
  28. type: Boolean,
  29. default: false
  30. },
  31. //箭头颜色 传值: white,gray,warning,danger
  32. arrowColor: {
  33. type: String,
  34. default: ''
  35. },
  36. //是否有点击效果
  37. hover: {
  38. type: Boolean,
  39. default: true
  40. },
  41. //隐藏线条
  42. unlined: {
  43. type: Boolean,
  44. default: false
  45. },
  46. //线条是否有左偏移距离
  47. lineLeft: {
  48. type: Boolean,
  49. default: true
  50. },
  51. //线条是否有右偏移距离
  52. lineRight: {
  53. type: Boolean,
  54. default: false
  55. },
  56. padding: {
  57. type: String,
  58. default: '26rpx 30rpx'
  59. },
  60. //背景颜色
  61. backgroundColor: {
  62. type: String,
  63. default: '#fff'
  64. },
  65. //字体大小
  66. size: {
  67. type: Number,
  68. default: 28
  69. },
  70. //字体颜色
  71. color: {
  72. type: String,
  73. default: '#333'
  74. },
  75. //是否加圆角
  76. radius: {
  77. type: Boolean,
  78. default: false
  79. },
  80. //箭头是否有偏移距离
  81. arrowRight: {
  82. type: Boolean,
  83. default: true
  84. },
  85. index: {
  86. type: Number,
  87. default: 0
  88. }
  89. },
  90. methods: {
  91. handleClick() {
  92. this.$emit('click', {
  93. index: this.index
  94. });
  95. }
  96. }
  97. };
  98. </script>
  99. <style scoped>
  100. .tui-list-cell {
  101. position: relative;
  102. width: 100%;
  103. box-sizing: border-box;
  104. }
  105. .tui-radius {
  106. border-radius: 6rpx;
  107. overflow: hidden;
  108. }
  109. .tui-cell-hover {
  110. background-color: #f1f1f1 !important;
  111. }
  112. .tui-list-cell::after {
  113. content: '';
  114. position: absolute;
  115. border-bottom: 1px solid #eaeef1;
  116. -webkit-transform: scaleY(0.5) translateZ(0);
  117. transform: scaleY(0.5) translateZ(0);
  118. transform-origin: 0 100%;
  119. bottom: 0;
  120. right: 0;
  121. left: 0;
  122. pointer-events: none;
  123. }
  124. .tui-line-left::after {
  125. left: 30rpx !important;
  126. }
  127. .tui-line-right::after {
  128. right: 30rpx !important;
  129. }
  130. .tui-cell-unlined::after {
  131. border-bottom: 0 !important;
  132. }
  133. .tui-cell-arrow::before {
  134. content: ' ';
  135. height: 10px;
  136. width: 10px;
  137. border-width: 2px 2px 0 0;
  138. border-color: #c0c0c0;
  139. border-style: solid;
  140. -webkit-transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  141. transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  142. position: absolute;
  143. top: 50%;
  144. margin-top: -6px;
  145. right: 30rpx;
  146. }
  147. .tui-arrow-right::before {
  148. right: 0 !important;
  149. }
  150. .tui-arrow-gray::before {
  151. border-color: #666666 !important;
  152. }
  153. .tui-arrow-white::before {
  154. border-color: #ffffff !important;
  155. }
  156. .tui-arrow-warning::before {
  157. border-color: #ff7900 !important;
  158. }
  159. .tui-arrow-success::before {
  160. border-color: #19be6b !important;
  161. }
  162. .tui-arrow-danger::before {
  163. border-color: #eb0909 !important;
  164. }
  165. </style>