index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div class="index">
  3. <div v-if="isMobile">
  4. </div>
  5. <div v-else>
  6. <carousel>
  7. <kind-category @loadchild="loadProductKinds"></kind-category>
  8. </carousel>
  9. <advert></advert>
  10. <floor-list></floor-list>
  11. <news></news>
  12. <partner></partner>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { KindCategory, Carousel, Advert, FloorList, Partner, News } from '~components/home'
  18. export default {
  19. name: 'index',
  20. layout: 'main',
  21. fetch ({ store }) {
  22. return Promise.all([
  23. store.dispatch('loadFloors'),
  24. store.dispatch('loadBanners', {type: 'home'}),
  25. store.dispatch('loadProductKinds', { id: 0 }),
  26. store.dispatch('loadNewsSnapshot', { page: 1, pageSize: 10 }),
  27. store.dispatch('loadProductCounts', { _status: 'actived' })
  28. ])
  29. },
  30. components: {
  31. KindCategory,
  32. Carousel,
  33. Advert,
  34. FloorList,
  35. Partner,
  36. News
  37. },
  38. methods: {
  39. loadProductKinds (id) {
  40. this.$store.dispatch('loadAllProductKinds', {id})
  41. }
  42. },
  43. computed: {
  44. isMobile: function () {
  45. return this.$store.state.option.isMobile
  46. }
  47. }
  48. }
  49. </script>