|
@@ -1,7 +1,8 @@
|
|
"use client";
|
|
"use client";
|
|
import { ServiceTypes } from "@/api/customservice";
|
|
import { ServiceTypes } from "@/api/customservice";
|
|
-import { lredPacketApi, redPacketApi } from "@/api/promo";
|
|
|
|
|
|
+import { getPaysApi, lredPacketApi, PayDataType, redPacketApi } from "@/api/promo";
|
|
import RedPacketModal, { RedPacketModalProps } from "@/components/Box/RedPacketModal";
|
|
import RedPacketModal, { RedPacketModalProps } from "@/components/Box/RedPacketModal";
|
|
|
|
+import UserRecharge, { ModalRefProps } from "@/components/Box/UserRecharge";
|
|
import { Link } from "@/i18n";
|
|
import { Link } from "@/i18n";
|
|
import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
|
|
import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
|
|
import { useSocialStore } from "@/stores/useSocials";
|
|
import { useSocialStore } from "@/stores/useSocials";
|
|
@@ -17,13 +18,14 @@ interface Props {
|
|
}
|
|
}
|
|
const ServiceWidget: FC<Props> = (props) => {
|
|
const ServiceWidget: FC<Props> = (props) => {
|
|
const token = getToken();
|
|
const token = getToken();
|
|
- // const [packets, setPackets] = useState<any[]>([]);
|
|
|
|
const { services, socials } = props;
|
|
const { services, socials } = props;
|
|
const defaultService = services.find((item) => item.is_suspend === 1);
|
|
const defaultService = services.find((item) => item.is_suspend === 1);
|
|
|
|
|
|
const newServices = services.filter((item) => item.is_suspend !== 1);
|
|
const newServices = services.filter((item) => item.is_suspend !== 1);
|
|
const setSocials = useSocialStore((state) => state.setSocials);
|
|
const setSocials = useSocialStore((state) => state.setSocials);
|
|
const RedPacketModalRef = useRef<RedPacketModalProps>(null);
|
|
const RedPacketModalRef = useRef<RedPacketModalProps>(null);
|
|
|
|
+
|
|
|
|
+ const userRechargeRef = useRef<ModalRefProps>(null);
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
// 数据存储,侧边栏使用
|
|
// 数据存储,侧边栏使用
|
|
setSocials(socials);
|
|
setSocials(socials);
|
|
@@ -61,11 +63,39 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
pollingWhenHidden: false,
|
|
pollingWhenHidden: false,
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // 首充活动
|
|
|
|
+
|
|
|
|
+ const getPayInfo = async () => {
|
|
|
|
+ if (token) {
|
|
|
|
+ return getPaysApi();
|
|
|
|
+ }
|
|
|
|
+ return Promise.resolve({});
|
|
|
|
+ };
|
|
|
|
+ const { data: paysInfo } = useRequest<PayDataType, any>(getPayInfo, {
|
|
|
|
+ pollingErrorRetryCount: 1,
|
|
|
|
+ pollingWhenHidden: false,
|
|
|
|
+ });
|
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in Service.tsx on 69`, paysInfo);
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<>
|
|
<>
|
|
<div
|
|
<div
|
|
className={`absolute bottom-[0.84rem] right-[0.12rem] z-50 flex w-[100px] flex-col items-center justify-center`}
|
|
className={`absolute bottom-[0.84rem] right-[0.12rem] z-50 flex w-[100px] flex-col items-center justify-center`}
|
|
>
|
|
>
|
|
|
|
+ {/*首充*/}
|
|
|
|
+ {paysInfo?.first_pay?.map((item, index) => {
|
|
|
|
+ return (
|
|
|
|
+ <div key={index} className={`mb-[0.0694rem] cursor-pointer`}>
|
|
|
|
+ <img
|
|
|
|
+ className={"h-[0.3889rem] w-[0.3889rem]"}
|
|
|
|
+ src="/hby/red-icon.png"
|
|
|
|
+ onClick={() => {
|
|
|
|
+ userRechargeRef.current?.onOpen(paysInfo.first_pay, index);
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ );
|
|
|
|
+ })}
|
|
{/* 红包雨icon */}
|
|
{/* 红包雨icon */}
|
|
{packets?.map((item, index) => {
|
|
{packets?.map((item, index) => {
|
|
return (
|
|
return (
|
|
@@ -115,6 +145,7 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<RedPacketModal ref={RedPacketModalRef} onAfterHandler={run} />
|
|
<RedPacketModal ref={RedPacketModalRef} onAfterHandler={run} />
|
|
|
|
+ <UserRecharge ref={userRechargeRef} />
|
|
|
|
|
|
<div className={`grid grid-cols-${newServices.length >= 5 ? 5 : newServices.length}`}>
|
|
<div className={`grid grid-cols-${newServices.length >= 5 ? 5 : newServices.length}`}>
|
|
{newServices.map((service, index) => {
|
|
{newServices.map((service, index) => {
|