From f0857de728ef105e898bb02441feb7ef63df4c7a Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 01 十二月 2025 13:18:05 +0800
Subject: [PATCH] fix: s
---
packages/components/src/hooks/index.ts | 70 ++++++++++++++++++++++++-----------
1 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts
index 9946e0e..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 ?? 100
+ 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 ?? 100
+ 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 ?? 100
+ 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,
};
}
@@ -263,19 +281,27 @@
type UseSetUserAccountBySelectOptions = {
lifePayOrderType: MaybeRef<LifeRechargeConstants.LifePayOrderTypeEnum>;
onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any;
+ getDefaultUserAccount?: (
+ userAccountList: UserAccountListOutput[]
+ ) => Promise<UserAccountListOutput | undefined>;
};
export function useSetUserAccountBySelect({
lifePayOrderType,
onSetUserAccount,
+ getDefaultUserAccount = (data) => Promise.resolve(data[0]),
}: UseSetUserAccountBySelectOptions) {
const { userAccountAllList } = useUserAccountAllList({
lifePayOrderType: lifePayOrderType,
- onSuccess(data) {
- if (data.length > 0) {
- const currentUserAccount = data[0];
- 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