|
@@ -2,7 +2,7 @@
|
|
|
import { ServiceTypes } from "@/api/customservice";
|
|
|
import { getPaysApi, lredPacketApi, PayDataType, redPacketApi } from "@/api/promo";
|
|
|
import RedPacketModal, { RedPacketModalProps } from "@/components/Box/RedPacketModal";
|
|
|
-import UserRecharge, { ModalRefProps } from "@/components/Box/UserRecharge";
|
|
|
+import UserRecharge, { ModalRefProps, Timeout } from "@/components/Box/UserRecharge";
|
|
|
import { Link } from "@/i18n";
|
|
|
import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
|
|
|
import { useSocialStore } from "@/stores/useSocials";
|
|
@@ -16,6 +16,7 @@ interface Props {
|
|
|
services: ServiceTypes[];
|
|
|
socials: ServiceTypes[];
|
|
|
}
|
|
|
+
|
|
|
const ServiceWidget: FC<Props> = (props) => {
|
|
|
const token = getToken();
|
|
|
const { services, socials } = props;
|
|
@@ -23,9 +24,11 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
|
|
|
const newServices = services.filter((item) => item.is_suspend !== 1);
|
|
|
const setSocials = useSocialStore((state) => state.setSocials);
|
|
|
- const RedPacketModalRef = useRef<RedPacketModalProps>(null);
|
|
|
+ const redPacketModalRef = useRef<RedPacketModalProps>(null);
|
|
|
+
|
|
|
+ /// 首充活动ref
|
|
|
+ const userRechargeRef = useRef<ModalRefProps | null>(null);
|
|
|
|
|
|
- const userRechargeRef = useRef<ModalRefProps>(null);
|
|
|
useEffect(() => {
|
|
|
// 数据存储,侧边栏使用
|
|
|
setSocials(socials);
|
|
@@ -64,19 +67,25 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
});
|
|
|
|
|
|
// 首充活动
|
|
|
-
|
|
|
- const getPayInfo = async () => {
|
|
|
- if (token) {
|
|
|
- return getPaysApi();
|
|
|
+ const getPayInfo = async (): Promise<PayDataType> => {
|
|
|
+ try {
|
|
|
+ if (token) {
|
|
|
+ const result = await getPaysApi();
|
|
|
+ return result.data;
|
|
|
+ } else {
|
|
|
+ return Promise.reject("not login");
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ return Promise.resolve({
|
|
|
+ first_pay: [],
|
|
|
+ pay: [],
|
|
|
+ });
|
|
|
}
|
|
|
- return Promise.resolve({});
|
|
|
};
|
|
|
const { data: paysInfo } = useRequest<PayDataType, any>(getPayInfo, {
|
|
|
pollingErrorRetryCount: 1,
|
|
|
pollingWhenHidden: false,
|
|
|
});
|
|
|
- console.log(`🚀🚀🚀🚀🚀-> in Service.tsx on 69`, paysInfo);
|
|
|
-
|
|
|
return (
|
|
|
<>
|
|
|
<div
|
|
@@ -85,14 +94,26 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
{/*首充*/}
|
|
|
{paysInfo?.first_pay?.map((item, index) => {
|
|
|
return (
|
|
|
- <div key={index} className={`mb-[0.0694rem] cursor-pointer`}>
|
|
|
+ <div
|
|
|
+ key={index}
|
|
|
+ className={`mb-[0.0694rem] flex cursor-pointer flex-col items-center`}
|
|
|
+ >
|
|
|
<img
|
|
|
- className={"h-[0.3889rem] w-[0.3889rem]"}
|
|
|
- src="/hby/red-icon.png"
|
|
|
+ className={"w-[0.4889rem]"}
|
|
|
+ src="/hby/recharge.png"
|
|
|
onClick={() => {
|
|
|
+ // @ts-ignore
|
|
|
userRechargeRef.current?.onOpen(paysInfo.first_pay, index);
|
|
|
}}
|
|
|
/>
|
|
|
+ {item.end_time > 0 ? (
|
|
|
+ <Timeout
|
|
|
+ className={
|
|
|
+ "bg-[#ffa800] text-[0.08rem] text-[#fff] shadow-[0_0_3px_0.03rem_#ffa800]"
|
|
|
+ }
|
|
|
+ endTime={item.end_time}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
</div>
|
|
|
);
|
|
|
})}
|
|
@@ -104,7 +125,7 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
className={"h-[0.3889rem] w-[0.3889rem]"}
|
|
|
src="/hby/red-icon.gif"
|
|
|
onClick={() => {
|
|
|
- RedPacketModalRef.current?.onOpen(packets, index);
|
|
|
+ redPacketModalRef.current?.onOpen(packets, index);
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
@@ -144,7 +165,8 @@ const ServiceWidget: FC<Props> = (props) => {
|
|
|
)}
|
|
|
</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}`}>
|