app-category-list.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <scroll-view scroll-y class="app-category-list"
  3. :style="{height: `${noSetHeight}` ? `${noSetHeight}` : `${setHeight}`}">
  4. <view class="app-item dir-left-nowrap" v-for="(item, index) in list" :key="index" @click="active(item, index)">
  5. <view class="app-border" :class="{'app-active-b': item.active === true}"></view>
  6. <view class="app-text" :class="{'app-active-f': item.active === true}">{{item.name}}</view>
  7. </view>
  8. </scroll-view>
  9. </template>
  10. <script>
  11. export default {
  12. name: 'app-category-list',
  13. props: {
  14. list: {
  15. type: Array,
  16. default() {
  17. return [];
  18. }
  19. },
  20. windowHeight: {
  21. type: Number,
  22. default() {
  23. return 0
  24. }
  25. },
  26. windowWidth: {
  27. type: Number,
  28. default() {
  29. return 0
  30. }
  31. },
  32. botHeight: {
  33. type: Number,
  34. default() {
  35. return 0
  36. }
  37. },
  38. noSetHeight: {
  39. type: String
  40. }
  41. },
  42. methods: {
  43. active(item, index) {
  44. this.$emit('click', item, index);
  45. }
  46. },
  47. computed: {
  48. setHeight() {
  49. let bottom = 0;
  50. if (this.$parent.$parent.$children[0].tabbarbool) {
  51. bottom = this.botHeight;
  52. }
  53. console.log(bottom);
  54. return (this.windowHeight * (750 / this.windowWidth)) - bottom - 88 + 'rpx';
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped lang="scss">
  60. .app-category-list {
  61. width: #{204rpx};
  62. background-color: #f7f7f7;
  63. .app-item {
  64. width: #{204rpx};
  65. height: #{106rpx};
  66. background-color: #f7f7f7;
  67. .app-border {
  68. width: #{8rpx};
  69. height: #{106rpx};
  70. background-color: #f7f7f7;
  71. }
  72. .app-active-b {
  73. background-color: #ff4544;
  74. }
  75. .app-active-f {
  76. background-color: #ffffff !important;;
  77. color: #ff4544 !important;
  78. }
  79. .app-text {
  80. background-color: #f7f7f7;
  81. width: #{196rpx};
  82. height: #{106rpx};
  83. line-height: #{106rpx};
  84. text-align: center;
  85. font-size: #{28rpx};
  86. color: #666666;
  87. word-break: break-all;
  88. text-overflow: ellipsis;
  89. display: -webkit-box;
  90. -webkit-box-orient: vertical;
  91. -webkit-line-clamp: 1;
  92. overflow: hidden;
  93. }
  94. }
  95. }
  96. </style>