|
@@ -1,7 +1,8 @@
|
|
|
-import { Wallet } from "@/api/user";
|
|
|
+import { Wallet, cleanBounsApi, toggleUserBounsApi } from "@/api/user";
|
|
|
import { percentage } from "@/utils/methods";
|
|
|
-import { ProgressBar } from "antd-mobile";
|
|
|
+import { Dialog, ProgressBar, Switch, Toast } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
+import React from "react";
|
|
|
import "./style.scss";
|
|
|
|
|
|
const Progress = ({ percent, textColor = "#fff" }: { percent: number; textColor?: string }) => {
|
|
@@ -69,7 +70,57 @@ export const BalanceContent = (props: { wallet: Wallet }) => {
|
|
|
|
|
|
export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) => {
|
|
|
const { wallet, handleAcquire } = props;
|
|
|
+ const [switchValue, setSwitchValue] = React.useState<boolean>(false);
|
|
|
+ const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
+
|
|
|
+ const changeValue = async (value: boolean) => {
|
|
|
+ const confirmRes = await Dialog.confirm({
|
|
|
+ content: <div className="text-[#fff]">{t("switch")}</div>,
|
|
|
+ confirmText: t("sure"),
|
|
|
+ cancelText: t("cancel"),
|
|
|
+ bodyStyle: {
|
|
|
+ backgroundColor: "#373737",
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ bodyClassName: "customConfirm",
|
|
|
+ });
|
|
|
+ if (!confirmRes) return;
|
|
|
+ setIsLoading(true);
|
|
|
+ try {
|
|
|
+ const res = await toggleUserBounsApi(value ? 1 : 0);
|
|
|
+ if (!(res?.code && res?.data?.code === 0)) {
|
|
|
+ throw new Error("error");
|
|
|
+ }
|
|
|
+
|
|
|
+ setSwitchValue(value);
|
|
|
+ } finally {
|
|
|
+ setIsLoading(false);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const doHandle = async () => {
|
|
|
+ const confirmRes = await Dialog.confirm({
|
|
|
+ content: <div className="text-[#fff]">{t("clean")}</div>,
|
|
|
+ confirmText: t("sure"),
|
|
|
+ cancelText: t("cancel"),
|
|
|
+ bodyStyle: {
|
|
|
+ backgroundColor: "#373737",
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ bodyClassName: "customConfirm",
|
|
|
+ });
|
|
|
+ if (!confirmRes) return;
|
|
|
+ const res = await cleanBounsApi(1);
|
|
|
+ if (res?.code && [6001, 6002].includes(res?.data?.code)) {
|
|
|
+ const str = t(`bouns${res?.data?.code}`);
|
|
|
+ Toast.show({
|
|
|
+ content: str,
|
|
|
+ icon: "fail",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //toggleUserBounsApi
|
|
|
return (
|
|
|
<div>
|
|
|
<WalletContent
|
|
@@ -84,6 +135,38 @@ export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) =>
|
|
|
<li className="mt-[.06rem]">{t("bonusDesc2")}</li>
|
|
|
<li className="mt-[.06rem]">{t("bonusDesc3")}</li>
|
|
|
</ul>
|
|
|
+ <div className="mt-[.15rem] rounded-[8px] border-[1px] border-[#e540ff] bg-[#2f4cc8] shadow-[0_-10px_25px_#e641ff_inset]">
|
|
|
+ <div className="flex flex-row items-center justify-between border-b-[1px] border-[#e540ff] p-[8px]">
|
|
|
+ <span className="text-[#fff]">{t("bounsTitle1")}</span>
|
|
|
+ <Switch
|
|
|
+ loading={isLoading}
|
|
|
+ style={{
|
|
|
+ "--checked-color": "#a195d2",
|
|
|
+ "--height": "24px",
|
|
|
+ "--width": "48px",
|
|
|
+ }}
|
|
|
+ checked={switchValue}
|
|
|
+ onChange={changeValue}
|
|
|
+ ></Switch>
|
|
|
+ </div>
|
|
|
+ <ul
|
|
|
+ className={
|
|
|
+ "ml-[0.1389rem] list-decimal pl-[0.1rem] pt-[.1rem] text-[0.12rem] text-[#fff]"
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <li className="mt-[.06rem]">{t("bonusDesc4")}</li>
|
|
|
+ <li className="mt-[.06rem]">{t("bonusDesc5")}</li>
|
|
|
+ <li className="mt-[.06rem]">{t("bonusDesc6")}</li>
|
|
|
+ </ul>
|
|
|
+ <div className="mt-[.1rem] flex items-center justify-center pb-[.2rem]">
|
|
|
+ <a
|
|
|
+ onClick={doHandle}
|
|
|
+ className="rounded-[20px] border-[1px] border-[#46e3ff] bg-[#4234a8] px-[.1rem] py-[.06rem] text-[#00f6ff] shadow-[0_0_25px_#435cb9_inset]"
|
|
|
+ >
|
|
|
+ {t("boundsBtn")}
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
{handleAcquire && (
|
|
|
<a
|
|
|
className={`carteira-box ${wallet.is_point_transfer ? "active" : ""}`}
|