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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
  <InfiniteLoading
    scrollViewClassName="common-page-infinite-scroll-list"
    v-bind="infiniteLoadingProps"
  >
    <template #renderItem="{ item }">
      <OrderCard
        :title="item.orderName"
        :hireType="item.hireType"
        :hireNumber="item.hireNumber"
        :hireEndNumber="item.hireEndNumber"
        :ageStart="item.ageStart"
        :ageEnd="item.ageEnd"
        :provinceName="item.provinceName"
        :cityName="item.cityName"
        :orderSupplierRefundInfo="item.orderSupplierRefundInfo"
        :src="item.avatarUrl"
        :name="item.contact"
        :jobTitle="item.jobTitle"
        :time="item.lastShelfTime"
        :integratedSalary="item.integratedSalary"
        :userId="item.userId"
        @click="handleClick(item)"
      >
      </OrderCard>
    </template>
  </InfiniteLoading>
  <FloatButton :icon="IconAdd" text="我要供人" @click="goPublish" />
</template>
 
<script setup lang="ts">
import { useInfiniteLoading, useEvent } from '@12333/hooks';
import * as orderServices from '@12333/services/api/Order';
import { OrderInputType, IndustryCategoryType, ResourceOperateBtnStatus } from '@12333/constants';
import { useAccessPersonalInfo, useCategoryMenu } from '@/hooks';
import { CategoryUtils } from '@12333/utils';
import IconAdd from '@/assets/order/icon-publish.png';
import Taro from '@tarojs/taro';
 
const queryState = reactive({
  categoryId: '',
});
 
const {
  ensureCategoryMenu,
  categoryMenuList: industryServicesCategoryList,
  categoryMenuRefetch,
} = useCategoryMenu({
  type: IndustryCategoryType.IndustryServices,
});
 
onMounted(async () => {
  await ensureCategoryMenu();
  queryState.categoryId = industryServicesCategoryList.value.find((x) =>
    CategoryUtils.isIHasOrder(x.name)
  ).id;
});
 
useEvent('logout/refresh', async function (data) {
  try {
    await categoryMenuRefetch();
    queryState.categoryId = industryServicesCategoryList.value.find((x) =>
      CategoryUtils.isIHasOrder(x.name)
    ).id;
    infiniteLoadingProps.value.refetch();
  } catch (error) {}
});
 
const { infiniteLoadingProps } = useInfiniteLoading(
  ({ pageParam }) => {
    let params: API.FrontOrderListInput = {
      pageModel: {
        rows: 20,
        page: pageParam,
        orderInput: [
          { property: 'isRecommend', order: OrderInputType.Desc },
          { property: 'lastShelfTime', order: OrderInputType.Desc },
        ],
      },
      categoryId: queryState.categoryId,
    };
 
    return orderServices.getFrontOrderList(params, {
      showLoading: false,
    });
  },
  {
    queryKey: ['logout/refresh', 'orderServices/getFrontOrderList', queryState],
    enabled: computed(() => !!queryState.categoryId),
  }
);
 
function handleClick(item: API.FrontOrderList) {
  Taro.navigateTo({
    url: `${RouterPath.orderDetail}?id=${item.id}`,
  });
}
 
const goPublish = useAccessPersonalInfo(() => {
  Taro.navigateTo({
    url: `${RouterPath.publishResource}?resourceOperateBtnStatus=${ResourceOperateBtnStatus.Add}`,
  });
});
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
 
.order-page-list {
  @include listScrollView;
  @include infiniteLoadingInTabBarPage;
}
</style>