collect_shop.vue 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="ml-[20px] min-h-[70vh] px-[20px] py-[30px] w-[1000px] bg-[#fff] rounded-[var(--rounded-big)]">
  3. <div class="full" v-loading="shopTableData.loading">
  4. <div>
  5. <div class="mb-[27px] text-[18px] text-[#333] font-500">全部店铺({{ shopTableData.total }})</div>
  6. <div v-if="shopTableData.data.length && !shopTableData.loading">
  7. <div class="products">
  8. <template v-for="(item,index) in shopTableData.data" :key="index">
  9. <div class="w-[228px] flex flex-col items-center box-border border-[1px] border-solid border-[#eee] pb-[20px] bg-[#fff] rounded-[var(--rounded-big)] cursor-pointer" @click="toShopDetail(item.site.site_id)">
  10. <el-image class="w-[228px] h-[228px] rounded-t-[var(--rounded-big)]" :src="img(item.site.logo ? item.site.logo : '')" fit="cover">
  11. <template #error>
  12. <img src="" class="w-[228px] h-[228px] rounded-t-[var(--rounded-big)]">
  13. </template>
  14. </el-image>
  15. <div class="w-[80px] h-[80px] mt-[-36px] mb-[18px] box-border border-[1px] border-solid border-[#eee] rounded-full">
  16. <el-image class="w-[80px] h-[80px] rounded-full" :src="img(item.site.front_end_logo ? item.site.front_end_logo : '')" fit="cover">
  17. <template #error>
  18. <img src="@/assets/images/shop_default.png" class="w-[80px] h-[80px] rounded-full">
  19. </template>
  20. </el-image>
  21. </div>
  22. <div class="text-[#333] text-[16px] truncate flex-center w-[212px] mb-[14px]">{{item.site.site_name}}</div>
  23. <div class="flex justify-center">
  24. <el-button plain round class="!text-primary !border-primary oppoSans-M !text-[12px]" @click.stop="cancelCollectShop(item.site.site_id,0)">取消关注</el-button>
  25. </div>
  26. </div>
  27. </template>
  28. </div>
  29. <div class="mt-[16px] flex justify-end">
  30. <el-pagination v-model:current-page="shopTableData.page" v-model:page-size="shopTableData.limit" layout="prev, pager, next" background :total="shopTableData.total" @size-change="loadShopList()" @current-change="loadShopList" />
  31. </div>
  32. </div>
  33. <div class="min-h-[300px]" v-if="!shopTableData.data.length && !shopTableData.loading">
  34. <el-empty description="暂无数据" :image-size="200" :image="img('static/resource/images/system/empty.png')"/>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import { reactive, ref } from 'vue'
  42. import { getShopFollowList , editShopCollect} from '@/addon/mall/api/shop'
  43. import { useRouter } from 'vue-router'
  44. const router = useRouter()
  45. // 获取店铺列表
  46. const shopTableData = reactive({
  47. page: 1,
  48. limit: 10,
  49. total: 0,
  50. loading: true,
  51. data: []
  52. })
  53. const loadShopList = (page: number = 1) => {
  54. shopTableData.loading = true
  55. shopTableData.page = page
  56. getShopFollowList({
  57. page: shopTableData.page,
  58. limit: shopTableData.limit,
  59. }).then(res => {
  60. shopTableData.loading = false
  61. shopTableData.data = res.data.data
  62. shopTableData.total = res.data.total
  63. }).catch(() => {
  64. shopTableData.loading = false
  65. })
  66. }
  67. loadShopList()
  68. // 店铺详情
  69. const toShopDetail = (id:any) => {
  70. router.push(`/shop/detail?site_id=${id}`)
  71. }
  72. // 店铺取消关注
  73. const cancelCollectShop = (id:any,is_follow:any) =>{
  74. editShopCollect({
  75. site_id: id,
  76. is_follow: is_follow
  77. }).then(res => {
  78. loadShopList()
  79. })
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .products{
  84. grid-row-gap: 15px;
  85. grid-column-gap: 15px;
  86. display: grid;
  87. grid-template-columns: repeat(4,1fr);
  88. grid-template-rows: auto;
  89. position: relative;
  90. }
  91. </style>