index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="classification">
  3. <main>
  4. <view class="left-class">
  5. <scroll-view :scroll-top="leftScroll" scroll-y="true" class="left-scroll">
  6. <view
  7. v-for="(item, index) in leftData" :key="index" class="class-item"
  8. :class="index == idx ? 'active' : ''" @click="leftClick(index, item.classifyId)"
  9. >
  10. {{ item.classifyName }}
  11. </view>
  12. </scroll-view>
  13. </view>
  14. <view class="right-scroll">
  15. <template v-if="ifEmpty">
  16. <div class="empty-box">
  17. <image src="../../static/images/new-business/shop/bgnull.png"></image>
  18. <span>该分类没有商品</span>
  19. </div>
  20. </template>
  21. </view>
  22. </main>
  23. </view>
  24. </template>
  25. <script>
  26. import { getFirstClassifyApi } from '../../api/anotherTFInterface'
  27. export default {
  28. data() {
  29. return {
  30. leftScroll: 0,
  31. leftData: [],
  32. idx: 0,
  33. classForm: {
  34. classifyId: ''
  35. },
  36. // 控制右边空状态的显示
  37. ifEmpty: true
  38. }
  39. },
  40. created() {
  41. this.getLeft()
  42. },
  43. methods: {
  44. leftClick(val, id) {
  45. this.idx = val
  46. this.classForm.classifyId = id
  47. },
  48. // 获取左边侧边栏的数据
  49. async getLeft() {
  50. const res = await getFirstClassifyApi(this.classForm)
  51. console.log(res)
  52. this.leftData = res.data
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. uni-page-body {
  59. height: 100%;
  60. }
  61. .classification {
  62. height: 100%;
  63. main {
  64. display: flex;
  65. height: 100%;
  66. .left-class {
  67. width: 200rpx;
  68. background-color: #f8f8f8;
  69. padding-top: 20rpx;
  70. .left-scroll {
  71. white-space: nowrap;
  72. width: 100%;
  73. height: 100%;
  74. .class-item {
  75. width: 100%;
  76. height: 100rpx;
  77. text-align: center;
  78. line-height: 100rpx;
  79. font-size: 28rpx;
  80. }
  81. .active {
  82. background-color: #fff;
  83. color: #EF530E;
  84. font-weight: 700;
  85. }
  86. }
  87. }
  88. .right-scroll {
  89. flex: 1;
  90. position: relative;
  91. width: 100%;
  92. height: 100%;
  93. .empty-box{
  94. position: absolute;
  95. left: 50%;
  96. top: 30%;
  97. transform: translateX(-50%);
  98. display: flex;
  99. flex-direction: column;
  100. align-items: center;
  101. gap: 30rpx;
  102. color: #999;
  103. image{
  104. width: 200rpx;
  105. height: 200rpx;
  106. }
  107. }
  108. }
  109. }
  110. }
  111. </style>