index.vue 1.2 KB

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