|
@@ -0,0 +1,143 @@
|
|
|
+"use client";
|
|
|
+import { useRouter } from "@/i18n";
|
|
|
+import { getToken } from "@/utils/Cookies";
|
|
|
+import { Mask } from "antd-mobile";
|
|
|
+import { useTranslations } from "next-intl";
|
|
|
+import Image from "next/image";
|
|
|
+import { FC, forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
|
+
|
|
|
+interface Props {}
|
|
|
+
|
|
|
+export interface ModalRefProps {
|
|
|
+ onClose?: () => void;
|
|
|
+ onOpen?: (data: any, index: number) => void;
|
|
|
+}
|
|
|
+
|
|
|
+export interface RechargeContentProps {
|
|
|
+ onCancel: () => void;
|
|
|
+ type?: "page" | "popup";
|
|
|
+}
|
|
|
+export const RechargeContent: FC<RechargeContentProps> = (props) => {
|
|
|
+ const { onCancel, type = "popup" } = props;
|
|
|
+ const t = useTranslations("HomePage");
|
|
|
+ const token = getToken();
|
|
|
+ const router = useRouter();
|
|
|
+ const receiveHandler = () => {
|
|
|
+ if (token) {
|
|
|
+ router.push("/deposit");
|
|
|
+ } else {
|
|
|
+ router.push("/login?redirect=deposit");
|
|
|
+ }
|
|
|
+ onCancel();
|
|
|
+ };
|
|
|
+ return (
|
|
|
+ <div className={""}>
|
|
|
+ <div className={"relative mt-[10vh]"}>
|
|
|
+ {type === "popup" ? (
|
|
|
+ <div
|
|
|
+ onClick={onCancel}
|
|
|
+ className={
|
|
|
+ "absolute right-[10%] top-0 h-[0.1736rem] w-[0.1736rem]" +
|
|
|
+ " rounded-[50%] border-[2px] border-[#dcd8bb] text-[#dcd8bb]" +
|
|
|
+ " flex items-center justify-center"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <span className={"iconfont icon-guanbi"}></span>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
+
|
|
|
+ <div className={"absolute -top-[0.34rem] left-0 -z-10 h-[100%] w-[100%]"}>
|
|
|
+ <img src={"/recharge/bg.png"} className={"h-[100%] w-[100%]"} />
|
|
|
+ </div>
|
|
|
+ <div className={"absolute left-0 top-0 -z-[9] h-[100%] w-[100%]"}>
|
|
|
+ <img src={"/recharge/bg1.png"} className={"h-[100%] w-[100%]"} />
|
|
|
+ </div>
|
|
|
+ <Image
|
|
|
+ src={"/recharge/content.png"}
|
|
|
+ alt={"recharge"}
|
|
|
+ className={"z-2 w-[100%]"}
|
|
|
+ width={750}
|
|
|
+ height={694}
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ className={
|
|
|
+ "absolute bottom-[0.59rem] h-[0.50rem] w-[100%] " + " flex justify-center"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <svg viewBox="0 -15 200 50" style={{ width: "100%", height: "100%" }}>
|
|
|
+ <path d="M0 30 C 50 10, 150 10 200 30" fill="transparent" id="circle" />
|
|
|
+ <text
|
|
|
+ style={{
|
|
|
+ fill: "#ff3333",
|
|
|
+ fontSize: "22px",
|
|
|
+ fontWeight: "bold",
|
|
|
+ textShadow: "0.1em 0.1em rgba(0,0,0,0.5)",
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <textPath
|
|
|
+ xlinkHref="#circle"
|
|
|
+ textAnchor="middle"
|
|
|
+ startOffset="50%"
|
|
|
+ dy="0"
|
|
|
+ >
|
|
|
+ <tspan>{t("rechargeTitle")}</tspan>
|
|
|
+ </textPath>
|
|
|
+ </text>
|
|
|
+ </svg>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ className={
|
|
|
+ "absolute bottom-[0px] right-[50%] flex h-[0.45rem] " +
|
|
|
+ " items-center" +
|
|
|
+ " mb-[0.13rem] translate-x-1/2 font-bold text-[#fee5c1]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ {t("rechargeTips", { num: "100%" })}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className={"relative flex w-[100%] justify-center"}>
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ background: "url(/recharge/button.png)",
|
|
|
+ backgroundRepeat: "no-repeat",
|
|
|
+ backgroundSize: "100% 100%",
|
|
|
+ }}
|
|
|
+ onClick={receiveHandler}
|
|
|
+ className={
|
|
|
+ "flex h-[0.7rem] w-[1.5972rem] items-center justify-center" +
|
|
|
+ " text-[0.1528rem] font-bold text-[#fff]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <span> {t("rechargeButton")}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+};
|
|
|
+const UserRecharge = forwardRef<ModalRefProps, Props>(function UserRecharge(props, ref) {
|
|
|
+ const [visible, setVisible] = useState(false);
|
|
|
+
|
|
|
+ const recharges = useRef<any>();
|
|
|
+ const activeIndex = useRef<number>(0);
|
|
|
+
|
|
|
+ useImperativeHandle(ref, () => {
|
|
|
+ return {
|
|
|
+ onClose: () => setVisible(false),
|
|
|
+ onOpen: (source: any, index?: number) => {
|
|
|
+ recharges.current = source;
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in UserRecharge.tsx on 36`, source);
|
|
|
+ if (index !== null && index !== undefined) {
|
|
|
+ activeIndex.current = index;
|
|
|
+ }
|
|
|
+ setVisible(true);
|
|
|
+ },
|
|
|
+ };
|
|
|
+ });
|
|
|
+ return (
|
|
|
+ <Mask visible={visible} onMaskClick={() => setVisible(false)}>
|
|
|
+ <RechargeContent onCancel={() => setVisible(false)} />
|
|
|
+ </Mask>
|
|
|
+ );
|
|
|
+});
|
|
|
+
|
|
|
+export default UserRecharge;
|