index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div class="index">
  3. <div v-if="isMobile">
  4. <Home></Home>
  5. </div>
  6. <div v-if="!isMobile">
  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 !store.state.option.isMobile ? 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. ]) : []
  30. },
  31. components: {
  32. KindCategory,
  33. Carousel,
  34. Advert,
  35. FloorList,
  36. Partner,
  37. News,
  38. Home
  39. },
  40. methods: {
  41. loadProductKinds (id) {
  42. this.$store.dispatch('loadAllProductKinds', {id})
  43. }
  44. },
  45. computed: {
  46. isMobile: function () {
  47. return this.$store.state.option.isMobile
  48. }
  49. }
  50. }
  51. </script>