Browse Source

feat: bouns相关

year 2 tháng trước cách đây
mục cha
commit
b21d1ad8bd

+ 12 - 1
messages/br.json

@@ -177,7 +177,18 @@
         "gratis": "Grátis",
         "compensation": "Compensaçao",
 
-        "carteira": "TRANSFERIR PARA A CARTEIRA"
+        "carteira": "TRANSFERIR PARA A CARTEIRA",
+        "bounsTitle1": "Nenhum modo de recompensa",
+        "bonusDesc4": "No modo de recompensa após aabertura.",
+        "bonusDesc5": "Não pode ganhar nenhum bônus.",
+        "bonusDesc6": "Esvaziar os b'nus existentes e asnecessidades de missão.",
+        "boundsBtn": "Ouro de cor esvaziado",
+        "cancel": "cancelar",
+        "sure": "A certeza",
+        "clean": "Não ativar o modo de bônus?",
+        "switch": "Esvaziar o bônus ou não? ",
+        "bouns6001": "Condições não satisfeitas",
+        "bouns6002": "No Bouns está aberto, não é possível receber"
     },
     "DepositPage": {
         "Montante": "Montante",

+ 1 - 1
src/api/home.ts

@@ -323,7 +323,7 @@ export const getGlobalNoticeApi = () => {
 };
 
 export const getGlobalUserNoticeApi = () => {
-    return server.post<NoticeRep[], { summery: { unread: number; promotion_count: number } }>({
+    return server.post<NoticeRep[], { summery: { unread: number } }>({
         url: "/v1/api/front/notice_user_list",
         data: {},
     });

+ 18 - 0
src/api/user.ts

@@ -389,3 +389,21 @@ export const getUserDepositApi = () => {
         url: "/v1/api/user/user_deposit_latest",
     });
 };
+
+export const toggleUserBounsApi = (is_open: 1 | 0) => {
+    return server.post<any>({
+        url: "/v1/api/user/bonus/openNoBonus",
+        data: {
+            is_open,
+        },
+    });
+};
+
+export const cleanBounsApi = (is_clear: 0 | 1) => {
+    return server.post<any>({
+        url: "/v1/api/user/bonus/clearBonus",
+        data: {
+            is_clear,
+        },
+    });
+};

+ 85 - 2
src/components/ModalPopup/WalletDescribeModal/index.tsx

@@ -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" : ""}`}

+ 17 - 0
src/components/ModalPopup/WalletDescribeModal/style.scss

@@ -70,3 +70,20 @@
         }
     }
 }
+.customConfirm {
+    background-color: #373737 !important;
+    .adm-dialog-action-row {
+        flex-direction: row-reverse;
+        border-top: 0.5px solid #8f8f8f !important;
+        button {
+            color: #fff !important;
+            &:nth-child(1) {
+                border-right: none !important;
+                border-left: 0.5px solid #8f8f8f !important;
+                color: red !important;
+            }
+        }
+    }
+    .adm-dialog-footer {
+    }
+}

+ 0 - 1
src/utils/client/index.ts

@@ -17,7 +17,6 @@ const server = new Request({
             return config;
         },
         responseInterceptorCatch: async (err) => {
-            console.log(2233, err);
             const { response }: any = err;
             if (!response) return err;
             // if (response.status !== 200) return Promise.reject(response.message);