|
@@ -5,10 +5,12 @@ import HeaderBack from "@/components/HeaderBack";
|
|
|
import VipProgress from "@/components/VipProgress";
|
|
|
import feedback from "@/feedback";
|
|
|
import useCountdown from "@/hooks/useCountdown";
|
|
|
+import { useRouter } from "@/i18n/routing";
|
|
|
import { formatAmount } from "@/utils";
|
|
|
import { useRequest } from "ahooks";
|
|
|
import { Toast } from "antd-mobile";
|
|
|
import clsx from "clsx";
|
|
|
+import dayjs from "dayjs";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import React from "react";
|
|
|
import List from "./List";
|
|
@@ -57,6 +59,7 @@ const Page = () => {
|
|
|
const containerRef = React.useRef<HTMLDivElement | null>(null);
|
|
|
const curReward = React.useRef<RewardItemData | any>(null);
|
|
|
const t = useTranslations();
|
|
|
+ const router = useRouter();
|
|
|
|
|
|
const { data: userVip, run: runVip } = useRequest<any, any>(getNewVip, {
|
|
|
pollingErrorRetryCount: 1,
|
|
@@ -161,11 +164,19 @@ const Page = () => {
|
|
|
return result;
|
|
|
}, [vipInfo, actVipInfo]);
|
|
|
|
|
|
- const multClick = (dialogProps: any) => {
|
|
|
- console.log(dialogProps);
|
|
|
+ const multClick = async (data: any) => {
|
|
|
+ if (!curReward.current) return;
|
|
|
+ if ((curReward.current?.cur_pay || 0) < (curReward.current?.double_pay || 0)) {
|
|
|
+ router.replace("/deposit");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ data.doClose("confirm");
|
|
|
+ };
|
|
|
+ const doSingleClaim = async (data: any) => {
|
|
|
+ data.doClose("confirm");
|
|
|
};
|
|
|
|
|
|
- const multRender = (dialogProps: any) => {
|
|
|
+ const confirmRender = (contentProps: any) => {
|
|
|
return (
|
|
|
<div className="relative">
|
|
|
<div className="mb-[.1rem] text-center text-[.12rem] text-[var(--textColor1)]">
|
|
@@ -193,7 +204,7 @@ const Page = () => {
|
|
|
);
|
|
|
})}
|
|
|
<CustomButton
|
|
|
- onClick={doRealClaim}
|
|
|
+ onClick={() => doSingleClaim({ ...contentProps })}
|
|
|
disabled={
|
|
|
(curReward.current?.cur_pay || 0) >=
|
|
|
(curReward.current?.double_pay || 0)
|
|
@@ -226,7 +237,7 @@ const Page = () => {
|
|
|
);
|
|
|
})}
|
|
|
<CustomButton
|
|
|
- onClick={() => multClick(dialogProps)}
|
|
|
+ onClick={() => multClick({ ...contentProps })}
|
|
|
className="!min-w-[120px] !px-[12px] !py-[6px] !text-[12px]"
|
|
|
>
|
|
|
{(curReward.current?.cur_pay || 0) >=
|
|
@@ -258,21 +269,35 @@ const Page = () => {
|
|
|
|
|
|
const doClaim = async (rewardData: RewardItemData) => {
|
|
|
curReward.current = rewardData;
|
|
|
- const res = await feedback.showModal({
|
|
|
- content: multRender,
|
|
|
- width: "80%",
|
|
|
- useDefaultFooter: false,
|
|
|
- });
|
|
|
+ if (rewardData.status !== 1) return;
|
|
|
+
|
|
|
+ if (renderType1.includes(rewardData.type) && rewardData.double_pay > 0) {
|
|
|
+ const isCanClaim =
|
|
|
+ dayjs().isAfter(rewardData.start_time * 1000) &&
|
|
|
+ dayjs().isBefore(rewardData.end_time * 1000);
|
|
|
+ if (!isCanClaim) return;
|
|
|
+ const res = await feedback.showModal({
|
|
|
+ content: confirmRender,
|
|
|
+ width: "80%",
|
|
|
+ useDefaultFooter: false,
|
|
|
+ });
|
|
|
+ if (res.cancel) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ doRealClaim();
|
|
|
};
|
|
|
|
|
|
const doRealClaim = async () => {
|
|
|
if (!curReward.current) return;
|
|
|
try {
|
|
|
+ Toast.show({
|
|
|
+ icon: "loading",
|
|
|
+ });
|
|
|
const res = await claimVip({ type: curReward.current?.type });
|
|
|
if (res.code === 200) {
|
|
|
runVip();
|
|
|
Toast.show(t(`code.200`));
|
|
|
-
|
|
|
return;
|
|
|
}
|
|
|
throw new Error(`${res?.code || 400}`);
|
|
@@ -481,7 +506,7 @@ const Page = () => {
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <List></List>
|
|
|
+ <List data={vipInfo?.level_info} level={vipInfo?.vip_level}></List>
|
|
|
|
|
|
{/* <Top data={userVip} cashbackInfo={cashbackInfo}></Top>
|
|
|
<RewardBox data={userVip} cashbackInfo={cashbackInfo}></RewardBox>
|