mix-list-cell.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="content">
  3. <view class="mix-list-cell" :class="border" @click="eventClick" hover-class="cell-hover" :hover-stay-time="50">
  4. <image
  5. v-if="icon"
  6. class="cell-icon"
  7. :style="[{
  8. color: iconColor,
  9. }]"
  10. :src='icon'
  11. mode='aspectFit'
  12. ></image>
  13. <text class="cell-tit clamp">{{title}}</text>
  14. <text v-if="tips" class="cell-tip">{{tips}}</text>
  15. <text class="cell-more yticon"
  16. :class="typeList[navigateType]"
  17. ></text>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. /**
  23. * 简单封装了下, 应用范围比较狭窄,可以在此基础上进行扩展使用
  24. * 比如加入image, iconSize可控等
  25. */
  26. export default {
  27. data() {
  28. return {
  29. typeList: {
  30. left: 'icon-zuo',
  31. right: 'icon-you',
  32. up: 'icon-shang',
  33. down: 'icon-xia'
  34. },
  35. }
  36. },
  37. props: {
  38. // 图标
  39. icon: {
  40. type: String,
  41. default: ''
  42. },
  43. // 标题
  44. title: {
  45. type: String,
  46. default: '标题'
  47. },
  48. // 右侧角标内容
  49. tips: {
  50. type: String,
  51. default: ''
  52. },
  53. // 是否显示右侧角标
  54. showType:{
  55. type: Boolean,
  56. default: true
  57. },
  58. // 右侧角标类型
  59. navigateType: {
  60. type: String,
  61. default: 'right'
  62. },
  63. // 边框
  64. border: {
  65. type: String,
  66. default: 'border-bottom-light'
  67. },
  68. // 点击时背景颜色
  69. hoverClass: {
  70. type: String,
  71. default: 'cell-hover'
  72. },
  73. // 图标颜色
  74. iconColor: {
  75. type: String,
  76. default: '#333'
  77. }
  78. },
  79. methods: {
  80. eventClick(){
  81. this.$emit('eventClick');
  82. }
  83. },
  84. }
  85. </script>
  86. <style lang='scss'>
  87. .icon .mix-list-cell.b-b:after{
  88. left: 30rpx;
  89. }
  90. .mix-list-cell{
  91. display:flex;
  92. align-items:baseline;
  93. padding: 20rpx $page-row-spacing;
  94. line-height:60rpx;
  95. position:relative;
  96. &.cell-hover{
  97. background:#fafafa;
  98. }
  99. &.b-b:after{
  100. left: 30rpx;
  101. }
  102. .cell-icon{
  103. align-self:center;
  104. width:58rpx;
  105. max-height:36rpx;
  106. font-size:38rpx;
  107. padding-right: 20rpx;
  108. }
  109. .cell-more{
  110. align-self: center;
  111. font-size:30rpx;
  112. color:$font-color-base;
  113. margin-left:$uni-spacing-row-sm;
  114. }
  115. .cell-tit{
  116. flex: 1;
  117. font-size: $font-base;
  118. color: $font-color-dark;
  119. margin-right:10rpx;
  120. }
  121. .cell-tip{
  122. font-size: $font-sm+2rpx;
  123. color: $font-color-light;
  124. }
  125. }
  126. </style>