shopList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="list flash-sale">
  3. <div class="content">
  4. <div class="list-banner" v-if="shopList.length">
  5. <img src="~/assets/images/shop-list.jpg" alt />
  6. </div>
  7. <div class="goods-list shop-list">
  8. <!-- 全部 -->
  9. <ShopItem v-if="shopList.length" :shop-list="shopList" />
  10. <div class="empty" v-else>
  11. <div class="img">
  12. <img src="~/assets/images/emptyPic/search-empty.png" alt />
  13. </div>
  14. <div class="action">
  15. <div class="text">{{$t('shopInfo.noRelevant')}}</div>
  16. <nuxt-link to="/" class="btn">{{$t('backToHome')}}</nuxt-link>
  17. </div>
  18. </div>
  19. <!-- 页码 -->
  20. <pagination v-model="current" :pages="pages" @changePage="getSearchShopPage"></pagination>
  21. <!-- /页码 -->
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import PageUtil from '~/plugins/pageUtil'
  28. import ShopItem from '~/components/shop-item'
  29. import Pagination from '~/components/pagination'
  30. export default {
  31. components: {
  32. ShopItem,
  33. Pagination
  34. },
  35. watchQuery: ['fansCount', 'intro', 'prodCount', 'shopId', 'shopLogo', 'shopName', 'current'],
  36. data () {
  37. return {
  38. shopList: [], //店铺列表
  39. fansCount: 0, //粉丝数量
  40. intro: '', //店铺简介
  41. prodCount: 0, //商品数量
  42. shopId: null, //店铺id
  43. shopLogo: '', //店铺logo
  44. shopName: this.$route.query.shopName || '', //店铺名称
  45. current: this.$route.query.current || 1, // 当前页数 // 当前页数
  46. type: this.$route.query.type || '', // 店铺类型
  47. pages: 1, // 总页数
  48. }
  49. },
  50. /**
  51. * 请求店铺接口 | 在页面加载前加载数据
  52. * @param query
  53. */
  54. async asyncData ({ app, query }) {
  55. var param = Object.assign({
  56. fansCount: parseInt(query.fansCount) || 0, //粉丝数量
  57. intro: query.intro || '', //店铺简介
  58. prodCount: parseInt(query.prodCount) || 0, //商品数量
  59. shopId: parseInt(query.shopId) || null, //店铺id
  60. shopLogo: query.shopLogo || '', //店铺logo
  61. shopName: query.shopName || '', //店铺名称
  62. current: parseInt(query.current) || 1, //当前页
  63. size: 20,
  64. type: query.type || ''
  65. }, param)
  66. return await app.$axios.get('/shop/searchShops', {
  67. params: param
  68. }).then(({ data }) => {
  69. // data.rainbow = PageUtil.rainbowWithDot(data.current, data.pages, 5)
  70. // return data
  71. param.pages = data.pages
  72. param.shopList = data.records
  73. return param
  74. })
  75. },
  76. mounted () {
  77. document.title = this.$i18n.t('shopInfo.storeList')
  78. },
  79. methods: {
  80. /**
  81. * 请求店铺列表
  82. */
  83. getSearchShopPage (current) {
  84. this.$router.push({
  85. path: '/shopList',
  86. query: {
  87. fansCount: this.fansCount || '', //粉丝数量
  88. intro: this.intro || '', //店铺介绍
  89. prodCount: this.prodCount || '', //商品数量
  90. shopId: this.shopId || null, //店铺id
  91. shopLogo: this.shopLogo || '', //店铺logo
  92. shopName: this.shopName || '', //店铺名称
  93. current: this.current,
  94. size: 20,
  95. type: this.type || ''
  96. }
  97. })
  98. },
  99. },
  100. }
  101. </script>
  102. <style scoped src='~/assets/css/list.css'></style>
  103. <style scoped>
  104. .empty {
  105. padding-top: 140px;
  106. }
  107. </style>