_id.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="kind-wrap">
  3. <div class="container">
  4. <div v-if="actives.length">
  5. <categroy-nav></categroy-nav>
  6. <!--<category-property @loadCmpGoodsByBrandEvent="listemBrandFilter" @loadCmpGoodsByTypeEvent="listemProTypeFilter"></category-property>-->
  7. <component-goods :brandid="brandid" :propertyJSON="propertyJSON"></component-goods>
  8. </div>
  9. <div v-else>
  10. <error-page :title="'物料名称(类目)'"></error-page>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import { CategroyNav, CategoryProperty, ComponentGoods } from '~components/product'
  17. import { ErrorPage } from '~components/error'
  18. export default {
  19. layout: 'main',
  20. data () {
  21. return {
  22. brandid: '',
  23. propertyJSON: {}
  24. }
  25. },
  26. fetch ({store, route}) {
  27. return Promise.all([
  28. store.dispatch('product/loadKindParentsWithBothers', {id: route.params.id}),
  29. store.dispatch('product/loadKindFirstChild', {id: route.params.id}),
  30. store.dispatch('product/loadKindBrands', {id: route.params.id}),
  31. store.dispatch('product/pageComGoods', {kindid: route.params.id})
  32. ])
  33. },
  34. components: {
  35. CategroyNav,
  36. CategoryProperty,
  37. ComponentGoods,
  38. ErrorPage
  39. },
  40. computed: {
  41. actives () {
  42. return this.$store.state.product.kind.kindsParentWithBother.data
  43. }
  44. },
  45. methods: {
  46. loadPage (id) {
  47. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: id})
  48. },
  49. listemBrandFilter (brandid, propertyJSON) {
  50. this.brandid = brandid
  51. this.propertyJSON = propertyJSON
  52. if (brandid) {
  53. if (propertyJSON !== null && Object.getOwnPropertyNames(propertyJSON).length > 3) {
  54. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: brandid, properties: propertyJSON})
  55. } else {
  56. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: brandid})
  57. }
  58. } else if (propertyJSON !== null && Object.getOwnPropertyNames(propertyJSON).length > 3) {
  59. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, properties: propertyJSON})
  60. } else {
  61. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id})
  62. }
  63. },
  64. listemProTypeFilter (propertyJSON, brandid) {
  65. this.brandid = brandid
  66. this.propertyJSON = propertyJSON
  67. if (propertyJSON !== null && Object.getOwnPropertyNames(propertyJSON).length > 3) {
  68. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: brandid, properties: propertyJSON})
  69. } else {
  70. this.$store.dispatch('product/pageComGoods', {kindid: this.$route.params.id, brandid: brandid})
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped>
  77. .kind-wrap {
  78. background: #f7f7f7;
  79. }
  80. .container {
  81. position: relative;
  82. width: 1190px;
  83. margin-right: auto;
  84. margin-left: auto;
  85. }
  86. </style>