_id.vue 2.5 KB

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