_id.vue 2.9 KB

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