zhengyiming
23 小时以前 6ac59f6fa91e51272b8cd4797458995e168ec0f9
apps/taro/src/hooks/lifepay.ts
@@ -6,6 +6,7 @@
} from '@life-payment/core-vue';
import { MaybeRef } from 'vue';
import { Message } from '@/utils';
import Taro from '@tarojs/taro';
export function useOnlineService() {
  const { blLifeRecharge } = useLifeRechargeContext();
@@ -69,10 +70,11 @@
type UseShowingLifePayAnnouncementOptions = {
  params?: MaybeRef<API.GetShowingLifePayAnnouncementInput>;
  onSuccess?: (data: API.CreateEditLifePayAnnouncementOutput) => any;
  staleTime?: MaybeRef<number>;
};
export function useShowingLifePayAnnouncement(options: UseShowingLifePayAnnouncementOptions = {}) {
  const { onSuccess, params = {} } = options;
  const { onSuccess, params = {}, staleTime } = options;
  const { blLifeRecharge } = useLifeRechargeContext();
@@ -91,6 +93,7 @@
    onSuccess: (data) => {
      onSuccess?.(data);
    },
    staleTime: staleTime,
  });
  return {
@@ -100,19 +103,26 @@
  };
}
const dialogShowingLifePayAnnouncementCache = {};
export function useDialogShowingLifePayAnnouncement() {
  const { blLifeRecharge } = useLifeRechargeContext();
  const router = Taro.useRouter();
  useShowingLifePayAnnouncement({
    params: {
      announcementType: blLifeRecharge.constants.AnnouncementTypeEnum.Dialog,
    },
    onSuccess(data) {
      Message.confirm({
        title: '公告',
        message: data.announcementContent ?? '',
        showCancelBtn: false,
      });
      if (!dialogShowingLifePayAnnouncementCache[router.path]) {
        dialogShowingLifePayAnnouncementCache[router.path] = true;
        Message.confirm({
          title: '公告',
          message: data.announcementContent ?? '',
          showCancelBtn: false,
        });
      }
    },
    staleTime: Infinity,
  });
}