From f4d3a468d151ce6ff4ef6b2158c2b13ebae18d43 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 19 三月 2025 18:05:13 +0800 Subject: [PATCH] fix: 三期需求 --- packages/components/src/hooks/index.ts | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 47 insertions(+), 5 deletions(-) diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts index 6862870..805b447 100644 --- a/packages/components/src/hooks/index.ts +++ b/packages/components/src/hooks/index.ts @@ -11,11 +11,13 @@ UserAccountListOutput, AddUpdateUserAccountInput, GasParValueResponse, + GasParValueOutput, } from '@life-payment/core-vue'; import { useQuery, useQueryClient } from '@tanstack/vue-query'; import { computed, MaybeRef, reactive, unref } from 'vue'; import { useInfiniteLoading } from './infiniteLoading'; import { OrderInputType } from '../constants'; +import { convertOrderFrontStatus } from '../utils'; export function useGetRate() { const { blLifeRecharge } = useLifeRechargeContext(); @@ -63,7 +65,7 @@ const { data: phoneParValueList, isLoading } = useQuery({ queryKey: ['blLifeRecharge/getPhoneParValue'], queryFn: async () => { - return await blLifeRecharge.services.getPhoneParValue({ showLoading: false }); + return await blLifeRecharge.services.getPhoneParValue({}, { showLoading: false }); }, select(data) { return data?.phoneParValue ?? []; @@ -82,7 +84,7 @@ const { data: electricParValueList, isLoading } = useQuery({ queryKey: ['blLifeRecharge/getElectricSupportArea'], queryFn: async () => { - return await blLifeRecharge.services.getElectricSupportArea({ showLoading: false }); + return await blLifeRecharge.services.getElectricSupportArea({}, { showLoading: false }); }, select(data) { return data.electricAreaList ?? []; @@ -109,7 +111,7 @@ // }); const { infiniteLoadingProps } = useInfiniteLoading( - ({ pageParam }) => { + async ({ pageParam }) => { let params: QueryLifePayOrderListInput = { pageModel: { rows: 20, @@ -120,9 +122,14 @@ userId: blLifeRecharge.accountModel.userId, }; - return blLifeRecharge.services.getUserLifePayOrderPage(params, { + let res = await blLifeRecharge.services.getUserLifePayOrderPage(params, { showLoading: false, }); + res.data = res.data.map((x) => ({ + ...x, + frontStatus: convertOrderFrontStatus(x.payStatus, x.lifePayOrderStatus), + })); + return res; }, { queryKey: [ @@ -132,6 +139,12 @@ userId: blLifeRecharge.accountModel.userId, }, ], + + select(data) { + console.log('data: ', data); + // data.pages.map((item) => item.data.map((x) => convertOrderFrontStatus(x))) + return data; + }, } ); @@ -251,7 +264,7 @@ const { data: gasParValueList, isLoading } = useQuery({ queryKey: ['blLifeRecharge/getGasParValue'], queryFn: async () => { - return await blLifeRecharge.services.getGasParValue({ showLoading: false }); + return await blLifeRecharge.services.getGasParValue({}, { showLoading: false }); }, select(data) { return data?.gasParValue ?? []; @@ -263,3 +276,32 @@ gasParValueList, }; } + +type UseIntroInfoOptions = { + lifePayOrderType: MaybeRef<LifeRechargeConstants.LifePayOrderTypeEnum>; + onSuccess?: (data: API.LifePayIntroInfoOutput[]) => any; +}; + +export function useIntroInfo({ lifePayOrderType, onSuccess }: UseIntroInfoOptions) { + const { blLifeRecharge } = useLifeRechargeContext(); + + const { data: introInfo } = useQuery({ + queryKey: ['blLifeRecharge/getIntroInfo', lifePayOrderType], + queryFn: async () => { + return await blLifeRecharge.services.getIntroInfo( + { + type: unref(lifePayOrderType), + }, + { + showLoading: false, + } + ); + }, + placeholderData: () => [] as API.LifePayIntroInfoOutput[], + onSuccess: (data) => { + onSuccess?.(data); + }, + }); + + return { introInfo }; +} -- Gitblit v1.9.1