浏览代码

fix: 更新惠充

Before 8 月之前
父节点
当前提交
bc62cfb96c

+ 1 - 1
src/api/promo.ts

@@ -135,7 +135,7 @@ export interface PayCondition {
     /**
      * 参加金额
      */
-    amount: string;
+    amount: number;
     /**
      * 奖励代币类型1现金2彩金3免费币4重玩币
      */

+ 25 - 27
src/app/[locale]/(navbar)/doings/discount/DepositData.tsx

@@ -1,32 +1,33 @@
 "use client";
-import { DepositsTypes } from "@/api/depositsApi";
+import { Pay } from "@/api/promo";
 import { getUserRechargeApi } from "@/api/user";
 import Box from "@/components/Box";
+import ButtonOwn from "@/components/ButtonOwn";
 import { useUserInfoStore } from "@/stores/useUserInfoStore";
+import "@/styles/deposit.scss";
 import { neReg } from "@/utils";
 import { Form, Input, Toast } from "antd-mobile";
 import { FormInstance } from "antd-mobile/es/components/form";
 import { useTranslations } from "next-intl";
-import { FC, Fragment, useRef, useState } from "react";
-
-import ButtonOwn from "@/components/ButtonOwn";
-import "@/styles/deposit.scss";
 import Image from "next/image";
+import { FC, Fragment, useRef, useState } from "react";
 interface Props {
-    deposits: DepositsTypes[];
+    deposits: Pay[];
 }
 const DepositData: FC<Props> = (props) => {
     const { deposits } = props;
+    console.log(`🚀🚀🚀🚀🚀-> in DepositData.tsx on 19`, deposits);
     const t = useTranslations();
     const userInfo = useUserInfoStore((state) => state.userInfo);
 
-    const count = 2;
     // 选中类型
-    const [activeType, setActiveType] = useState<DepositsTypes>(deposits[0]);
+    const [activeType, setActiveType] = useState<Pay>(deposits[0]);
+
+    const count = activeType.num === 0 ? "MAX" : activeType.num;
 
     const formInstanceRef = useRef<FormInstance>(null);
     let [amount, setAmount] = useState<number | undefined>(undefined);
-    const titleChangeHandler = (item: DepositsTypes, index: number) => {
+    const titleChangeHandler = (item: Pay, index: number) => {
         setAmount(undefined);
         setActiveType(item);
         formInstanceRef.current?.resetFields();
@@ -50,8 +51,9 @@ const DepositData: FC<Props> = (props) => {
             });
     };
     const onValuesChange = (changeValues: any) => {
+        console.log(`🚀🚀🚀🚀🚀-> in DepositData.tsx on 53`, changeValues);
         if (changeValues.amount) {
-            setAmount(changeValues.amount);
+            setAmount(+changeValues.amount);
         }
     };
     const amountChange = (value: number) => {
@@ -59,15 +61,15 @@ const DepositData: FC<Props> = (props) => {
         setAmount(value);
     };
     const amountValidator = (rules: any, value: any) => {
-        if (!value) return Promise.reject(new Error(t("form.amount")));
-        if (+value < activeType.min_amount)
-            return Promise.reject(
-                new Error(t("form.amountMinReg", { amount: activeType.min_amount }))
-            );
-        if (+value > activeType.max_amount)
-            return Promise.reject(
-                new Error(t("form.amountMaxReg", { amount: activeType.max_amount }))
-            );
+        // if (!value) return Promise.reject(new Error(t("form.amount")));
+        // if (+value < activeType.min_amount)
+        //     return Promise.reject(
+        //         new Error(t("form.amountMinReg", { amount: activeType.min_amount }))
+        //     );
+        // if (+value > activeType.max_amount)
+        //     return Promise.reject(
+        //         new Error(t("form.amountMaxReg", { amount: activeType.max_amount }))
+        //     );
         return Promise.resolve();
     };
 
@@ -153,23 +155,19 @@ const DepositData: FC<Props> = (props) => {
                             label=""
                             rules={[{ required: true, type: "number", validator: amountValidator }]}
                         >
-                            <Input
-                                placeholder={`${t("DepositPage.Montante")}(BRL): Mín. ${activeType.min_amount}`}
-                                type={"number"}
-                                maxLength={activeType.max_amount}
-                            />
+                            <Input placeholder={t("DepositPage.Montante")} type={"number"} />
                         </Form.Item>
 
                         <div className={"flex flex-col"}>
                             <div className={"flex-1"}>
                                 <ul className="ul-box">
-                                    {activeType.products.map((item, index) => (
+                                    {activeType.condition.map((item, index) => (
                                         <li
-                                            className={amount == item.amount ? "active" : ""}
+                                            className={amount === item.amount ? "active" : ""}
                                             key={index}
                                             onClick={() => amountChange(item.amount)}
                                         >
-                                            {!!item.badge && <span className="hot"></span>}
+                                            {/*{!!item.badge && <span className="hot"></span>}*/}
                                             <div className="amountContent">
                                                 {/* <span className="iconfont icon-unit-brl"></span> */}
                                                 <span className="iconfont">R$</span>

+ 10 - 7
src/app/[locale]/(navbar)/doings/discount/page.tsx

@@ -1,25 +1,28 @@
-import { DepositsTypes } from "@/api/depositsApi";
+import { PayDataType } from "@/api/promo";
 import Empty from "@/components/Empty";
 import { server } from "@/utils/server";
 import DepositData from "./DepositData";
-
 const getDepositApi = async () => {
     return server
-        .request<DepositsTypes[]>({
-            url: "/v1/api/user/user_deposit_config",
+        .request<PayDataType>({
+            url: "/v1/api/front/activity/pay",
             method: "post",
         })
         .then((res) => {
             if (res.code === 200) return res.data;
-            return [];
+            return {
+                first_pay: [],
+                pay: [],
+            };
         });
 };
 const Deposit = async () => {
     const deposits = await getDepositApi();
-    if (!deposits.length) return <Empty />;
+    console.log(`🚀🚀🚀🚀🚀-> in page.tsx on 22`, deposits);
+    if (!deposits.pay.length) return <Empty />;
     return (
         <>
-            <DepositData deposits={deposits} />
+            <DepositData deposits={deposits.pay} />
         </>
     );
 };