|
@@ -1,11 +1,12 @@
|
|
|
"use client";
|
|
|
import { DepositsTypes, RewardsType } from "@/api/depositsApi";
|
|
|
-import { getUserRechargeApi } from "@/api/user";
|
|
|
+import { getUserRechargeApi, getUserMoneyApi } from "@/api/user";
|
|
|
+import TipsModal, { ModalProps } from "@/components/TipsModal";
|
|
|
import Box from "@/components/Box";
|
|
|
import ButtonOwn from "@/components/ButtonOwn";
|
|
|
import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
import { neReg } from "@/utils";
|
|
|
-import { Form, Input, Toast } from "antd-mobile";
|
|
|
+import { Button, Form, Input, Toast } from "antd-mobile";
|
|
|
import { FormInstance } from "antd-mobile/es/components/form";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import { FC, Fragment, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -90,26 +91,41 @@ const DepositData: FC<Props> = (props) => {
|
|
|
|
|
|
const isStrictMode = true;
|
|
|
|
|
|
- const onFinish = (values: any) => {
|
|
|
+ const tipModelRef = useRef<ModalProps>(null); // 充值清空打码量弹窗
|
|
|
+ const [formData, setFormData] = useState<any>({}); // 存放表单数据
|
|
|
+ const onFinish = async (values: any) => {
|
|
|
const params = { ...values, channel_id: activeType.id, amount: +values.amount };
|
|
|
- getUserRechargeApi(params)
|
|
|
- .then(async (res) => {
|
|
|
- formInstanceRef.current?.resetFields();
|
|
|
- Toast.show({ icon: "success", content: t("code.200"), maskClickable: false });
|
|
|
- setAmount(undefined);
|
|
|
-
|
|
|
- if (res.data.pay_url) {
|
|
|
- window.open(res.data.pay_url);
|
|
|
- }
|
|
|
- const data = await getDepositApi();
|
|
|
- setDepositState(data);
|
|
|
- setActiveType(data[0]);
|
|
|
- await actions();
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- Toast.show({ content: t(`code${error.data.code}`), maskClickable: false });
|
|
|
- });
|
|
|
+ const res: any = await getUserMoneyApi()
|
|
|
+ if (res?.data?.tips_reset_rollover) {
|
|
|
+ tipModelRef.current?.onOpen();
|
|
|
+ setFormData(params)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ handleUserRecharge(false, params)
|
|
|
};
|
|
|
+
|
|
|
+ const handleUserRecharge = (is_reset_rollover: boolean, data?: any) => {
|
|
|
+ let params = data || formData
|
|
|
+ getUserRechargeApi({ is_reset_rollover, ...params})
|
|
|
+ .then(async (res) => {
|
|
|
+ formInstanceRef.current?.resetFields();
|
|
|
+ Toast.show({ icon: "success", content: t("code.200"), maskClickable: false });
|
|
|
+ tipModelRef.current?.onClose();
|
|
|
+ setAmount(undefined);
|
|
|
+
|
|
|
+ if (res.data.pay_url) {
|
|
|
+ window.open(res.data.pay_url);
|
|
|
+ }
|
|
|
+ const data = await getDepositApi();
|
|
|
+ setDepositState(data);
|
|
|
+ setActiveType(data[0]);
|
|
|
+ await actions();
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ Toast.show({ content: t(`code${error.data.code}`), maskClickable: false });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
const onValuesChange = (changeValues: any) => {
|
|
|
if (changeValues.amount) {
|
|
|
setAmount(changeValues.amount);
|
|
@@ -256,6 +272,35 @@ const DepositData: FC<Props> = (props) => {
|
|
|
{t("DepositPage.depositTips")}
|
|
|
</div>
|
|
|
</Box>
|
|
|
+ <TipsModal title={"Tips"} ref={tipModelRef}>
|
|
|
+ <div className={"flex items-center justify-between"}>
|
|
|
+ <h2 className={"text-[0.14rem]"}>Mantenha Bônus</h2>
|
|
|
+ <Button color={"primary"} className={"mx-auto"}
|
|
|
+ style={{
|
|
|
+ "--background-color": "var(--primary-color)",
|
|
|
+ "--border-color": "var(--primary-color)",
|
|
|
+ }}
|
|
|
+ onClick={() => handleUserRecharge(false)}
|
|
|
+ >
|
|
|
+ Depósito
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ <p className={"text-left text-[0.12rem] font-medium text-[#666] mt-[0.05rem]"}>Recarga direta, mantendo a carteira principal e informações de carteira de bônus;</p>
|
|
|
+ <b className={"mt-[0.2rem] mb-[0.2rem]"} style={{width: '100%',height: 'auto', borderTop: '1px solid #e5e5e5', display: 'block'}}></b>
|
|
|
+ <div className={"flex items-center justify-between"}>
|
|
|
+ <h2 className={"text-[0.14rem]"}>Esvaziem Bônus</h2>
|
|
|
+ <Button color={"primary"} className={"mx-auto"}
|
|
|
+ style={{
|
|
|
+ "--background-color": "var(--primary-color)",
|
|
|
+ "--border-color": "var(--primary-color)",
|
|
|
+ }}
|
|
|
+ onClick={() => handleUserRecharge(true)}
|
|
|
+ >
|
|
|
+ Depósito
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ <p className={"text-left text-[0.12rem] font-medium text-[#666] mt-[0.05rem]"}>Após a recarga, o saldo principal é mantido e todo o bônus é esvaziado, a nova carteira principal e a carteira de bônus são re-gravadas a quantidade de códigos jogados;</p>
|
|
|
+ </TipsModal>
|
|
|
</div>
|
|
|
);
|
|
|
};
|