|
@@ -1,14 +1,14 @@
|
|
|
"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 { getWheelApi } from "@/api/cashWheel";
|
|
|
-import { getGiveInfoApi } from "@/api/slots";
|
|
|
-import SignInModal, { SignInModalProps } from "@/components/ModalPopup/SignInModal";
|
|
|
import { useEventPoint } from "@/hooks/useEventPoint";
|
|
|
import { Link } from "@/i18n/routing";
|
|
|
import { useFirstPayStore } from "@/stores/useFirstPayStore";
|
|
@@ -20,7 +20,7 @@ import { useRequest } from "ahooks";
|
|
|
import { Badge } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import Image from "next/image";
|
|
|
-import { FC, useEffect, useRef } from "react";
|
|
|
+import { FC, useEffect, useRef, useState } from "react";
|
|
|
|
|
|
interface Props {
|
|
|
services: ServiceTypes[];
|
|
@@ -290,11 +290,23 @@ 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 SignInRef = useRef<SignInModalProps>(null);
|
|
|
+ const [activityId, setActivityId] = useState<number | null>(null);
|
|
|
|
|
|
const { getSignData, signData } = useSignStore((state) => {
|
|
|
return {
|
|
@@ -302,16 +314,34 @@ const SignInSection: FC = () => {
|
|
|
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 });
|
|
|
+ setTimeout(() => {
|
|
|
+ signInHandle();
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
- getSignData({ activity_id: 20 });
|
|
|
+ getUserInfo();
|
|
|
}, []);
|
|
|
|
|
|
const signInHandle = () => {
|
|
|
SignInRef.current?.onOpen();
|
|
|
};
|
|
|
+
|
|
|
+ if (!activityId) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
return (
|
|
|
<>
|
|
|
- <div
|
|
|
+ {/* <div
|
|
|
className={
|
|
|
"mt-[0.2778rem] flex h-[0.54rem] w-[0.54rem] items-center justify-center" +
|
|
|
" rounded-[50%]" +
|
|
@@ -320,7 +350,7 @@ const SignInSection: FC = () => {
|
|
|
onClick={signInHandle}
|
|
|
>
|
|
|
Sign
|
|
|
- </div>
|
|
|
+ </div> */}
|
|
|
<SignInModal ref={SignInRef}></SignInModal>
|
|
|
</>
|
|
|
);
|
|
@@ -365,7 +395,7 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
{/*客服*/}
|
|
|
<CustomerSection services={services} />
|
|
|
{/* 签到 */}
|
|
|
- {/* <SignInSection /> */}
|
|
|
+ <SignInSection />
|
|
|
</div>
|
|
|
|
|
|
<div
|