tui-list-cell.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. /* #ifdef MP-BAIDU */
  113. .tui-list-cell:active {
  114. background-color: #f1f1f1 !important;
  115. }
  116. /* #endif */
  117. .tui-list-cell::after {
  118. content: '';
  119. position: absolute;
  120. border-bottom: 1px solid #eaeef1;
  121. -webkit-transform: scaleY(0.5) translateZ(0);
  122. transform: scaleY(0.5) translateZ(0);
  123. transform-origin: 0 100%;
  124. bottom: 0;
  125. right: 0;
  126. left: 0;
  127. pointer-events: none;
  128. }
  129. .tui-line-left::after {
  130. left: 30rpx !important;
  131. }
  132. .tui-line-right::after {
  133. right: 30rpx !important;
  134. }
  135. .tui-cell-unlined::after {
  136. border-bottom: 0 !important;
  137. }
  138. .tui-cell-arrow::before {
  139. content: ' ';
  140. height: 10px;
  141. width: 10px;
  142. border-width: 2px 2px 0 0;
  143. border-color: #c0c0c0;
  144. border-style: solid;
  145. -webkit-transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  146. transform: matrix(0.5, 0.5, -0.5, 0.5, 0, 0);
  147. position: absolute;
  148. top: 50%;
  149. margin-top: -6px;
  150. right: 30rpx;
  151. }
  152. .tui-arrow-right::before {
  153. right: 0 !important;
  154. }
  155. .tui-arrow-gray::before {
  156. border-color: #666666 !important;
  157. }
  158. .tui-arrow-white::before {
  159. border-color: #ffffff !important;
  160. }
  161. .tui-arrow-warning::before {
  162. border-color: #ff7900 !important;
  163. }
  164. .tui-arrow-success::before {
  165. border-color: #19be6b !important;
  166. }
  167. .tui-arrow-danger::before {
  168. border-color: #eb0909 !important;
  169. }
  170. </style>