zhengyiming
2025-02-10 0f686ea1fe4700a909a6159efcf1fcb0e1f88a17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<template>
  <InfiniteLoading scrollViewClassName="common-infinite-scroll-list" v-bind="infiniteLoadingProps">
    <template #renderItem="{ item }">
      <ResourceCard
        :title="item.title"
        :src="item.avatarUrl"
        :name="item.contact"
        :jobTitle="item.jobTitle"
        :time="item.lastShelfTime"
        :resourceCount="item.resourceCount"
        :intendedDeliveryCities="item.intendedDeliveryCities"
        @click="handleClick(item)"
        :showActionBtn="false"
      >
      </ResourceCard>
    </template>
  </InfiniteLoading>
</template>
 
<script setup lang="ts">
import { useInfiniteLoading } from '@12333/hooks';
import * as resourceServices from '@12333/services/api/Resource';
import { OrderInputType } from '@12333/constants';
import Taro from '@tarojs/taro';
 
type Props = {
  userId?: string;
};
 
const props = withDefaults(defineProps<Props>(), {});
 
const queryState = reactive({
  userId: props.userId,
});
 
const { infiniteLoadingProps } = useInfiniteLoading(
  ({ pageParam }) => {
    let params: API.GetFrontResourceListInput = {
      pageModel: {
        rows: 20,
        page: pageParam,
        orderInput: [
          { property: 'isRecommend', order: OrderInputType.Desc },
          { property: 'lastShelfTime', order: OrderInputType.Desc },
        ],
      },
      userId: queryState.userId,
    };
 
    return resourceServices.getFrontResourceList(params, {
      showLoading: false,
    });
  },
  {
    queryKey: ['resourceServices/getFrontResourceList', queryState],
  }
);
 
function handleClick(item: API.GetFrontResourceList) {
  Taro.navigateTo({
    url: `${RouterPath.resourceDetail}?id=${item.id}`,
  });
}
</script>