zhengyiming
8 天以前 c24cdd854e258712408a7904bdb401c49e3f07c1
packages/components/src/hooks/index.ts
@@ -263,19 +263,25 @@
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];
        const currentUserAccount = getDefaultUserAccount(data);
        if (currentUserAccount) {
        onSetUserAccount?.(currentUserAccount);
      }
      }
    },
  });