index.vue 1.7 KB

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