Browse Source

fix: 更新轮盘分享数据获取方式

Before 7 months ago
parent
commit
831f196b8b

BIN
public/recharge/activity-1.png


BIN
public/recharge/activity-2.png


BIN
public/recharge/activity-3.png


BIN
public/recharge/button-1.png


BIN
public/recharge/download.png


BIN
public/recharge/success.png


BIN
public/recharge/title_bg.png


+ 73 - 0
src/api/promo.ts

@@ -8,6 +8,79 @@ export interface RedPacketParams {
     // 红包索引
     index: number;
 }
+export interface RedPacketInfoType {
+    red_packets: RedPacket[];
+    /**
+     * 历史领取红包总次数
+     */
+    total_receive_red_packet: number;
+    /**
+     * 历史红包总金额
+     */
+    total_red_packet: number;
+}
+export interface RedPacket {
+    /**
+     * 红包雨结束时间
+     */
+    end_time: number;
+    /**
+     * 图片
+     */
+    icon: string;
+    /**
+     * 活动ID
+     */
+    id: number;
+    /**
+     * 红包索引,抢红包时用
+     */
+    index: number;
+    /**
+     * 是否领取
+     */
+    is_receive: boolean;
+    /**
+     * 活动是否开始
+     */
+    is_start: boolean;
+    rewards: Reward[];
+    /**
+     * 红包雨开始时间
+     */
+    start_time: number;
+}
+
+export interface Reward {
+    /**
+     * 红包等级
+     */
+    level: number;
+    /**
+     * 红包随机范围上限
+     */
+    max_amount: number;
+    /**
+     * vip范围的上限
+     */
+    max_vip: number;
+    /**
+     * 红包随机范围下限
+     */
+    min_amount: number;
+    /**
+     * vip范围的下限
+     */
+    min_vip: number;
+    /**
+     * 打码倍数
+     */
+    multiple: number;
+    /**
+     * 红包总金额
+     */
+    total: number;
+}
 
 // 未登陆的红包信息
 export const redPacketApi = () => {

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

@@ -54,7 +54,7 @@ const ServiceWidget: FC<Props> = (props) => {
                 return res;
             }
 
-            if (res && res.activate.can === 1) {
+            if (res && res.activate.can === 1 && res.not_receive === null) {
                 setVisibleWheel(1);
                 wheelModalRef.current?.onOpen(res);
                 return;

+ 64 - 0
src/app/[locale]/(navbar)/recharge/DownNumber.tsx

@@ -0,0 +1,64 @@
+"use client";
+import { useCountDown } from "ahooks";
+
+export const DownNumber = () => {
+    const [countdown, time] = useCountDown({
+        targetDate: 60800000000,
+        onEnd: () => {},
+    });
+    return (
+        <div className={"flex text-[0.0972rem]"}>
+            <div className={"text-center"}>
+                <div className={"flex items-center text-[#ff7000]"}>
+                    <div
+                        className={
+                            "flex items-center justify-center rounded-[0.0347rem] bg-[#ffd7ab]" +
+                            " h-[0.2083rem] w-[0.2083rem]"
+                        }
+                    >
+                        {`${time.days}`.padStart(2, "0")}
+                    </div>
+                    <span className={"mx-[0.0247rem]"}>:</span>
+                    <div
+                        className={
+                            "flex items-center justify-center rounded-[0.0347rem] bg-[#ffd7ab]" +
+                            " h-[0.2083rem] w-[0.2083rem]"
+                        }
+                    >
+                        {`${time.hours}`.padStart(2, "0")}
+                    </div>
+                    <span className={"mx-[0.0247rem]"}>:</span>
+                    <div
+                        className={
+                            "flex items-center justify-center rounded-[0.0347rem] bg-[#ffd7ab]" +
+                            " h-[0.2083rem] w-[0.2083rem]"
+                        }
+                    >
+                        {`${time.minutes}`.padStart(2, "0")}
+                    </div>
+                    <span className={"mx-[0.0247rem]"}>:</span>
+                    <div
+                        className={
+                            "flex items-center justify-center rounded-[0.0347rem] bg-[#ffd7ab]" +
+                            " h-[0.2083rem] w-[0.2083rem]"
+                        }
+                    >
+                        {`${time.seconds}`.padStart(2, "0")}
+                    </div>
+                </div>
+
+                <div
+                    className={
+                        "grid grid-cols-4 justify-center gap-[0.0833rem]" +
+                        " mt-[3px] text-[0.0733rem]"
+                    }
+                >
+                    <span className={""}>DAYS</span>
+                    <span className={""}>HRS</span>
+                    <span className={""}>MINS</span>
+                    <span className={""}>SECS</span>
+                </div>
+            </div>
+        </div>
+    );
+};

+ 156 - 3
src/app/[locale]/(navbar)/recharge/page.tsx

@@ -1,6 +1,159 @@
-import { RechargeContent } from "@/components/Box/UserRecharge";
+import { RedPacketInfoType } from "@/api/promo";
+import DomainFooter from "@/components/DomainFooter";
+import { Link } from "@/i18n/routing";
+import { server } from "@/utils/server";
+import Image from "next/image";
+import { DownNumber } from "./DownNumber";
 
-const Page = () => {
-    return <RechargeContent type={"page"} />;
+const getRedPacketApi = () => {
+    return server.request<RedPacketInfoType>({
+        url: "/v1/api/user/activity/red_packet",
+        method: "post",
+    });
+};
+const Page = async () => {
+    const { data } = await getRedPacketApi();
+    console.log(`🚀🚀🚀🚀🚀-> in page.tsx on 15`, data.red_packets);
+    return (
+        <>
+            <div className={"mb-[0.2778rem] flex flex-col items-center"}>
+                <Image src={"/recharge/success.png"} alt={"success"} width={80} height={80} />
+                <h1 className={"mt-[0.2083rem] font-bold"}>Parabéns</h1>
+                <p className={"mt-[5px] text-[0.12rem]"}>Sua conta foi criada com sucesso.</p>
+            </div>
+            <div
+                className={
+                    "relative m-[0.0694rem] rounded-[10px] bg-gradient-to-b" +
+                    " from-[#f8e4bf] to-[#f2ae38] p-[0.1389rem]"
+                }
+            >
+                <div className={"absolute -top-[0.125rem] left-1/2 -translate-x-1/2"}>
+                    <Image
+                        src={"/recharge/title_bg.png"}
+                        alt={"Novo Usuário"}
+                        width={300}
+                        height={160}
+                    />
+                    <span
+                        className={
+                            "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" +
+                            " font-bold text-[#ff7301]"
+                        }
+                    >
+                        Novo Usuário
+                    </span>
+                </div>
+
+                <div
+                    className={
+                        "mt-[0.2778rem] flex rounded-[0.0347rem] bg-[#fbe6c6]" +
+                        " p-[0.0694rem]" +
+                        " items-center text-[#000]"
+                    }
+                >
+                    <div>
+                        <Image
+                            src={"/recharge/activity-1.png"}
+                            alt={"activity-1"}
+                            width={80}
+                            height={40}
+                        />
+                    </div>
+                    <div className={"ml-[20px] w-[100%]"}>
+                        <div className={"flex items-center"}>
+                            <div className={"flex-1"}>
+                                <DownNumber />
+                            </div>
+                            <Link href={"/deposit"}>
+                                <div
+                                    className={
+                                        "bg-[url(/recharge/button-1.png)] " +
+                                        " bg-[length:100%_100%] bg-no-repeat" +
+                                        " h-[0.4167rem] w-[0.8333rem] pt-[0.0347rem]"
+                                    }
+                                >
+                                    <span
+                                        className={
+                                            "flex items-center text-[0.125rem]" +
+                                            " font-bold" +
+                                            " justify-center text-[#fff]"
+                                        }
+                                    >
+                                        Deposito
+                                    </span>
+                                </div>
+                            </Link>
+                        </div>
+                        <div>
+                            Deposite dentro de duas horas, você receberá 100 bônus em dinheiro.
+                        </div>
+                    </div>
+                </div>
+
+                {/*   2*/}
+                <div
+                    className={
+                        "mt-[10px] flex rounded-[0.0347rem] bg-[#fbe6c6]" +
+                        " p-[0.0694rem]" +
+                        " items-center justify-between text-[#000]"
+                    }
+                >
+                    <Image
+                        src={"/recharge/activity-2.png"}
+                        alt={"activity-1"}
+                        width={60}
+                        height={40}
+                    />
+                    <div className={"ml-[20px] flex-1"}>ADICIONAR À TELA INICIAL</div>
+                    <Image src={"/recharge/download.png"} alt={"download"} width={60} height={40} />
+                </div>
+
+                {/*  3 */}
+                <div
+                    className={
+                        "mt-[10px] flex rounded-[0.0347rem] bg-[#fbe6c6]" +
+                        " p-[0.0694rem]" +
+                        " items-center text-[#000]"
+                    }
+                >
+                    <div>
+                        <Image
+                            src={"/recharge/activity-3.png"}
+                            alt={"activity-3"}
+                            width={80}
+                            height={40}
+                        />
+                    </div>
+                    <div className={"ml-[20px] w-[100%]"}>
+                        <div className={"flex items-center"}>
+                            <div className={"flex-1"}>De registo prémios</div>
+                            <Link href={"/deposit"}>
+                                <div
+                                    className={
+                                        "bg-[url(/recharge/button-1.png)] " +
+                                        " bg-[length:100%_100%] bg-no-repeat" +
+                                        " h-[0.4167rem] w-[0.8333rem] pt-[0.0347rem]"
+                                    }
+                                >
+                                    <span
+                                        className={
+                                            "flex items-center text-[0.125rem]" +
+                                            " font-bold" +
+                                            " justify-center text-[#fff]"
+                                        }
+                                    >
+                                        Jogo
+                                    </span>
+                                </div>
+                            </Link>
+                        </div>
+                        <div>100 grátis grátis para começar a jogar imediatamente</div>
+                    </div>
+                </div>
+            </div>
+
+            <DomainFooter />
+        </>
+    );
 };
 export default Page;

+ 49 - 42
src/app/[locale]/(wheel)/cashWheel/CashWheelClient.tsx

@@ -5,6 +5,7 @@ import Box from "@/components/Box";
 import { WheelClient } from "@/components/Box/WheelModal";
 import { Link } from "@/i18n/routing";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
+import { server } from "@/utils/client";
 import { copyText, timeFormat } from "@/utils/methods";
 import { useCountDown } from "ahooks";
 import { Popup, Toast } from "antd-mobile";
@@ -17,7 +18,6 @@ import styles from "./style.module.scss";
 interface Props {
     // wheel: WheelsType;
     allHistory: any[];
-    selfHistory: any[];
     phones: any[];
 }
 interface ContextType extends WheelsType, Props {
@@ -116,9 +116,20 @@ const LeftListClient = () => {
         </>
     );
 };
-
+const getSelfHistoryApi = () => {
+    return server.request<any[]>({
+        url: "/v1/api/user/turntable/self_receive",
+        method: "POST",
+    });
+};
 const RightListClient = () => {
-    const wheel = useContext(WheelContext);
+    const [selfHistory, setSelfHistory] = useState<any[]>([]);
+
+    useEffect(() => {
+        getSelfHistoryApi().then((res) => {
+            setSelfHistory(res.data);
+        });
+    }, []);
     return (
         <div className={"h-[100%] overflow-scroll p-[10px]"}>
             <div
@@ -127,42 +138,39 @@ const RightListClient = () => {
                     " text-[#8795b1]"
                 }
             >
-                {wheel.selfHistory &&
-                    wheel.selfHistory.map((n, index) => {
-                        return (
-                            <Fragment key={index}>
-                                <div className={"flex"}>
-                                    <span
-                                        className={"mr-[0.0694rem] text-[0.12rem] text-[#6ddf39]"}
-                                    >
-                                        +100.00
-                                    </span>
-                                    <div
-                                        className={
-                                            "h-[0.16rem] w-[0.16rem] rounded-[50%] bg-[#6ddf39] text-center" +
-                                            " text-[0.07rem] leading-[0.16rem] text-[#fff]"
-                                        }
-                                    >
-                                        R$
-                                    </div>
-                                </div>
-                                <div className={"flex flex-1"}>
-                                    {" "}
-                                    {timeFormat(Date.now(), "br", undefined, true)}
-                                </div>
-                                <div className={"flex justify-end text-[#f0ae18]"}>
-                                    <Image
-                                        className={"mr-[0.0694rem] object-contain"}
-                                        src={"/wheels/group.png"}
-                                        alt={"group"}
-                                        width={20}
-                                        height={8}
-                                    />
-                                    <span>+12</span>
+                {selfHistory.map((item, index) => {
+                    return (
+                        <Fragment key={index}>
+                            <div className={"flex"}>
+                                <span className={"mr-[0.0694rem] text-[0.12rem] text-[#6ddf39]"}>
+                                    +{item.lose_amount}
+                                </span>
+                                <div
+                                    className={
+                                        "h-[0.16rem] w-[0.16rem] rounded-[50%] bg-[#6ddf39] text-center" +
+                                        " text-[0.07rem] leading-[0.16rem] text-[#fff]"
+                                    }
+                                >
+                                    R$
                                 </div>
-                            </Fragment>
-                        );
-                    })}
+                            </div>
+                            <div className={"flex flex-1"}>
+                                {" "}
+                                {timeFormat(item.receive_time, "br", undefined)}
+                            </div>
+                            <div className={"flex items-center justify-end text-[#f0ae18]"}>
+                                <Image
+                                    className={"mr-[0.0694rem] object-contain"}
+                                    src={"/wheels/group.png"}
+                                    alt={"group"}
+                                    width={20}
+                                    height={8}
+                                />
+                                <span>+{item.count_person}</span>
+                            </div>
+                        </Fragment>
+                    );
+                })}
             </div>
         </div>
     );
@@ -457,7 +465,7 @@ const ShareClient = () => {
         Toast.show({ icon: "success", content: t("SummaryPage.copySuc"), maskClickable: false });
     };
     const handler = () => {
-        const current = phones[currentPhoneIndex];
+        const current = wheel.phones?.[currentPhoneIndex];
         window.open(`https://wa.me/${current}`);
         setCurrentPhoneIndex((value) => (value += 1));
     };
@@ -550,7 +558,7 @@ const ShareClient = () => {
 
                         <div className={"mt-[0.0694rem] bg-[#000] p-[10px]"}>
                             <div className={"grid grid-cols-3 gap-[5px] text-[0.0833rem]"}>
-                                {phones.map((phone, index) => {
+                                {wheel.phones?.map((phone, index) => {
                                     return (
                                         <span
                                             style={{
@@ -588,7 +596,7 @@ const ShareClient = () => {
                                     />
                                 </div>
                                 <Link
-                                    href={`sms:${phones.join(";")}?body=message_body`}
+                                    href={`sms:${wheel.phones?.join(";")}?body=message_body`}
                                     className={
                                         "flex items-center rounded-[10px] bg-[#35b2fe]" +
                                         " p-[0.0694rem] text-[#fff]"
@@ -629,7 +637,6 @@ const CashWheelClient: FC<Props> = (props) => {
     const [values, setValues] = useState<Partial<ContextType>>({
         num: 100,
         allHistory: props.allHistory || [],
-        selfHistory: props.selfHistory || [],
         phones: props.phones || [],
         handler: getWheelData,
     });

+ 2 - 14
src/app/[locale]/(wheel)/cashWheel/page.tsx

@@ -7,12 +7,7 @@ const getAllHistoryApi = () => {
         method: "POST",
     });
 };
-const getSelfHistoryApi = () => {
-    return server.request<any[]>({
-        url: "/v1/api/user/turntable/self_receive",
-        method: "POST",
-    });
-};
+
 const getPhoneNumbersApi = () => {
     return server.request<any[]>({
         url: "/v1/api/user/turntable/phone_number",
@@ -22,15 +17,8 @@ const getPhoneNumbersApi = () => {
 
 const CashWheel = async () => {
     const historyResult = await getAllHistoryApi();
-    const selfHistoryResult = await getSelfHistoryApi();
     const phonesResult = await getPhoneNumbersApi();
-    return (
-        <CashWheelClient
-            allHistory={historyResult.data}
-            selfHistory={selfHistoryResult.data}
-            phones={phonesResult.data}
-        />
-    );
+    return <CashWheelClient allHistory={historyResult.data} phones={phonesResult.data} />;
 };
 
 export default CashWheel;

+ 1 - 2
src/components/Box/index.tsx

@@ -69,14 +69,13 @@ const Box: FC<PropsWithChildren<Props>> = (props) => {
      * @description 弹窗类型
      */
     const popupHandler = (actionData: keyof typeof ModalEnum) => {
-        console.log(`🚀🚀🚀🚀🚀-> in index.tsx on 71`, actionData);
         switch (actionData) {
             case ModalEnum.red_packet:
                 isStartPacketsHandler().then((data) => {
                     if (data.length) {
                         packetModalRef.current?.onOpen(data);
                     } else {
-                        Toast.show("It is under development");
+                        Toast.show("The event is not open");
                     }
                 });
                 break;