zhengyiming
8 天以前 c24cdd854e258712408a7904bdb401c49e3f07c1
packages/components/src/hooks/index.ts
@@ -53,7 +53,7 @@
    return (
      lifePayRateList.value.find(
        (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认话费折扣
      )?.rate ?? 100
      )?.rate ?? 0
    );
  });
@@ -64,7 +64,7 @@
    return (
      lifePayRateList.value.find(
        (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认电费折扣
      )?.rate ?? 100
      )?.rate ?? 0
    );
  });
@@ -75,7 +75,7 @@
    return (
      lifePayRateList.value.find(
        (x) => x.rateType === blLifeRecharge.constants.LifePayRateTypeEnum.默认燃气折扣
      )?.rate ?? 100
      )?.rate ?? 0
    );
  });
@@ -263,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);
        }
      }
    },
  });