tui-list-cell.vue 3.0 KB

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