shop.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="bg-[#F6F6F6] min-h-screen overflow-hidden order-list" :style="themeColor()">
  3. <mescroll-body ref="mescrollRef" top="0rpx" @init="mescrollInit" :down="{ use: false }" @up="getCollectFn">
  4. <view class="px-[var(--sidebar-m)] top-mar" v-if="list.length">
  5. <u-swipe-action ref="swipeActive">
  6. <template v-for="(item, index) in list" :key="index">
  7. <view class="mb-[20rpx] rounded-[var(--rounded-big)] overflow-hidden">
  8. <u-swipe-action-item :options="cartOptions" @click="swipeClick(item.site.site_id,0)">
  9. <view class="card-template flex items-center box-border" @click="toShopDetail(item.site.site_id)">
  10. <view class="flex items-center">
  11. <u--image class="overflow-hidden" radius="50%" width="100rpx" height="100rpx" :src="img(item.site.icon ? item.site.icon : '')" model="aspectFill">
  12. <template #error>
  13. <image :src="img('addon/mall/shop/shop_default.png')" class="w-[100rpx] h-[100rpx] rounded-full"></image>
  14. </template>
  15. </u--image>
  16. <view class="ml-[20rpx]">{{item.site.site_name}}</view>
  17. </view>
  18. </view>
  19. </u-swipe-action-item>
  20. </view>
  21. </template>
  22. </u-swipe-action>
  23. </view>
  24. <mescroll-empty :option="{tip : '暂无数据'}" v-if="!list.length && loading"></mescroll-empty>
  25. </mescroll-body>
  26. </view>
  27. </template>
  28. <script setup lang="ts">
  29. import { ref } from 'vue';
  30. import { t } from '@/locale'
  31. import { img, redirect } from '@/utils/common';
  32. import { getShopFollowList , editShopCollect} from '@/addon/mall/api/shop';
  33. import MescrollBody from '@/components/mescroll/mescroll-body/mescroll-body.vue';
  34. import MescrollEmpty from '@/components/mescroll/mescroll-empty/mescroll-empty.vue';
  35. import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
  36. import { onLoad, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
  37. const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom);
  38. let list = ref<Array<Object>>([]);
  39. let loading = ref<boolean>(false);
  40. const getCollectFn = (mescroll) => {
  41. loading.value = false;
  42. let data: object = {
  43. page: mescroll.num,
  44. limit: mescroll.size
  45. };
  46. getShopFollowList(data).then((res) => {
  47. let newArr = (res.data.data as Array<Object>);
  48. //设置列表数据
  49. if (mescroll.num == 1) {
  50. list.value = []; //如果是第一页需手动制空列表
  51. }
  52. list.value = list.value.concat(newArr);
  53. mescroll.endSuccess(newArr.length);
  54. loading.value = true;
  55. }).catch(() => {
  56. loading.value = true;
  57. mescroll.endErr(); // 请求失败, 结束加载
  58. })
  59. }
  60. //进入店铺
  61. const toShopDetail = (id: any) => {
  62. redirect({ url: '/app/pages/site/index', param: { site_id: id } })
  63. }
  64. const cartOptions = ref([
  65. {
  66. text: '取消关注',
  67. style: {
  68. backgroundColor: '#EF000C'
  69. }
  70. }
  71. ])
  72. // 取消店铺关注
  73. const swipeClick = (id:any,is_follow:any) => {
  74. editShopCollect({
  75. site_id: id,
  76. is_follow: is_follow
  77. }).then(res => {
  78. list.value = [];
  79. getMescroll().resetUpScroll();
  80. })
  81. }
  82. </script>
  83. <style>
  84. .order-list .mescroll-body {
  85. padding-bottom: constant(safe-area-inset-bottom) !important;
  86. padding-bottom: env(safe-area-inset-bottom) !important;
  87. }
  88. </style>
  89. <style lang="scss" scoped>
  90. :deep(.u-swipe-action-item__right__button__wrapper){
  91. padding:0 10rpx !important;
  92. }
  93. :deep(.u-swipe-action-item__right__button__wrapper__text){
  94. font-size:24rpx !important;
  95. }
  96. </style>