| | |
| | | EnumTaskStatus, |
| | | EnumUserGender, |
| | | EnumTaskUserApplyStatus, |
| | | EnumReadScene, |
| | | } from '@12333/constants'; |
| | | import _ from 'lodash'; |
| | | import { OrderUtils, trim } from '@12333/utils'; |
| | |
| | | type UseTaskListOptions = { |
| | | cityCode?: MaybeRef<string>; |
| | | enabled?: MaybeRef<boolean>; |
| | | needLogin?: MaybeRef<boolean>; |
| | | |
| | | defaultQueryMenuState?: { |
| | | releaseStatus?: EnumTaskReleaseStatus; |
| | |
| | | * @description 仅C端使用 |
| | | */ |
| | | export function useTaskList(options: UseTaskListOptions = {}) { |
| | | const { cityCode = '', enabled = true, defaultQueryMenuState = {}, beforeRequest } = options; |
| | | const { |
| | | cityCode = '', |
| | | enabled = true, |
| | | needLogin = false, |
| | | defaultQueryMenuState = {}, |
| | | beforeRequest, |
| | | } = options; |
| | | |
| | | const searchValue = ref(''); |
| | | |
| | |
| | | params = beforeRequest(params); |
| | | } |
| | | |
| | | return taskServices.getOpenTaskInfos(params, { |
| | | showLoading: false, |
| | | }); |
| | | if (unref(needLogin)) { |
| | | return taskServices.getTaskInfos(params, { |
| | | showLoading: false, |
| | | }); |
| | | } else { |
| | | return taskServices.getOpenTaskInfos(params, { |
| | | showLoading: false, |
| | | }); |
| | | } |
| | | }, |
| | | { |
| | | queryKey: ['taskServices/getOpenTaskInfos', queryState, queryMenuState, cityCode], |
| | | queryKey: ['taskServices/getOpenTaskInfos', queryState, queryMenuState, cityCode, needLogin], |
| | | enabled: enabled, |
| | | } |
| | | ); |
| | |
| | | |
| | | type UseTaskInfoOptions = { |
| | | id: MaybeRef<string>; |
| | | readScene?: string | EnumReadScene; |
| | | onSuccess?: (data: API.GetTaskInfoQueryResult) => any; |
| | | }; |
| | | |
| | | export function useTaskInfo({ id, onSuccess }: UseTaskInfoOptions) { |
| | | export function useTaskInfo({ id, readScene, onSuccess }: UseTaskInfoOptions) { |
| | | const { |
| | | isLoading, |
| | | isError, |
| | | data: detail, |
| | | refetch, |
| | | } = useQuery({ |
| | | queryKey: ['taskServices/getTaskInfo', id], |
| | | queryKey: ['taskServices/getTaskInfo', id, readScene], |
| | | queryFn: async () => { |
| | | return await taskServices.getTaskInfo( |
| | | { id: unref(id) }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | const params: API.APIgetTaskInfoParams = { |
| | | id: unref(id), |
| | | }; |
| | | if (!!readScene) { |
| | | params.readScene = Number(readScene); |
| | | } |
| | | return await taskServices.getTaskInfo(params, { |
| | | showLoading: false, |
| | | }); |
| | | }, |
| | | placeholderData: () => ({} as API.GetTaskInfoQueryResult), |
| | | onSuccess(data) { |