|
@@ -1,154 +1,191 @@
|
|
|
/* eslint-disable @next/next/no-img-element */
|
|
|
-'use client'
|
|
|
-import { FC, forwardRef, memo, useImperativeHandle, useRef, useState } from "react"
|
|
|
-import { Mask } from "antd-mobile"
|
|
|
+"use client";
|
|
|
import { useRouter } from "@/i18n/routing";
|
|
|
-import styles from './style.module.scss'
|
|
|
+import { useSignStore } from "@/stores/useSignStore";
|
|
|
+import { Mask } from "antd-mobile";
|
|
|
+import { FC, forwardRef, memo, useImperativeHandle, useRef, useState } from "react";
|
|
|
+import styles from "./style.module.scss";
|
|
|
|
|
|
export interface SignInModalProps {
|
|
|
onClose: () => void;
|
|
|
- onOpen: () => void
|
|
|
+ onOpen: () => void;
|
|
|
}
|
|
|
interface BoxParams {
|
|
|
startDays?: number;
|
|
|
num: number;
|
|
|
- type?: 'page' | 'modal';
|
|
|
+ type?: "page" | "modal";
|
|
|
}
|
|
|
interface BoxList {
|
|
|
- handleOpening: (index: number) => void
|
|
|
+ handleOpening: (index: number) => void;
|
|
|
}
|
|
|
-export const BoxListCom = forwardRef<BoxList, BoxParams>(function BoxListCom({ startDays = 1, num, type = 'modal' }: BoxParams, ref) {
|
|
|
+export const BoxListCom = forwardRef<BoxList, BoxParams>(function BoxListCom(
|
|
|
+ { startDays = 1, num, type = "modal" }: BoxParams,
|
|
|
+ ref
|
|
|
+) {
|
|
|
+ const signData = useSignStore((state) => state.signData);
|
|
|
const handleOpening = (index: number) => {
|
|
|
- const box: any = document.getElementById(`box${index}`)
|
|
|
- box.src = '/sign/box/box-open.png'
|
|
|
- const img = document.getElementById(`opened${index}`)
|
|
|
- img ? img.style.visibility = 'visible' : null
|
|
|
- }
|
|
|
+ const box: any = document.getElementById(`box${index}`);
|
|
|
+ box.src = "/sign/box/box-open.png";
|
|
|
+ const img = document.getElementById(`opened${index}`);
|
|
|
+ img ? (img.style.visibility = "visible") : null;
|
|
|
+ };
|
|
|
useImperativeHandle(ref, (): BoxList => {
|
|
|
return {
|
|
|
- handleOpening
|
|
|
- }
|
|
|
- })
|
|
|
+ handleOpening,
|
|
|
+ };
|
|
|
+ });
|
|
|
return (
|
|
|
<>
|
|
|
- <div className={`w-[100%] ${type === 'page' ? styles.page : styles.modal}`}>
|
|
|
- <div className="flex flex-wrap w-[100%] h-[100%] justify-start">
|
|
|
- {Array.from({ length: num }).map((item, index) => {
|
|
|
+ <div className={`w-[100%] ${type === "page" ? styles.page : styles.modal}`}>
|
|
|
+ <div className="flex h-[100%] w-[100%] flex-wrap justify-start">
|
|
|
+ {signData?.list?.map((item, index) => {
|
|
|
return (
|
|
|
<div className="h-[100%] w-[20%]" key={index}>
|
|
|
<div className="h-[100%] w-[100%]">
|
|
|
- <div className={`relative text-center ${styles.text} text-[white]`}>
|
|
|
+ <div
|
|
|
+ className={`relative text-center ${styles.text} text-[white]`}
|
|
|
+ >
|
|
|
<p>Day{startDays + index}</p>
|
|
|
</div>
|
|
|
- <div className={`relative ${styles.box} w-[100%]`} onClick={(e) => handleOpening(startDays + index)}>
|
|
|
+ <div className={`relative ${styles.box} w-[100%]`}>
|
|
|
+ {/*onClick={(e) => handleOpening(startDays + index)}*/}
|
|
|
<img
|
|
|
- id={'box' + (startDays + index)}
|
|
|
- src={index >= 5 ? '/sign/box_pay/gift.png' : '/sign/box/box.png'}
|
|
|
- className={"h-[100%] z-50 mx-[auto]"}
|
|
|
+ id={"box" + (startDays + index)}
|
|
|
+ src={
|
|
|
+ item.is_suss
|
|
|
+ ? "/sign/box/box-open.png"
|
|
|
+ : item.is_unlock_extra_reward
|
|
|
+ ? "/sign/box_pay/gift.png"
|
|
|
+ : "/sign/box/box.png"
|
|
|
+ }
|
|
|
+ className={"z-50 mx-[auto] h-[100%]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
<div className="flex justify-center">
|
|
|
- <img
|
|
|
- id={'opened' + (startDays + index)}
|
|
|
- src="/sign/opened.png"
|
|
|
- className={"absolute h-[0.34rem] z-50 bottom-[0.035rem] invisible"}
|
|
|
- alt=""
|
|
|
- />
|
|
|
+ {item.is_suss ? (
|
|
|
+ <img
|
|
|
+ id={"opened" + (startDays + index)}
|
|
|
+ src={"/sign/opened.png"}
|
|
|
+ className={
|
|
|
+ "absolute bottom-[0.035rem] z-50 h-[0.34rem]"
|
|
|
+ }
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
- {
|
|
|
- index >= 5 ? <div className="h-[30%] absolute w-[90%] bottom-0 bg-[black] rounded mx-auto left-0 right-0 border-[0.02rem] border-[green]">
|
|
|
- <p className={`${styles.green} text-[green] font-bold text-center`}>Extra +50R</p>
|
|
|
- </div> : null
|
|
|
- }
|
|
|
+ {item.is_unlock_extra_reward ? (
|
|
|
+ <div className="absolute bottom-0 left-0 right-0 mx-auto h-[30%] w-[90%] rounded border-[0.02rem] border-[green] bg-[black]">
|
|
|
+ <p
|
|
|
+ className={`${styles.green} text-center font-bold text-[green]`}
|
|
|
+ >
|
|
|
+ Extra +{item.extra_num}R
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
- {
|
|
|
- index >= 5 ? <div className={`${styles.lock} relative text-center text-[yellow] font-bold flex justify-center mt-[0.05rem]`}>
|
|
|
+ {item.is_unlock_extra_reward ? (
|
|
|
+ <div
|
|
|
+ className={`${styles.lock} relative mt-[0.05rem] flex justify-center text-center font-bold text-[yellow]`}
|
|
|
+ >
|
|
|
<img
|
|
|
- id={'opened' + (startDays + index)}
|
|
|
+ id={"opened" + (startDays + index)}
|
|
|
src="/sign/lock.png"
|
|
|
- className={"h-[100%] block"}
|
|
|
+ className={"block h-[100%]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
- <span className="block">+5R</span>
|
|
|
- </div> : null
|
|
|
- }
|
|
|
+ <span className="block">+{item.extra_num}</span>
|
|
|
+ </div>
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
</div>
|
|
|
- )
|
|
|
+ );
|
|
|
})}
|
|
|
</div>
|
|
|
</div>
|
|
|
</>
|
|
|
- )
|
|
|
-})
|
|
|
+ );
|
|
|
+});
|
|
|
|
|
|
interface PayProps {
|
|
|
- type?: 'page' | 'modal'
|
|
|
+ type?: "page" | "modal";
|
|
|
}
|
|
|
-export const PayBoxList: FC<PayProps> = ({ type = 'modal' }) => {
|
|
|
+export const PayBoxList: FC<PayProps> = ({ type = "modal" }) => {
|
|
|
return (
|
|
|
<>
|
|
|
<div className="flex justify-center">
|
|
|
{Array.from({ length: 4 }).map((item, index) => {
|
|
|
return (
|
|
|
<>
|
|
|
- <div className={`relative h-[100%] ${type === 'page' ? styles.payPage : styles.payModal}`}>
|
|
|
- <div className="relative h-[0.89rem] flex justify-center font-bold">
|
|
|
- <span className="absolute z-50 top-[0.005rem] text-[white] leading-[]">5R</span>
|
|
|
+ <div
|
|
|
+ className={`relative h-[100%] ${type === "page" ? styles.payPage : styles.payModal}`}
|
|
|
+ >
|
|
|
+ <div className="relative flex h-[0.89rem] justify-center font-bold">
|
|
|
+ <span className="absolute top-[0.005rem] z-50 leading-[] text-[white]">
|
|
|
+ 5R
|
|
|
+ </span>
|
|
|
<img
|
|
|
src="/sign/box_pay/bg.png"
|
|
|
- className={"h-[100%] z-10"}
|
|
|
+ className={"z-10 h-[100%]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
<img
|
|
|
src="/sign/box_pay/bg2.png"
|
|
|
- className={"absolute h-[0.355rem] z-30 bottom-0"}
|
|
|
+ className={"absolute bottom-0 z-30 h-[0.355rem]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
<img
|
|
|
src="/sign/box_pay/gift.png"
|
|
|
- className={"absolute h-[0.505rem] z-20 top-[0.18rem]"}
|
|
|
+ className={"absolute top-[0.18rem] z-20 h-[0.505rem]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
<img
|
|
|
- id={'lock' + index}
|
|
|
+ id={"lock" + index}
|
|
|
src="/sign/box_pay/lock.png"
|
|
|
- className={"absolute h-[0.315rem] z-40 bottom-[0.17rem]"}
|
|
|
+ className={"absolute bottom-[0.17rem] z-40 h-[0.315rem]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
<img
|
|
|
- id={'opened' + index}
|
|
|
+ id={"opened" + index}
|
|
|
src="/sign/opened.png"
|
|
|
- className={"absolute h-[0.34rem] z-40 bottom-[0.3rem]"}
|
|
|
+ className={"absolute bottom-[0.3rem] z-40 h-[0.34rem]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
- <span className="absolute z-50 bottom-[0.005rem] text-[white]">50R</span>
|
|
|
+ <span className="absolute bottom-[0.005rem] z-50 text-[white]">
|
|
|
+ 50R
|
|
|
+ </span>
|
|
|
</div>
|
|
|
- <div className={`${styles.text} text-center font-bold text-[white]`}>
|
|
|
- <span>Day{index === 3 ? 10 + index * 5 + 5 : 10 + index * 5}</span>
|
|
|
+ <div
|
|
|
+ className={`${styles.text} text-center font-bold text-[white]`}
|
|
|
+ >
|
|
|
+ <span>
|
|
|
+ Day{index === 3 ? 10 + index * 5 + 5 : 10 + index * 5}
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</>
|
|
|
- )
|
|
|
+ );
|
|
|
})}
|
|
|
</div>
|
|
|
</>
|
|
|
- )
|
|
|
-}
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
const SignInModal = forwardRef(function SignInModal(props, ref) {
|
|
|
- const [visible, setVisible] = useState(false)
|
|
|
+ const [visible, setVisible] = useState(false);
|
|
|
+ const signData = useSignStore((state) => state.signData);
|
|
|
|
|
|
- const router = useRouter()
|
|
|
+ const totalData = signData.list;
|
|
|
+ const isSignNum = totalData?.reduce((pre, cur) => (cur.is_suss ? pre + 1 : pre), 0);
|
|
|
+ const router = useRouter();
|
|
|
|
|
|
- const boxRef = useRef(null)
|
|
|
+ const boxRef = useRef(null);
|
|
|
|
|
|
useImperativeHandle(ref, () => {
|
|
|
return {
|
|
|
onClose: () => setVisible(false),
|
|
|
- onOpen: () => setVisible(true)
|
|
|
+ onOpen: () => setVisible(true),
|
|
|
};
|
|
|
- })
|
|
|
+ });
|
|
|
return (
|
|
|
<>
|
|
|
<Mask visible={visible} destroyOnClose={true} onMaskClick={() => setVisible(false)}>
|
|
@@ -159,12 +196,12 @@ const SignInModal = forwardRef(function SignInModal(props, ref) {
|
|
|
<span className={"iconfont icon-guanbi"}></span>
|
|
|
</div>
|
|
|
<div className="absolute top-[5%] w-[100%]">
|
|
|
- <div className={"relative w-[100%] h-[6.25rem]"}>
|
|
|
- <div className={'h-[100%]'}>
|
|
|
- <div className="absolute h-[100%] w-[100%] overflow-hidden flex justify-center">
|
|
|
+ <div className={"relative h-[6.25rem] w-[100%]"}>
|
|
|
+ <div className={"h-[100%]"}>
|
|
|
+ <div className="absolute flex h-[100%] w-[100%] justify-center overflow-hidden">
|
|
|
<img
|
|
|
src="/sign/light2.png"
|
|
|
- className={"absolute h-[7.5rem] max-w-[none] top-[-1.215rem]"}
|
|
|
+ className={"absolute top-[-1.215rem] h-[7.5rem] max-w-[none]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
<img
|
|
@@ -174,38 +211,49 @@ const SignInModal = forwardRef(function SignInModal(props, ref) {
|
|
|
/>
|
|
|
</div>
|
|
|
{/* 主题背景图 */}
|
|
|
- <div className="relative flex justify-center h-[3rem] w-[100%]">
|
|
|
- <img
|
|
|
- src="/sign/theme.png"
|
|
|
- className={"absolute h-[100%]"}
|
|
|
- alt=""
|
|
|
- />
|
|
|
+ <div className="relative flex h-[3rem] w-[100%] justify-center">
|
|
|
+ <img src="/sign/theme.png" className={"absolute h-[100%]"} alt="" />
|
|
|
</div>
|
|
|
- <div className="absolute h-[3.95rem] top-[30%] w-[100%]">
|
|
|
- <div className="flex justify-center h-[100%]">
|
|
|
+ <div className="absolute top-[30%] h-[3.95rem] w-[100%]">
|
|
|
+ <div className="flex h-[100%] justify-center">
|
|
|
{/* 宽度自动填充适应活动背景图宽度 */}
|
|
|
<div className="relative h-[100%]">
|
|
|
<img
|
|
|
- src="/sign/bg2.png"
|
|
|
+ src={
|
|
|
+ signData.background_type === 1
|
|
|
+ ? "/sign/bg2.png"
|
|
|
+ : signData.Background
|
|
|
+ }
|
|
|
className={"h-[100%]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
{/* 右上角倒计时 */}
|
|
|
- <div className="absolute w-[20%] h-[0.3rem] right-[0.15rem] top-0 z-50 text-center text-[0.1rem] font-bold text-[white]">
|
|
|
- <p className={"h-[0.15rem]"}>CountDown</p>
|
|
|
- <p className={"text-[yellow] h-[0.15rem]"}>Day 20</p>
|
|
|
+ <div className="absolute right-[0.15rem] top-0 z-50 flex h-[0.3rem] w-[20%] items-center justify-center space-x-[2px] text-center text-[0.125rem] font-bold text-[white]">
|
|
|
+ {/*<p
|
|
|
+ className={"h-[0.15rem]"}>{totalData?.length}</p>*/}
|
|
|
+ {/*<p className={"h-[0.15rem] text-[yellow]"}>Day 20</p>*/}
|
|
|
+ <p className={"text-[yellow]"}>{isSignNum}</p>
|
|
|
+ <span>/</span>
|
|
|
+ <p>{totalData?.length}</p>
|
|
|
</div>
|
|
|
{/* 签到body */}
|
|
|
- <div className="absolute top-0 left-0 w-[100%]">
|
|
|
- <div className="relative w-[100%] mt-[0.51rem]">
|
|
|
+ <div className="absolute left-0 top-0 w-[100%]">
|
|
|
+ <div className="relative mt-[0.51rem] w-[100%]">
|
|
|
<BoxListCom num={15} ref={boxRef} />
|
|
|
- <div className="flex justify-center h-[0.62rem] mt-[0.25rem]" onClick={() => { router.push('/signIn') }}>
|
|
|
+ <div
|
|
|
+ className="mt-[0.25rem] flex h-[0.62rem] justify-center"
|
|
|
+ onClick={() => {
|
|
|
+ router.push("/signIn");
|
|
|
+ }}
|
|
|
+ >
|
|
|
<img
|
|
|
src="/sign/button_signed.png"
|
|
|
className={"h-[100%]"}
|
|
|
alt=""
|
|
|
/>
|
|
|
- <span className="absolute leading-[0.375rem] text-[0.16rem] font-bold">Sign-in</span>
|
|
|
+ <span className="absolute text-[0.16rem] font-bold leading-[0.375rem]">
|
|
|
+ Sign-in
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -217,7 +265,7 @@ const SignInModal = forwardRef(function SignInModal(props, ref) {
|
|
|
</div>
|
|
|
</Mask>
|
|
|
</>
|
|
|
- )
|
|
|
-})
|
|
|
+ );
|
|
|
+});
|
|
|
|
|
|
-export default memo(SignInModal)
|
|
|
+export default memo(SignInModal);
|