|
@@ -1,29 +1,22 @@
|
|
|
"use client";
|
|
|
import { getWheelApi } from "@/api/cashWheel";
|
|
|
import { ServiceTypes } from "@/api/customservice";
|
|
|
-import { userInfoApi } from "@/api/login";
|
|
|
import { lredPacketApi, redPacketApi } from "@/api/promo";
|
|
|
import { getGiveInfoApi } from "@/api/slots";
|
|
|
import UserRecharge, { ModalRefProps, Timeout } from "@/components/ModalPopup/RechargeModal";
|
|
|
import RedPacketModal, { RedPacketModalProps } from "@/components/ModalPopup/RedPacketModal";
|
|
|
-import SignInModal, { SignInModalProps } from "@/components/ModalPopup/SignInModal";
|
|
|
import SlotsModal, { SlotModalRefProps } from "@/components/ModalPopup/SlotsModal";
|
|
|
-import WheelModal, { WheelModalProps } from "@/components/ModalPopup/WheelModal";
|
|
|
import { useEventPoint } from "@/hooks/useEventPoint";
|
|
|
import { Link } from "@/i18n/routing";
|
|
|
-import { useModalShow } from "@/stores/modalShow";
|
|
|
import { useFirstPayStore } from "@/stores/useFirstPayStore";
|
|
|
import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
|
|
|
-import { useSignStore } from "@/stores/useSignStore";
|
|
|
import useWheelStore from "@/stores/useWheelStore";
|
|
|
import { getToken } from "@/utils/Cookies";
|
|
|
import { useRequest } from "ahooks";
|
|
|
import { Badge } from "antd-mobile";
|
|
|
-import dayjs from "dayjs";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import Image from "next/image";
|
|
|
-import { usePathname } from "next/navigation";
|
|
|
-import { FC, useEffect, useMemo, useRef, useState } from "react";
|
|
|
+import { FC, useEffect, useRef, useState } from "react";
|
|
|
|
|
|
interface Props {
|
|
|
services: ServiceTypes[];
|
|
@@ -80,49 +73,9 @@ const SlotSection: FC<SlotSectionProps> = ({ onDestory }) => {
|
|
|
* 轮盘
|
|
|
*/
|
|
|
const WheelSection = () => {
|
|
|
- const pathname = usePathname();
|
|
|
- const wheelModalRef = useRef<WheelModalProps | null>(null);
|
|
|
- const [data, setData] = useState<any>([]);
|
|
|
- const { modalShow, closeModalShow, setModalShow } = useModalShow((state: any) => ({
|
|
|
- modalShow: state.modalShow,
|
|
|
- closeModalShow: state.closeModalShow,
|
|
|
- setModalShow: state.setModalShow,
|
|
|
- }));
|
|
|
- const keyName = useMemo(() => {
|
|
|
- return "WheelSection";
|
|
|
- }, []);
|
|
|
- const { wheelStatus, wheelCurrent, setWheel } = useWheelStore((state) => ({
|
|
|
+ const { wheelStatus } = useWheelStore((state) => ({
|
|
|
wheelStatus: state.status,
|
|
|
- wheelCurrent: state.currentWheel,
|
|
|
- setWheel: state.setWheel,
|
|
|
}));
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- setWheel().then((data) => {
|
|
|
- if (data && useWheelStore.getState().status === 1) {
|
|
|
- setData(data);
|
|
|
- }
|
|
|
- });
|
|
|
- }, []);
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- if (!data) return;
|
|
|
- if (modalShow === keyName) {
|
|
|
- wheelModalRef.current?.onOpen(data);
|
|
|
- }
|
|
|
- }, [modalShow, data, keyName, pathname]);
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- setModalShow("WheelSection");
|
|
|
- // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
- }, [pathname]);
|
|
|
-
|
|
|
- const destoryComponent = () => {
|
|
|
- if (modalShow === keyName) {
|
|
|
- closeModalShow(keyName);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
return (
|
|
|
<>
|
|
|
{wheelStatus === 2 ? (
|
|
@@ -138,7 +91,6 @@ const WheelSection = () => {
|
|
|
) : null}
|
|
|
|
|
|
{/* 轮盘弹窗 */}
|
|
|
- <WheelModal ref={wheelModalRef} onDestory={destoryComponent} />
|
|
|
</>
|
|
|
);
|
|
|
};
|
|
@@ -320,100 +272,6 @@ const CustomerSection: FC<Omit<Props, "socials">> = (props) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-const getMaxSignId = (obj: any) => {
|
|
|
- if (!obj) return null;
|
|
|
- const signArr: number[] = [];
|
|
|
- Object.keys(obj).map((key) => {
|
|
|
- if (obj[key] === 9) {
|
|
|
- signArr.push(Number(key));
|
|
|
- }
|
|
|
- });
|
|
|
- return signArr.length > 0 ? Math.max(...signArr) : null;
|
|
|
-};
|
|
|
-
|
|
|
-/**
|
|
|
- * 签到活动
|
|
|
- */
|
|
|
-const SignInSection: FC = () => {
|
|
|
- const { modalShow, closeModalShow } = useModalShow((state: any) => ({
|
|
|
- modalShow: state.modalShow,
|
|
|
- closeModalShow: state.closeModalShow,
|
|
|
- }));
|
|
|
- const SignInRef = useRef<SignInModalProps>(null);
|
|
|
- const [activityId, setActivityId] = useState<number | null>(null);
|
|
|
- const keyName = "SignInSection";
|
|
|
- const { getSignData, signData } = useSignStore((state) => {
|
|
|
- return {
|
|
|
- getSignData: state.getSignData,
|
|
|
- signData: state.signData,
|
|
|
- };
|
|
|
- });
|
|
|
- const getUserInfo = async () => {
|
|
|
- const res: any = await userInfoApi();
|
|
|
- if (res.code === 200 && res.data?.activity) {
|
|
|
- const activity_id = getMaxSignId(res.data?.activity);
|
|
|
- if (activity_id) {
|
|
|
- setActivityId(activity_id);
|
|
|
- await getSignData({ activity_id: activity_id });
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- const checkIsShowed = () => {
|
|
|
- const showTime = localStorage.getItem("sign");
|
|
|
- if (showTime) {
|
|
|
- const nextDay = dayjs(Number(showTime)).add(1, "day").format("YYYY-MM-DD");
|
|
|
- if (dayjs(nextDay).isAfter(dayjs())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- };
|
|
|
- useEffect(() => {
|
|
|
- // if (checkIsShowed()) return;
|
|
|
- if (getToken()) getUserInfo();
|
|
|
- // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
- }, []);
|
|
|
-
|
|
|
- const destoryComponent = () => {
|
|
|
- closeModalShow(keyName);
|
|
|
- };
|
|
|
- useEffect(() => {
|
|
|
- console.log(modalShow, modalShow === keyName, getToken());
|
|
|
- if (modalShow === keyName && getToken()) {
|
|
|
- if (checkIsShowed()) {
|
|
|
- destoryComponent();
|
|
|
- } else {
|
|
|
- localStorage.setItem("sign", `${Date.now()}`);
|
|
|
- signInHandle();
|
|
|
- }
|
|
|
- }
|
|
|
- // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
- }, [modalShow, keyName]);
|
|
|
-
|
|
|
- const signInHandle = () => {
|
|
|
- SignInRef.current?.onOpen();
|
|
|
- };
|
|
|
-
|
|
|
- if (!activityId) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return (
|
|
|
- <>
|
|
|
- {/* <div
|
|
|
- className={
|
|
|
- "mt-[0.2778rem] flex h-[0.54rem] w-[0.54rem] items-center justify-center" +
|
|
|
- " rounded-[50%]" +
|
|
|
- " bg-gradient-to-t from-[#ff611b] to-[#ffcf35]"
|
|
|
- }
|
|
|
- onClick={signInHandle}
|
|
|
- >
|
|
|
- Sign
|
|
|
- </div> */}
|
|
|
- <SignInModal ref={SignInRef} onDestory={destoryComponent}></SignInModal>
|
|
|
- </>
|
|
|
- );
|
|
|
-};
|
|
|
-
|
|
|
const ServiceWidget: FC<Props> = (props) => {
|
|
|
const { services } = props;
|
|
|
const [type, setType] = useState<number>(0);
|
|
@@ -437,62 +295,6 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
|
|
|
const t = useTranslations("HomePage");
|
|
|
|
|
|
- // const servicesMap = new Map<number, any>([
|
|
|
- // [
|
|
|
- // 0,
|
|
|
- // {
|
|
|
- // components: <SlotSection />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // [
|
|
|
- // 1,
|
|
|
- // {
|
|
|
- // components: <WheelSection />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // [
|
|
|
- // 2,
|
|
|
- // {
|
|
|
- // components: <PaySection />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // [
|
|
|
- // 3,
|
|
|
- // {
|
|
|
- // components: <RedPacketSection />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // [
|
|
|
- // 4,
|
|
|
- // {
|
|
|
- // components: <MessageSection />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // [
|
|
|
- // 5,
|
|
|
- // {
|
|
|
- // components: <CustomerSection services={services} />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // [
|
|
|
- // 6,
|
|
|
- // {
|
|
|
- // components: <SignInSection />,
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // ]);
|
|
|
-
|
|
|
- // const curComponents = useMemo(() => {
|
|
|
- // return servicesMap.get(type)?.components;
|
|
|
- // // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
- // }, [type, services, servicesMap]);
|
|
|
-
|
|
|
- // const modalDestory = () => {
|
|
|
- // setType(type + 1);
|
|
|
- // };
|
|
|
-
|
|
|
- // console.log("type:", type);
|
|
|
-
|
|
|
return (
|
|
|
<>
|
|
|
<div
|
|
@@ -511,7 +313,7 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
{/*客服*/}
|
|
|
<CustomerSection services={services} />
|
|
|
{/* 签到 */}
|
|
|
- <SignInSection />
|
|
|
+ {/* <SignInSection /> */}
|
|
|
</div>
|
|
|
|
|
|
<div
|