From c24cdd854e258712408a7904bdb401c49e3f07c1 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期四, 28 八月 2025 13:09:08 +0800 Subject: [PATCH] fix: 修改通道充值提示语 --- packages/components/src/hooks/index.ts | 64 ++++++++++++++++++++++++------- 1 files changed, 49 insertions(+), 15 deletions(-) diff --git a/packages/components/src/hooks/index.ts b/packages/components/src/hooks/index.ts index d8ff400..6eca483 100644 --- a/packages/components/src/hooks/index.ts +++ b/packages/components/src/hooks/index.ts @@ -11,7 +11,7 @@ UserAccountListOutput, AddUpdateUserAccountInput, GasParValueResponse, - GasParValueOutput, + ChannelRateOutput, } from '@life-payment/core-vue'; import { useQuery, useQueryClient } from '@tanstack/vue-query'; import { computed, MaybeRef, reactive, unref } from 'vue'; @@ -30,26 +30,54 @@ placeholderData: () => [] as LifePayRateListOutput[], }); - const lifePayPhoneRate = computed( - () => + const hasChannel = computed(() => !!blLifeRecharge.accountModel.channlesNum); + + const { data: channelRate } = useQuery({ + queryKey: ['blLifeRecharge/getChannelRate', blLifeRecharge.accountModel.channlesNum], + queryFn: async () => { + return await blLifeRecharge.services.getChannelRate( + { + checkChannelId: blLifeRecharge.accountModel.channlesNum, + }, + { showLoading: false } + ); + }, + placeholderData: () => ({} as ChannelRateOutput), + enabled: hasChannel, + }); + + const lifePayPhoneRate = computed(() => { + if (hasChannel.value && channelRate.value.channlesRate) { + return channelRate.value.channlesRate; + } + return ( lifePayRateList.value.find( (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸 - )?.rate ?? 100 - ); + )?.rate ?? 0 + ); + }); - const lifePayElectricRate = computed( - () => + const lifePayElectricRate = computed(() => { + if (hasChannel.value && channelRate.value.channlesRate) { + return channelRate.value.channlesRate; + } + return ( lifePayRateList.value.find( (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸 - )?.rate ?? 100 - ); + )?.rate ?? 0 + ); + }); - const lifePayGasRate = computed( - () => + const lifePayGasRate = computed(() => { + if (hasChannel.value && channelRate.value.channlesRate) { + return channelRate.value.channlesRate; + } + return ( lifePayRateList.value.find( (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸 - )?.rate ?? 100 - ); + )?.rate ?? 0 + ); + }); return { lifePayRateList, @@ -235,18 +263,24 @@ type UseSetUserAccountBySelectOptions = { lifePayOrderType: MaybeRef<LifeRechargeConstants.LifePayOrderTypeEnum>; onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any; + getDefaultUserAccount?: ( + userAccountList: UserAccountListOutput[] + ) => UserAccountListOutput | undefined; }; export function useSetUserAccountBySelect({ lifePayOrderType, onSetUserAccount, + getDefaultUserAccount = (data) => data[0], }: UseSetUserAccountBySelectOptions) { const { userAccountAllList } = useUserAccountAllList({ lifePayOrderType: lifePayOrderType, onSuccess(data) { if (data.length > 0) { - const currentUserAccount = data[0]; - onSetUserAccount?.(currentUserAccount); + const currentUserAccount = getDefaultUserAccount(data); + if (currentUserAccount) { + onSetUserAccount?.(currentUserAccount); + } } }, }); -- Gitblit v1.9.1