zhengyiming
2025-03-27 55c03f35a31979aefd46aead13a145c9b293e6d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { useQuery } from '@tanstack/vue-query';
import { useLifeRechargeContext, CreateEditPayChannelsInput } from '@life-payment/core-vue';
 
export function useOnlineService() {
  const { blLifeRecharge } = useLifeRechargeContext();
 
  const { data } = useQuery({
    queryKey: ['blLifeRecharge/getOnlineService'],
    queryFn: async () => {
      return await blLifeRecharge.services.getOnlineService({
        showLoading: false,
      });
    },
    placeholderData: () => '',
  });
 
  return {
    onlineServiceLink: data,
  };
}
 
type UseLifePayChannlesAllListOptions = {
  onSuccess?: (data: API.CreateEditPayChannelsInput[]) => any;
};
 
export function useLifePayChannlesAllList(options: UseLifePayChannlesAllListOptions = {}) {
  const { onSuccess } = options;
 
  const { blLifeRecharge } = useLifeRechargeContext();
 
  const {
    data: allChannlesList,
    isLoading,
    refetch,
  } = useQuery({
    queryKey: ['blLifeRecharge/getLifePayChannlesAllList'],
    queryFn: async () => {
      return await blLifeRecharge.services.getLifePayChannlesAllList({
        showLoading: false,
      });
    },
    placeholderData: () => [] as CreateEditPayChannelsInput[],
    onSuccess: (data) => {
      onSuccess?.(data);
    },
  });
 
  function getChannlesNameByNum(channlesNum: string) {
    return (
      allChannlesList.value.find((item) => item.channlesNum === channlesNum)?.channlesName ?? ''
    );
  }
 
  return {
    allChannlesList,
    isLoading,
    refetch,
    getChannlesNameByNum,
  };
}