From 5cd618c9523ad30dccf858a00ff6d99a28de4187 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期四, 11 九月 2025 10:24:35 +0800 Subject: [PATCH] feat: 公告 --- packages/components/src/hooks/index.ts | 70 ++++++++++++++++++++++------------ 1 files changed, 45 insertions(+), 25 deletions(-) diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts index 6eca483..8288b45 100644 --- a/packages/components/src/hooks/index.ts +++ b/packages/components/src/hooks/index.ts @@ -18,17 +18,19 @@ import { useInfiniteLoading } from './infiniteLoading'; import { OrderInputType } from '../constants'; import { convertOrderFrontStatus } from '../utils'; +import { useLifePayRateChannelAllList } from './rate'; export function useGetRate() { const { blLifeRecharge } = useLifeRechargeContext(); - const { data: lifePayRateList, isLoading } = useQuery({ - queryKey: ['blLifeRecharge/getRate'], - queryFn: async () => { - return await blLifeRecharge.services.getRate({ showLoading: false }); - }, - placeholderData: () => [] as LifePayRateListOutput[], - }); + // const { data: lifePayRateList, isLoading } = useQuery({ + // queryKey: ['blLifeRecharge/getRate'], + // queryFn: async () => { + // return await blLifeRecharge.services.getRate({ showLoading: false }); + // }, + // placeholderData: () => [] as LifePayRateListOutput[], + // }); + const { allRateChannelList } = useLifePayRateChannelAllList(); const hasChannel = computed(() => !!blLifeRecharge.accountModel.channlesNum); @@ -50,10 +52,15 @@ if (hasChannel.value && channelRate.value.channlesRate) { return channelRate.value.channlesRate; } + // return ( + // lifePayRateList.value.find( + // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸 + // )?.rate ?? 0 + // ); return ( - lifePayRateList.value.find( - (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸 - )?.rate ?? 0 + allRateChannelList.value + .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.璇濊垂璁㈠崟) + .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0 ); }); @@ -61,10 +68,15 @@ if (hasChannel.value && channelRate.value.channlesRate) { return channelRate.value.channlesRate; } + // return ( + // lifePayRateList.value.find( + // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸 + // )?.rate ?? 0 + // ); return ( - lifePayRateList.value.find( - (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸 - )?.rate ?? 0 + allRateChannelList.value + .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.鐢佃垂璁㈠崟) + .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0 ); }); @@ -72,18 +84,24 @@ if (hasChannel.value && channelRate.value.channlesRate) { return channelRate.value.channlesRate; } + // return ( + // lifePayRateList.value.find( + // (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸 + // )?.rate ?? 0 + // ); return ( - lifePayRateList.value.find( - (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸 - )?.rate ?? 0 + allRateChannelList.value + .filter((x) => x.lifePayOrderType == blLifeRecharge.constants.LifePayOrderTypeEnum.鐕冩皵璁㈠崟) + .toSorted((a, b) => a.platformRate - b.platformRate)?.[0]?.platformRate ?? 0 ); }); return { - lifePayRateList, + // lifePayRateList, lifePayPhoneRate, lifePayElectricRate, lifePayGasRate, + allRateChannelList, }; } @@ -265,23 +283,25 @@ onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any; getDefaultUserAccount?: ( userAccountList: UserAccountListOutput[] - ) => UserAccountListOutput | undefined; + ) => Promise<UserAccountListOutput | undefined>; }; export function useSetUserAccountBySelect({ lifePayOrderType, onSetUserAccount, - getDefaultUserAccount = (data) => data[0], + getDefaultUserAccount = (data) => Promise.resolve(data[0]), }: UseSetUserAccountBySelectOptions) { const { userAccountAllList } = useUserAccountAllList({ lifePayOrderType: lifePayOrderType, - onSuccess(data) { - if (data.length > 0) { - const currentUserAccount = getDefaultUserAccount(data); - if (currentUserAccount) { - onSetUserAccount?.(currentUserAccount); + async onSuccess(data) { + try { + if (data.length > 0) { + const currentUserAccount = await getDefaultUserAccount(data); + if (currentUserAccount) { + onSetUserAccount?.(currentUserAccount); + } } - } + } catch (error) {} }, }); -- Gitblit v1.9.1