From 006e8527857850dfd01371384afa532af5a001f7 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 12 二月 2025 14:58:56 +0800 Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/flexJobMiniApp --- apps/cMiniApp/src/hooks/task.ts | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/apps/cMiniApp/src/hooks/task.ts b/apps/cMiniApp/src/hooks/task.ts new file mode 100644 index 0000000..9591376 --- /dev/null +++ b/apps/cMiniApp/src/hooks/task.ts @@ -0,0 +1,55 @@ +import { useInfiniteLoading } from '@12333/hooks'; +import { OrderInputType, Gender } from '@12333/constants'; +import * as orderServices from '@12333/services/api/Order'; +import _ from 'lodash'; +import { trim } from '@12333/utils'; + +export enum HomeOrderType { + Recommend = 'Recommend', + LastShelfTime = 'LastShelfTime', +} + +export function useTaskList() { + const searchValue = ref(''); + + const queryState = reactive({ + searchValueTrim: '', + orderType: HomeOrderType.Recommend, + gender: '' as any as Gender, + companyId: '', + }); + + const handleSearch = _.debounce(function () { + queryState.searchValueTrim = trim(searchValue.value); + }, 300); + + const { infiniteLoadingProps } = useInfiniteLoading( + ({ pageParam }) => { + let params: API.FrontOrderListInput = { + pageModel: { + rows: 20, + page: pageParam, + orderInput: [ + queryState.orderType === HomeOrderType.Recommend + ? { property: 'isRecommend', order: OrderInputType.Desc } + : { property: 'lastShelfTime', order: OrderInputType.Desc }, + ], + }, + }; + + return orderServices.getFrontOrderList(params, { + showLoading: false, + }); + }, + { + queryKey: ['orderServices/getFrontOrderList', queryState], + } + ); + + return { + searchValue, + queryState, + handleSearch, + infiniteLoadingProps, + }; +} -- Gitblit v1.9.1