listBack.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div>
  3. <SldHomeTopSearch />
  4. <NavCatHeader />
  5. <div class="sld_store_list">
  6. <img class="store_list_banner" src="/store_list_banner.png" />
  7. <div class="seller_list_search clearfix">
  8. <input
  9. type="text"
  10. name="sellerName"
  11. :placeholder="L['请输入店铺名称']"
  12. v-model="keyWord"
  13. @keyup.enter="search_store(keyWord)"
  14. />
  15. <button @click="search_store(keyWord)">{{ L["搜索"] }}</button>
  16. </div>
  17. <div class="seller_list">
  18. <div class="fav_list fav_list_box clearfix">
  19. <div v-for="(item, index) in initData.data" :key="index">
  20. <StoreItem :item="item" :ItemIndex="index" :skeleton="firstLoading">
  21. </StoreItem>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <!-- 分页 start -->
  27. <div class="flex_row_center_center sld_pagination">
  28. <el-pagination
  29. @current-change="handleCurrentChange"
  30. v-model:currentPage="pageData.current"
  31. :page-size="pageData.pageSize"
  32. layout="prev, pager, next, jumper"
  33. :total="pageData.total"
  34. :hide-on-single-page="true"
  35. >
  36. </el-pagination>
  37. </div>
  38. <!-- 分页 end -->
  39. <!-- 空页面 start-->
  40. <SldCommonEmpty v-if="!firstLoading && !initData.data.length" />
  41. <!-- 空页面 end-->
  42. </div>
  43. </template>
  44. <script setup>
  45. import { getCurrentInstance, onMounted, reactive, ref } from "vue";
  46. import { ElPagination } from "element-plus";
  47. // import { lang_zn } from "@/assets/language/zh.js";
  48. import { getCurLanguage } from '@/composables/common.js';
  49. // const L = lang_zn;
  50. const L = getCurLanguage();
  51. const firstLoading = ref(true); //是否第一次加载
  52. const initData = reactive({ data: [] });
  53. const pageData = reactive({
  54. current: 1,
  55. pageSize: 8,
  56. total: null,
  57. });
  58. const params = reactive({
  59. current: pageData.current,
  60. pageSize: pageData.pageSize,
  61. });
  62. const indexNum = ref(0);
  63. useHead({
  64. title:'热门店铺'
  65. })
  66. //初始化数据
  67. const getInitData = async (params) => {
  68. let searchParams = { ...params };
  69. let keys = ''
  70. if(searchParams.current){
  71. keys += searchParams.current
  72. }
  73. const {data:value,pending:pending} = await useFetchRaw(apiUrl + "v3/seller/front/store/list" , {params,params, key:keys.toString(),})
  74. const res = value._rawValue
  75. if(!pending._rawValue){
  76. firstLoading.value = false;
  77. }
  78. if (res.state === 200) {
  79. initData.data = res.data.list;
  80. pageData.current = res.data.pagination.current;
  81. pageData.pageSize = res.data.pagination.pageSize;
  82. pageData.total = res.data.pagination.total;
  83. }
  84. // get(apiUrl + "v3/seller/front/store/list",params).then((res) => {
  85. // firstLoading.value = false;
  86. // if (res.state === 200) {
  87. // initData.data = res.data.list;
  88. // pageData.current = res.data.pagination.current;
  89. // pageData.pageSize = res.data.pagination.pageSize;
  90. // pageData.total = res.data.pagination.total;
  91. // }
  92. // });
  93. };
  94. getInitData(params);
  95. //分页切换
  96. const handleCurrentChange = (e) => {
  97. params.current = e;
  98. getInitData(params);
  99. };
  100. //店铺搜索
  101. const keyWord = ref("");
  102. const search_store = (keyWord) => {
  103. params.keyword = keyWord;
  104. getInitData(params);
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. @import "@/assets/style/storeList.scss";
  109. @import "@/assets/style/base.scss";
  110. .sld_pagination {
  111. width: 580px;
  112. margin: 0 auto;
  113. margin-top: 30px;
  114. margin-bottom: 30px;
  115. }
  116. </style>