StoreGoodsList.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="store-goods-list-container">
  3. <view
  4. v-if="brandDetail.categoryList && brandDetail.categoryList.length"
  5. style="display: flex;box-sizing: border-box;"
  6. >
  7. <view style="background-color: #f3f3f3;max-height: 85vh;" :style="{ overflowY }">
  8. <view
  9. v-for="item in brandDetail.categoryList" :key="item.serverNameOne"
  10. style="max-width: 144upx;padding: 20upx 28upx;word-break: break-all;box-sizing: border-box;"
  11. :style="{ backgroundColor: item.id === currentTab ? '#ffffff' : 'transparent' }"
  12. @click="(currentTab = item.id) && (currentGoods = brandDetail.categoryList.find(part => part.id === item.id).goodsList || [])"
  13. >
  14. {{ item.name }}
  15. </view>
  16. </view>
  17. <view style="flex: 1;padding: 20upx;max-height: 85vh;" :style="{ overflowY }">
  18. <view v-if="currentGoods && currentGoods.length">
  19. <view v-for="item in currentGoods" :key="item.id">
  20. <StoreGoods
  21. :goods-data="item" pic-height="210rpx" pic-mode="aspectFit" show-voucher
  22. @click-content="(e) => $emit('click-content', e)" @add-car="(e) => $emit('add-car', e)"
  23. ></StoreGoods>
  24. </view>
  25. </view>
  26. <view v-else style="margin: 40upx 0;text-align: center;">
  27. 暂无商品~
  28. </view>
  29. </view>
  30. </view>
  31. <view v-else class="no-data">
  32. 暂无数据
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'StoreGoodsList',
  39. props: {
  40. brandDetail: {
  41. type: Object,
  42. required: true
  43. },
  44. overflowY: {
  45. type: String,
  46. default: 'auto'
  47. }
  48. },
  49. data() {
  50. return {
  51. currentTab: '',
  52. currentGoods: []
  53. }
  54. },
  55. watch: {
  56. brandDetail: {
  57. handler(newVal) {
  58. if (newVal) {
  59. if (this.brandDetail.categoryList && this.brandDetail.categoryList.length) {
  60. (this.currentTab = this.brandDetail.categoryList[0].id) && (this.currentGoods = this.brandDetail.categoryList[0].goodsList || [])
  61. }
  62. }
  63. },
  64. immediate: true,
  65. deep: true
  66. }
  67. },
  68. methods: {
  69. }
  70. }
  71. </script>
  72. <style lang="less" scoped>
  73. .store-goods-list-container {
  74. width: 100%;
  75. font-size: 32upx;
  76. .no-data {
  77. display: flex;
  78. align-items: center;
  79. justify-content: center;
  80. min-height: 200upx;
  81. color: #ccc;
  82. padding: 20upx 0;
  83. flex-direction: column;
  84. }
  85. }
  86. </style>