Parcourir la source

fix: 修改pwa 安装无渠道

ansoni il y a 3 mois
Parent
commit
047c59001f

BIN
public/recharge.zip


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

@@ -295,10 +295,7 @@ const SignInSection: FC = () => {
     });
     useEffect(() => {
         if (getToken()) {
-            // getSignDetailsApi({ activity_id: 3 }).then((res) => {
-            //     console.log(`🚀🚀🚀🚀🚀-> in Service.tsx on 299`, res.data);
-            //     setSignData(res.data);
-            // });
+            // setSignData({ active_id: 3 });
         }
     }, []);
 

+ 4 - 1
src/app/[locale]/(TabBar)/[[...share]]/@clientWidget/page.tsx

@@ -1,6 +1,7 @@
 "use client";
 import { getShareApi } from "@/api/config";
 import { useEventPoint } from "@/hooks/useEventPoint";
+import { isInStandaloneMode } from "@/utils";
 import { Local } from "@/utils/storage";
 import { useSearchParams } from "next/navigation";
 import { useEffect } from "react";
@@ -17,7 +18,9 @@ const Page = () => {
         // pixel 埋点
         eventView();
 
-        Local.setKey("channel_code", window.location.href);
+        if (!isInStandaloneMode()) {
+            Local.setKey("channel_code", window.location.href);
+        }
         // 统计访问
         getShareApi({ channel_url: window.location.href });
 

+ 10 - 6
src/app/[locale]/(doings)/signIn/layout.tsx

@@ -4,15 +4,19 @@ export default function Layout({
     children,
     params: { locale },
 }: {
-    children: React.ReactNode,
-    params: { locale: string },
+    children: React.ReactNode;
+    params: { locale: string };
 }) {
     return (
         <>
-            <HeaderBack showBack={true} className={"bg-[#0d1933] text-[white]"} title={"Sign in and get the gift"} />
-            <main className={"main-header bg-[#1f2225] text-[#000]"}>
+            <HeaderBack
+                showBack={true}
+                className={"bg-[#0d1933] text-[white]"}
+                title={"Sign in and get the gift"}
+            />
+            <main className={"main-header bg-[url(/signDetails/bg3.png)] text-[#000]"}>
                 {children}
             </main>
         </>
-    )
-}
+    );
+}

+ 39 - 45
src/app/[locale]/(doings)/signIn/page.tsx

@@ -1,13 +1,13 @@
 /* eslint-disable @next/next/no-img-element */
-import { BoxListCom, PayBoxList } from "@/components/ModalPopup/SignInModal"
-import { useTranslations } from "next-intl"
-import { FC } from "react"
+import { BoxListCom } from "@/components/ModalPopup/SignInModal";
+import { useTranslations } from "next-intl";
+import { FC } from "react";
 
 const SignIn: FC = () => {
-    const t = useTranslations("signInPage")
+    const t = useTranslations("signInPage");
     return (
         <>
-            <div className="relative w-[100%] h-[100%]">
+            <div className="relative h-[100%] w-[100%]">
                 {/* 主题图片及背景 */}
                 <div className="relative h-[3.1863rem]">
                     <img
@@ -15,28 +15,24 @@ const SignIn: FC = () => {
                         alt=""
                         className="absolute h-[100%] w-[100%]"
                     />
-                    <div className="relative z-50 top-[-0.3363rem] h-[3.0591rem] flex justify-center">
-                        <img
-                            src="/signDetails/theme.png"
-                            alt=""
-                            className="h-[100%]"
-                        />
+                    <div className="relative top-[-0.3363rem] z-50 flex h-[3.0591rem] justify-center">
+                        <img src="/signDetails/theme.png" alt="" className="h-[100%]" />
                     </div>
-                    <div className="absolute z-50 h-[.3636rem] w-[100%] bottom-[0.2136rem]">
-                        <img
-                            src="/signDetails/vip_bg.png"
-                            alt=""
-                            className="h-[100%] w-[100%]"
-                        />
-                        <div className="absolute h-[100%] w-[100%] top-0 px-[0.25rem] text-[white]">
+                    <div className="absolute bottom-[0.2136rem] z-50 h-[.3636rem] w-[100%]">
+                        <img src="/signDetails/vip_bg.png" alt="" className="h-[100%] w-[100%]" />
+                        <div className="absolute top-0 h-[100%] w-[100%] px-[0.25rem] text-[white]">
                             <img
                                 src="/signDetails/vip.png"
                                 alt=""
-                                className="absolute h-[80%] top-[10%]"
+                                className="absolute top-[10%] h-[80%]"
                             />
-                            <div className="relative h-[100%] left-[10%]">
-                                <p className="h-[50%] text-[0.12rem] font-bold leading-[0.2rem]">VIP0</p>
-                                <p className="h-[50%] text-[0.1rem] font-bold leading-[0.12rem]">quanto maior o nível VlP, mais abundantes s?o as recompensas</p>
+                            <div className="relative left-[10%] h-[100%]">
+                                <p className="h-[50%] text-[0.12rem] font-bold leading-[0.2rem]">
+                                    VIP0
+                                </p>
+                                <p className="h-[50%] text-[0.1rem] font-bold leading-[0.12rem]">
+                                    quanto maior o nível VlP, mais abundantes s?o as recompensas
+                                </p>
                             </div>
                         </div>
                     </div>
@@ -44,14 +40,14 @@ const SignIn: FC = () => {
                 {/* 活动背景 */}
                 <div className="absolute top-[2.9727rem] w-[100%]">
                     {/* 右上角文本 */}
-                    <div className="absolute w-[20%] h-[0.32rem] right-[0.1rem] top-0 z-50 text-center text-[0.11rem] font-bold text-[white]">
+                    <div className="absolute right-[0.1rem] top-0 z-50 h-[0.32rem] w-[20%] text-center text-[0.11rem] font-bold text-[white]">
                         <p className={"h-[0.16rem]"}>CountDown</p>
-                        <p className={"text-[yellow] h-[0.16rem]"}>Day 20</p>
+                        <p className={"h-[0.16rem] text-[yellow]"}>Day 20</p>
                     </div>
                     <img
                         src="/signDetails/bg3.png"
                         alt=""
-                        className="absolute h-[100%] w-[100%] z-1"
+                        className="z-1 absolute h-[100%] w-[100%]"
                     />
                     {/* 免费盒子 */}
                     <div className="mt-[0.4227rem]">
@@ -62,30 +58,28 @@ const SignIn: FC = () => {
                         <PayBoxList type="page" />
                     </div> */}
                     {/* 签到按钮 */}
-                    <div className={"relative h-[.6045rem] flex justify-center mt-[0.25rem]"}>
-                        <img
-                            src="/sign/button.png"
-                            className={"h-[100%]"}
-                            alt=""
-                        />
-                        <span className="absolute leading-[0.375rem] text-[0.16rem] font-bold text-[white]">Sign-in</span>
+                    <div className={"relative mt-[0.25rem] flex h-[.6045rem] justify-center"}>
+                        <img src="/sign/button.png" className={"h-[100%]"} alt="" />
+                        <span className="absolute text-[0.16rem] font-bold leading-[0.375rem] text-[white]">
+                            Sign-in
+                        </span>
                     </div>
                     {/* 活动描述文本背景 */}
-                    <div className="relative flex justify-center h-[4.4rem]">
+                    <div className="relative flex h-[4.4rem] justify-center">
                         <div className="relative h-[100%]">
-                            <img
-                                src="/signDetails/bg2.png"
-                                className={"h-[100%]"}
-                                alt=""
-                            />
-                            <div className="absolute h-[100%] top-0 w-[100%]">
+                            <img src="/signDetails/bg2.png" className={"h-[100%]"} alt="" />
+                            <div className="absolute top-0 h-[100%] w-[100%]">
                                 {/* title标题 */}
-                                <div className="h-[0.425rem] text-center text-[white] font-bold leading-[0.425rem] text-[.18rem]">
+                                <div className="h-[0.425rem] text-center text-[.18rem] font-bold leading-[0.425rem] text-[white]">
                                     <p>Activity dedscription</p>
                                 </div>
                                 {/* 描述内容 */}
-                                <div className="w-[100%] h-[3.3455rem] py-[0.2091rem] px-[0.15rem]">
-                                    <ul className={"list-decimal break-word  pt-0 text-[white] text-[.14rem] pl-[.2455rem] pr-[.1rem] leading-[.23rem]"}>
+                                <div className="h-[3.3455rem] w-[100%] px-[0.15rem] py-[0.2091rem]">
+                                    <ul
+                                        className={
+                                            "break-word list-decimal pl-[.2455rem] pr-[.1rem] pt-0 text-[.14rem] leading-[.23rem] text-[white]"
+                                        }
+                                    >
                                         <li>{t("desc1")}</li>
                                         <li>{t("desc2")}</li>
                                         <li>{t("desc3")}</li>
@@ -100,6 +94,6 @@ const SignIn: FC = () => {
                 </div>
             </div>
         </>
-    )
-}
-export default SignIn
+    );
+};
+export default SignIn;

+ 3 - 0
src/app/[locale]/(doings)/store/page.tsx

@@ -1,6 +1,7 @@
 "use client";
 import useDesktop from "@/hooks/useDesktop";
 import { server } from "@/utils/client";
+import { Local } from "@/utils/storage";
 import { Divider, Mask, Popup, ProgressBar, Rate } from "antd-mobile";
 import clsx from "clsx";
 import Image from "next/image";
@@ -709,6 +710,8 @@ const Page = () => {
             setDetails(res.data);
             return res.data;
         });
+
+        Local.setKey("channel_code", window.location.href);
     }, []);
     return (
         <div className={"text-[#000]"}>

+ 1 - 1
src/app/manifest.ts

@@ -4,7 +4,7 @@ export default function manifest(): MetadataRoute.Manifest {
     return {
         name: "BCWin777",
         description: "BCWin777 The home of over 30 million players",
-        start_url: "/",
+        start_url: "/?query=",
         display: "standalone",
         background_color: "#ffffff",
         theme_color: "#000000",

+ 3 - 1
src/hooks/useDesktop.tsx

@@ -1,11 +1,13 @@
 /**
  * @description 自定义pwa 安装hooks
  */
+import { useRouter } from "@/i18n/routing";
 import { useEffect, useRef, useState } from "react";
 
 const useDesktop = (source: "page" | "components") => {
     const prompt = useRef<Event | null>(null);
 
+    const router = useRouter();
     const [isHasDesktop, setHasDesktop] = useState(false);
 
     const downloadHandler = () => {
@@ -42,7 +44,7 @@ const useDesktop = (source: "page" | "components") => {
         // @ts-ignore
         window.onappinstalled = function (ev) {
             // 安装完成
-            console.log("The application was installed.");
+            router.replace("/");
         };
         return () => window.removeEventListener("beforeinstallprompt", initDesktop);
     }, []);

+ 18 - 2
src/stores/useSignStore.ts

@@ -1,3 +1,4 @@
+import { server } from "@/utils/client";
 import { create } from "zustand";
 
 export interface SignType {
@@ -102,15 +103,30 @@ interface State {
 }
 
 interface Action {
-    setSignData: (data: SignType) => void;
+    setSignData: (data: { activity_id: number }) => void;
 }
 
 const initState: State = {
     signData: {},
 };
+const getSignDetailsApi = (data: { activity_id: number }) => {
+    return server.post<SignType>({
+        url: "/v1/api/user/activity/signInInfo",
+        data,
+    });
+};
 export const useSignStore = create<State & Action>()((set, get) => {
     return {
         ...initState,
-        setSignData: (data) => set((value) => ({ ...value, signData: data })),
+        setSignData: (data) => {
+            if (Object.keys(get().signData).length === 0) {
+                getSignDetailsApi(data).then((res) => {
+                    set((value) => ({ ...value, signData: res.data }));
+                });
+            }
+        },
+        getSignData: () => {
+            return get().signData;
+        },
     };
 });