From f0857de728ef105e898bb02441feb7ef63df4c7a Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 01 十二月 2025 13:18:05 +0800
Subject: [PATCH] fix: s
---
apps/taro/src/hooks/lifepay.ts | 76 ++++++++++++++++++++++++++++++++++++--
1 files changed, 72 insertions(+), 4 deletions(-)
diff --git a/apps/taro/src/hooks/lifepay.ts b/apps/taro/src/hooks/lifepay.ts
index 574a36c..eb019fa 100644
--- a/apps/taro/src/hooks/lifepay.ts
+++ b/apps/taro/src/hooks/lifepay.ts
@@ -1,5 +1,12 @@
import { useQuery } from '@tanstack/vue-query';
-import { useLifeRechargeContext, CreateEditPayChannelsInput } from '@life-payment/core-vue';
+import {
+ useLifeRechargeContext,
+ CreateEditPayChannelsInput,
+ GetShowingLifePayAnnouncementInput,
+} from '@life-payment/core-vue';
+import { MaybeRef } from 'vue';
+import { Message } from '@/utils';
+import Taro from '@tarojs/taro';
export function useOnlineService() {
const { blLifeRecharge } = useLifeRechargeContext();
@@ -20,11 +27,12 @@
}
type UseLifePayChannlesAllListOptions = {
+ params?: MaybeRef<API.QueryLifePayChannlesInput>;
onSuccess?: (data: API.CreateEditPayChannelsInput[]) => any;
};
export function useLifePayChannlesAllList(options: UseLifePayChannlesAllListOptions = {}) {
- const { onSuccess } = options;
+ const { onSuccess, params = {} } = options;
const { blLifeRecharge } = useLifeRechargeContext();
@@ -33,9 +41,9 @@
isLoading,
refetch,
} = useQuery({
- queryKey: ['blLifeRecharge/getLifePayChannlesAllList'],
+ queryKey: ['blLifeRecharge/getLifePayChannlesAllList', params],
queryFn: async () => {
- return await blLifeRecharge.services.getLifePayChannlesAllList({
+ return await blLifeRecharge.services.getLifePayChannlesAllList(unref(params), {
showLoading: false,
});
},
@@ -58,3 +66,63 @@
getChannlesNameByNum,
};
}
+
+type UseShowingLifePayAnnouncementOptions = {
+ params?: MaybeRef<API.GetShowingLifePayAnnouncementInput>;
+ onSuccess?: (data: API.CreateEditLifePayAnnouncementOutput) => any;
+ staleTime?: MaybeRef<number>;
+};
+
+export function useShowingLifePayAnnouncement(options: UseShowingLifePayAnnouncementOptions = {}) {
+ const { onSuccess, params = {}, staleTime } = options;
+
+ const { blLifeRecharge } = useLifeRechargeContext();
+
+ const {
+ data: announcement,
+ isLoading,
+ refetch,
+ } = useQuery({
+ queryKey: ['blLifeRecharge/getShowingLifePayAnnouncement', params],
+ queryFn: async () => {
+ return await blLifeRecharge.services.getShowingLifePayAnnouncement(unref(params), {
+ showLoading: false,
+ skipErrorHandler: true,
+ });
+ },
+ onSuccess: (data) => {
+ onSuccess?.(data);
+ },
+ staleTime: staleTime,
+ });
+
+ return {
+ announcement,
+ isLoading,
+ refetch,
+ };
+}
+
+const dialogShowingLifePayAnnouncementCache = {};
+
+export function useDialogShowingLifePayAnnouncement() {
+ const { blLifeRecharge } = useLifeRechargeContext();
+ const router = Taro.useRouter();
+
+ useShowingLifePayAnnouncement({
+ params: {
+ announcementType: blLifeRecharge.constants.AnnouncementTypeEnum.Dialog,
+ },
+ onSuccess(data) {
+ if (!dialogShowingLifePayAnnouncementCache[router.path]) {
+ dialogShowingLifePayAnnouncementCache[router.path] = true;
+ Message.confirm({
+ title: '鍏憡',
+ message: data.announcementContent ?? '',
+ showCancelBtn: false,
+ });
+ }
+ },
+ staleTime: Infinity,
+ });
+}
--
Gitblit v1.9.1