list-cell.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view
  3. class="tui-cell-class tui-list-cell"
  4. :class="{'tui-cell-last': last, 'tui-line-left': lineLeft, 'tui-line-right': lineRight, 'tui-radius': radius }"
  5. :hover-class="hover ? 'tui-cell-hover' : ''"
  6. :style="{ background: bgcolor, fontSize: size + 'rpx', color: color, padding: padding}"
  7. :hover-stay-time="150"
  8. @tap="handleClick"
  9. >
  10. <slot></slot>
  11. <image src="/static/images/common/icon_jump_black3.png" class="arrow" v-if="arrow"></image>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: "ListCell",
  17. props: {
  18. //是否有箭头
  19. arrow: {
  20. type: Boolean,
  21. default: false
  22. },
  23. //是否有点击效果
  24. hover: {
  25. type: Boolean,
  26. default: false
  27. },
  28. lineLeft:{
  29. type: Boolean,
  30. default: true
  31. },
  32. lineRight:{
  33. type: Boolean,
  34. default: false
  35. },
  36. padding:{
  37. type:String,
  38. default:"30rpx"
  39. },
  40. last: {
  41. type: Boolean,
  42. default: false //最后一条数据隐藏线条
  43. },
  44. radius:{
  45. type:Boolean,
  46. default:false
  47. },
  48. bgcolor: {
  49. type: String,
  50. default: "#fff" //背景颜色
  51. },
  52. size: {
  53. type: Number,
  54. default: 28 //字体大小
  55. },
  56. color: {
  57. type: String,
  58. default: "#343434" //字体颜色
  59. },
  60. index: {
  61. type: Number,
  62. default: 0
  63. }
  64. },
  65. methods: {
  66. handleClick() {
  67. this.$emit('click', {
  68. index: this.index
  69. });
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .tui-list-cell {
  76. position: relative;
  77. width: 100%;
  78. box-sizing: border-box;
  79. overflow: hidden;
  80. display: flex;
  81. align-items: center;
  82. }
  83. .tui-radius {
  84. border-radius: 12rpx;
  85. overflow: hidden;
  86. }
  87. .tui-cell-hover {
  88. background: #f7f7f9 !important;
  89. }
  90. .tui-list-cell::after {
  91. content: '';
  92. position: absolute;
  93. border-bottom: 1rpx solid rgba($color: $border-color, $alpha: 0.3);
  94. bottom: 0;
  95. right: 0;
  96. left: 0;
  97. }
  98. .tui-line-left::after {
  99. left: 30rpx !important;
  100. }
  101. .tui-line-right::after {
  102. right: 30rpx !important;
  103. }
  104. .tui-cell-last::after {
  105. border-bottom: 0 !important;
  106. }
  107. .arrow {
  108. width: 20rpx;
  109. height: 32rpx;
  110. position: relative;
  111. flex-shrink: 0;
  112. margin-left: 10rpx;
  113. }
  114. </style>