index.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div class="container">
  3. <recommend-product/>
  4. <commodity-list :kinds="kinds"/>
  5. </div>
  6. </template>
  7. <script>
  8. import axios from '~plugins/axios'
  9. import { CommodityList, RecommendProduct } from '~components/store'
  10. export default {
  11. layout: 'shop',
  12. data () {
  13. return {
  14. uuid: this.$route.params.uuid
  15. }
  16. },
  17. fetch ({ store, params, redirect }) {
  18. if (!params.uuid) {
  19. return redirect('/error')
  20. }
  21. if (params.uuid && params.uuid !== '') {
  22. return Promise.all([
  23. store.dispatch('shop/findStoreInfoFromUuid', params),
  24. store.dispatch('shop/findRecommendProducts', params),
  25. store.dispatch('shop/pageCommoditiesOfStore', params.uuid, { page: 1, count: 6 })
  26. ])
  27. }
  28. },
  29. async asyncData ({ params }) {
  30. // asyncData ({ params }) {
  31. let { data } = await axios.get('/api/commodity/components/kinds', { params: { StoreUuid: params.uuid } })
  32. // axios.get('/api/commodity/components/kinds', { params: { StoreUuid: params.uuid } })
  33. // .then(response => {
  34. return { kinds: data }
  35. // })
  36. },
  37. components: {
  38. RecommendProduct,
  39. CommodityList
  40. }
  41. }
  42. </script>
  43. <style>
  44. #nav_fragment .el-dialog__wrapper .el-dialog--tiny{
  45. width: 320px !important;
  46. }
  47. #nav_fragment .el-dialog__wrapper .el-dialog__body{
  48. padding: 14px !important;
  49. }
  50. </style>