|
@@ -3,13 +3,14 @@
|
|
|
import { getWheelReceiveApi } from "@/api/cashWheel";
|
|
|
import Box from "@/components/Box";
|
|
|
import { WheelClient } from "@/components/Box/WheelModal";
|
|
|
+import { Link } from "@/i18n/routing";
|
|
|
import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
import useWheelStore from "@/stores/useWheelStore";
|
|
|
import { server } from "@/utils/client";
|
|
|
import { copyText, timeFormat } from "@/utils/methods";
|
|
|
import NumberFlow from "@number-flow/react";
|
|
|
import { useCountDown, useRequest } from "ahooks";
|
|
|
-import { Popup, Toast } from "antd-mobile";
|
|
|
+import { Mask, Popup, Toast } from "antd-mobile";
|
|
|
import clsx from "clsx";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import Image from "next/image";
|
|
@@ -323,7 +324,9 @@ const DrawMain = () => {
|
|
|
</div>
|
|
|
|
|
|
{/*倒计时*/}
|
|
|
- <CountdownClient />
|
|
|
+ <div className={"relative flex justify-center"}>
|
|
|
+ {!receiveTarget.unique_id ? <CountdownClient /> : <ReceiveClient />}
|
|
|
+ </div>
|
|
|
{/*分享*/}
|
|
|
{currentWheel.end_time && currentWheel.end_time > 0 ? (
|
|
|
<ShareClient ref={shareRef} />
|
|
@@ -331,6 +334,80 @@ const DrawMain = () => {
|
|
|
</>
|
|
|
);
|
|
|
};
|
|
|
+
|
|
|
+const ReceiveClient = () => {
|
|
|
+ const [visible, setVisible] = useState(false);
|
|
|
+ const t = useTranslations();
|
|
|
+ const { receiveTarget, setWheel } = useWheelStore((state) => ({
|
|
|
+ statusWheel: state.status,
|
|
|
+ currentWheel: state.currentWheel,
|
|
|
+ setWheel: state.setWheel,
|
|
|
+ receiveTarget: state.receiveTarget,
|
|
|
+ }));
|
|
|
+
|
|
|
+ const receiveHandler = () => {
|
|
|
+ getWheelReceiveApi({ unique_id: receiveTarget.unique_id! })
|
|
|
+ .then(() => {
|
|
|
+ setVisible(true);
|
|
|
+ setWheel();
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ Toast.show(t(`code.${error.data.code || 500}`));
|
|
|
+ });
|
|
|
+ };
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div className={"mt-[10px]"}>
|
|
|
+ <Image
|
|
|
+ src={"/wheels/receive-button.png"}
|
|
|
+ alt={"receive"}
|
|
|
+ height={80}
|
|
|
+ width={160}
|
|
|
+ onClick={receiveHandler}
|
|
|
+ ></Image>
|
|
|
+ </div>
|
|
|
+ <Mask visible={visible}>
|
|
|
+ <div className={"absolute top-[50%] w-[100%] -translate-y-1/2 p-[0.1389rem]"}>
|
|
|
+ <div
|
|
|
+ className={
|
|
|
+ "h-[2.0833rem] rounded-[0.0694rem] bg-[#232327FF]" +
|
|
|
+ " flex flex-col justify-between p-[0.1389rem]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <div className={"mb-[0.1389rem] text-center"}>
|
|
|
+ Parabéns por conseguir 100 BRL
|
|
|
+ </div>
|
|
|
+ <div className={"flex justify-center"}>
|
|
|
+ <img
|
|
|
+ src="/wheel/cash.png"
|
|
|
+ alt=""
|
|
|
+ className={"w-[0.6rem] object-contain"}
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ className={
|
|
|
+ "ml-[0.1389rem] text-[0.2778rem] font-black" + " text-[#fb8b05]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <p>R$ 100</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <Link href={"/"}>
|
|
|
+ <div
|
|
|
+ className={
|
|
|
+ "h-[0.34rem] w-[100%] rounded-[0.0694rem] bg-[#fb8b05] text-[#fff]" +
|
|
|
+ " flex items-center justify-center"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ Voltar à página inicial
|
|
|
+ </div>
|
|
|
+ </Link>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Mask>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+};
|
|
|
const CountdownClient = () => {
|
|
|
const wheel = useContext(WheelContext);
|
|
|
const { setWheel, currentWheel, receiveTarget } = useWheelStore((state) => ({
|
|
@@ -343,33 +420,14 @@ const CountdownClient = () => {
|
|
|
leftTime: currentWheel.end_time ? currentWheel.end_time * 1000 - Date.now() : 0,
|
|
|
});
|
|
|
const { days, hours, minutes, seconds } = formattedRes;
|
|
|
- const receiveHandler = () => {
|
|
|
- getWheelReceiveApi({ unique_id: receiveTarget.unique_id! }).then((res) => {
|
|
|
- setWheel();
|
|
|
- });
|
|
|
- };
|
|
|
return (
|
|
|
- <div className={"relative flex justify-center"}>
|
|
|
- {receiveTarget.unique_id ? (
|
|
|
- <div className={"mt-[10px]"}>
|
|
|
- <Image
|
|
|
- src={"/wheels/receive-button.png"}
|
|
|
- alt={"receive"}
|
|
|
- height={80}
|
|
|
- width={160}
|
|
|
- onClick={receiveHandler}
|
|
|
- ></Image>
|
|
|
- </div>
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- <img src="/wheels/countdown-bg.png" alt="" />
|
|
|
- <span className={"absolute bottom-[50%] ml-[0.2083rem] translate-y-1/2"}>
|
|
|
- {String(days).padStart(2, "0")}:{String(hours).padStart(2, "0")}:
|
|
|
- {String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}
|
|
|
- </span>
|
|
|
- </>
|
|
|
- )}
|
|
|
- </div>
|
|
|
+ <>
|
|
|
+ <img src="/wheels/countdown-bg.png" alt="" />
|
|
|
+ <span className={"absolute bottom-[50%] ml-[0.2083rem] translate-y-1/2"}>
|
|
|
+ {String(days).padStart(2, "0")}:{String(hours).padStart(2, "0")}:
|
|
|
+ {String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}
|
|
|
+ </span>
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
const phones = Array(9)
|