Prechádzať zdrojové kódy

fix: 修改分享地址上送逻辑

Before 6 mesiacov pred
rodič
commit
7f3d5d6fe1

+ 1 - 1
src/api/config.ts

@@ -33,7 +33,7 @@ export const getConfigApi = async () => {
 
 export const getShareApi = async (params: { channel_url: string }) => {
     return server.request({
-        url: `/channel/add_click`,
+        url: `/v1/api/user/channel/add_click`,
         method: "get",
         params,
     });

+ 11 - 0
src/app/[locale]/(TabBar)/[[...share]]/@actionWidget/Service.tsx

@@ -7,6 +7,7 @@ import SlotsModal, { SlotModalRefProps } from "@/components/ModalPopup/SlotsModa
 import WheelModal, { WheelModalProps } from "@/components/ModalPopup/WheelModal";
 
 import { getWheelApi } from "@/api/cashWheel";
+import { getShareApi } from "@/api/config";
 import { getGiveInfoApi } from "@/api/slots";
 import { Link } from "@/i18n/routing";
 import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
@@ -17,6 +18,7 @@ import { useRequest } from "ahooks";
 import { Badge } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import Image from "next/image";
+import { useSearchParams } from "next/navigation";
 import { FC, useEffect, useRef } from "react";
 
 interface Props {
@@ -53,6 +55,9 @@ const ServiceWidget: FC<Props> = (props) => {
             return res.data;
         });
     };
+
+    const serach = useSearchParams();
+
     useEffect(() => {
         // 数据存储,侧边栏使用
         setSocials(socials);
@@ -61,6 +66,12 @@ const ServiceWidget: FC<Props> = (props) => {
                 wheelModalRef.current?.onOpen(data);
             }
         });
+
+        // 分享地址
+        if (serach.size > 1 && localStorage.getItem("share_url") !== window.location.href) {
+            getShareApi({ channel_url: window.location.href });
+            localStorage.setItem("share_url", window.location.href);
+        }
     }, []);
 
     const t = useTranslations("HomePage");

+ 0 - 4
src/app/[locale]/providers.tsx

@@ -8,7 +8,6 @@ import { ThemeProviderProps } from "next-themes/dist/types";
 import { ReactNode, useRef } from "react";
 import { Swiper, SwiperClass, SwiperSlide } from "swiper/react";
 
-import { getShareApi } from "@/api/config";
 import { setupFontSize } from "@/utils";
 import { useDebounceEffect } from "ahooks";
 import { initializeApp } from "firebase/app";
@@ -133,9 +132,6 @@ export const Providers = ({ children, themeProps }: ProvidersProps) => {
         setupConfig();
         // 初始化字体
         setupFontSize();
-        // 初始化参数地址
-
-        getShareApi({ channel_url: window.location.href });
     }, []);
 
     return (