瀏覽代碼

feat: 修改逻辑

year 2 月之前
父節點
當前提交
baee799fea

+ 19 - 1
src/api/depositsApi.ts

@@ -112,6 +112,7 @@ export interface ShopProductItem {
     pay_reward: ShopPayRewardItem[];
     activity_reward: ShopActivityRewardItem[];
     style: 1 | 2 | 3;
+    type: 1 | 2;
 }
 
 export interface ShopInfo {
@@ -119,7 +120,7 @@ export interface ShopInfo {
     renter_id: number;
     has_pay: boolean;
     num: number;
-    type: 1 | 2;
+    shop_type: 1 | 2 | 3 | 4;
     products: ShopProductItem[];
     condition: {
         min: number;
@@ -153,3 +154,20 @@ export const doClaimShopApi = (data: { id: number }) => {
         data,
     });
 };
+
+export interface ShopClaimRecordItem {
+    claim_time: number;
+    list: {
+        item_id: number;
+        amount: number;
+        rollover: number;
+    }[];
+}
+
+export const getClaimRecordApi = (data: { shop_id: number }) => {
+    return server.request<ShopClaimRecordItem[]>({
+        url: "/v1/api/user/shop/getShopClaimDetail",
+        method: "POST",
+        data,
+    });
+};

+ 39 - 24
src/app/[locale]/(TabBar)/deposit/DepositData.tsx

@@ -1,8 +1,9 @@
 "use client";
-import { DepositsTypes, PayChannel, ShopInfo } from "@/api/depositsApi";
+import { DepositsTypes, PayChannel, ShopInfo, ShopProductItem } from "@/api/depositsApi";
 import { getUserMoneyApi, getUserRechargeApi } from "@/api/user";
 import Box from "@/components/Box";
 import ButtonOwn from "@/components/ButtonOwn";
+import Empty from "@/components/Empty";
 import TipsModal, { ModalProps } from "@/components/TipsModal";
 import { useEventPoint } from "@/hooks/useEventPoint";
 import { useSystemStore } from "@/stores/useSystemStore";
@@ -14,7 +15,7 @@ import { Button, Form, Input, Toast } from "antd-mobile";
 import { FormInstance } from "antd-mobile/es/components/form";
 import clsx from "clsx";
 import { useTranslations } from "next-intl";
-import { FC, useRef, useState } from "react";
+import { FC, useEffect, useMemo, useRef, useState } from "react";
 import { Swiper, SwiperSlide } from "swiper/react";
 import actions from "./actions";
 import Reward from "./Reward";
@@ -46,6 +47,8 @@ const DepositData: FC<Props> = (props) => {
     // const router = useRouter();
     const userInfo = useUserInfoStore((state) => state.userInfo);
     const [currentProduct, setCurrentProduct] = useState<any>(null);
+    const [btns, setBtns] = useState<ShopProductItem[]>([]);
+    const [formInput, setFormInput] = useState<ShopProductItem | null>(null);
     const { eventInitiate } = useEventPoint();
 
     const isStrictMode = useSystemStore((state) => state.identity_verify.deposit === 1);
@@ -53,37 +56,37 @@ const DepositData: FC<Props> = (props) => {
     const formInstanceRef = useRef<FormInstance>(null);
     let [amount, setAmount] = useState<number | undefined>(undefined);
 
-    // useEffect(() => {
-    //     if (props.onActiveChange) {
-    //         props.onActiveChange(activeType as DepositsTypes);
-    //     }
-    // }, [activeType]);
-
     const titleChangeHandler = (data: PayChannel) => {
         setAmount(undefined);
         if (typeof setChannel === "function") setChannel(data);
         formInstanceRef.current?.resetFields();
     };
 
-    // const currentProduct = useMemo(() => {
-    //     if (!shopInfo?.products?.length) return null;
-    //     let result = shopInfo?.products?.find((item) => item.par_value === amount);
-    //     console.log(result);
-    //     if (!result) {
-    //         result = shopInfo?.products?.find((item) => item.par_value === 0);
-    //     }
-    //     return result;
-    // }, [shopInfo?.products, amount]);
-
     const tipModelRef = useRef<ModalProps>(null); // 充值清空打码量弹窗
     const [formData, setFormData] = useState<any>({}); // 存放表单数据
 
+    useEffect(() => {
+        if (shopInfo?.products?.length) {
+            const normalProduct: ShopProductItem[] = [];
+            let formProduct = null;
+            shopInfo?.products.forEach((item) => {
+                if (item.type === 2) {
+                    formProduct = item;
+                    return;
+                }
+                normalProduct.push(item);
+            });
+
+            setFormInput(formProduct);
+            setBtns(normalProduct);
+        }
+    }, [shopInfo]);
+
     const getCurrentProduct = (amount: number) => {
         if (!shopInfo?.products?.length) return null;
-
         let result = shopInfo?.products?.find((item) => item.par_value === Number(amount));
         if (!result) {
-            result = shopInfo?.products?.find((item) => item.par_value === 0);
+            result = shopInfo?.products?.find((item) => item.type === 2);
         }
         setCurrentProduct(result);
     };
@@ -166,6 +169,14 @@ const DepositData: FC<Props> = (props) => {
         return Promise.resolve();
     };
 
+    const isEmpty = useMemo(() => {
+        if (btns?.length === 0 && !formInput) {
+            return true;
+        }
+
+        return false;
+    }, [shopInfo]);
+
     // useLayoutEffect(() => {
     //     getDepositApi().then((data) => {
     //         setDepositState(data);
@@ -173,7 +184,7 @@ const DepositData: FC<Props> = (props) => {
     //     });
     // }, []);
 
-    // if (!depositState.length) return <Empty />;
+    if (isEmpty) return <Empty />;
 
     return (
         <div className="deposit-box">
@@ -202,7 +213,9 @@ const DepositData: FC<Props> = (props) => {
                     ref={formInstanceRef}
                     footer={
                         <>
-                            <ButtonOwn active>{t("DepositPage.DepositarAgora")}</ButtonOwn>
+                            {!isEmpty && (
+                                <ButtonOwn active>{t("DepositPage.DepositarAgora")}</ButtonOwn>
+                            )}
                         </>
                     }
                     initialValues={userInfo}
@@ -234,7 +247,7 @@ const DepositData: FC<Props> = (props) => {
                         name="amount"
                         label=""
                         rules={[{ required: true, type: "number", validator: amountValidator }]}
-                        style={{ display: shopInfo?.type === 2 ? "block" : "none" }}
+                        style={{ display: formInput ? "block" : "none" }}
                     >
                         <Input
                             placeholder={`${t("DepositPage.Montante")}: (${currentShop?.condition?.min}-${currentShop?.condition?.max})`}
@@ -246,7 +259,7 @@ const DepositData: FC<Props> = (props) => {
                     <div className={"flex flex-col"}>
                         <div className={"flex-1"}>
                             <ul className="ul-box">
-                                {shopInfo?.products?.map((item, index) => {
+                                {btns?.map((item, index) => {
                                     if (item.par_value <= 0) return null;
                                     return (
                                         <li
@@ -277,10 +290,12 @@ const DepositData: FC<Props> = (props) => {
                         </div>
                     </div>
                 </Form>
+
                 <div className={"mt-[5px] text-[0.12rem] text-[#3af3ff]"}>
                     {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>

+ 1 - 3
src/app/[locale]/(TabBar)/deposit/Left.tsx

@@ -17,8 +17,6 @@ const Left: React.FC<Props> = ({ channelData, data, actIdx = 0, onChange }) => {
         }
     };
 
-    console.log(11220, channelData);
-
     return (
         <div className="h-[100%] overflow-auto border border-y-0 border-[#5ec5ff] shadow-[0_0_25px_#3d4083_inset]">
             {channelData?.name && (
@@ -38,7 +36,7 @@ const Left: React.FC<Props> = ({ channelData, data, actIdx = 0, onChange }) => {
                             className={clsx(styles.item, { [styles.active]: actIdx === idx })}
                             onClick={() => doChange(idx)}
                         >
-                            Cartão Mensal
+                            {item.name}
                         </div>
                     );
                 })}

+ 1 - 1
src/app/[locale]/(TabBar)/deposit/page.tsx

@@ -45,7 +45,7 @@ const Deposit = () => {
         try {
             setLoading(true);
             const res = await getShopInfoApi({ shop_id: id });
-            if (res?.code === 200 && res?.data) {
+            if (res?.code === 200 && res?.data?.products?.length) {
                 res.data.products.sort((a: any, b: any) => {
                     return a.pay - b.pay;
                 }); //TODO: sort sho

+ 2 - 2
src/app/[locale]/(doings)/card/page.tsx

@@ -328,7 +328,7 @@ const CardPage = () => {
             <div className={styles.main}>
                 <div
                     className="my-[.15rem] cursor-pointer text-right text-[#00deff]"
-                    onClick={() => router.push("/cardRecord")}
+                    onClick={() => router.push(`/cardRecord?shop_id=${shop_id}`)}
                 >
                     Receba sens registros&gt;
                 </div>
@@ -361,7 +361,7 @@ const CardPage = () => {
                         <ul className={styles.introboxDesc}>
                             <li>
                                 Recarregue no dia 1 e receba bônus + prêmios emdinheiro diariamente
-                                do mesmo dia até o dia 30.
+                                do mesmo dia até o dia {shop_id === 3 ? "7" : "30"}.
                             </li>
                             <li>A retirada diária do prémio do cartão mensal é até às 23h30.</li>
                             <li>0 cartão mensal é recolhido 1 vez por dia.</li>

+ 51 - 7
src/app/[locale]/(doings)/cardRecord/page.tsx

@@ -1,15 +1,49 @@
 "use client";
+import { getClaimRecordApi } from "@/api/depositsApi";
 import { InfiniteScroll } from "antd-mobile"; // Import the CSS module for styling
 import clsx from "clsx";
+import dayjs from "dayjs";
+import { useSearchParams } from "next/navigation"; // Import useRoute
 import React from "react";
 import styles from "./page.module.scss";
 
+interface RecordItem {
+    claim_time: number; // Replace with the actual type of claim_time if known
+    [key: string]: any; // Allow any other properties
+}
+
 const Record = () => {
+    const searchParams = useSearchParams();
     const params = React.useRef({ current_page: 0, page_size: 20, use_page: true });
+    const [dataSource, setDataSource] = React.useState<RecordItem[]>([]);
 
     const loadMore = async () => {
         params.current.current_page += 1;
     };
+    React.useEffect(() => {
+        getData();
+    }, []); //TODO: dat
+
+    const getData = async () => {
+        const res = await getClaimRecordApi({ shop_id: Number(searchParams.get("shop_id") || 0) });
+        if (res.code === 200 && res.data) {
+            const result: RecordItem[] = [];
+            res.data.forEach((item: any) => {
+                // result.push({...item,claim_time:item.claim_time/1000})
+                let itemResult: any = {
+                    claim_time: item.claim_time / 1000,
+                };
+                if (item.list.length > 0) {
+                    item.list.forEach((citem: any) => {
+                        itemResult[`amount_${citem.item_id}`] = citem.amount;
+                        itemResult[`rollover_${citem.item_id}`] = citem.rollover;
+                    });
+                }
+                result.push(itemResult);
+            });
+            setDataSource(result);
+        }
+    };
 
     return (
         <div className={styles.pageContainer}>
@@ -21,13 +55,23 @@ const Record = () => {
                 <div>Proporção de codificação de bônus</div>
             </div>
             <div className="flex-1">
-                <div className={clsx(styles.item, styles.recordItem)}>
-                    <div>2025/04/23 14:46:23</div>
-                    <div>Receber principal</div>
-                    <div>Razão de codificação principal</div>
-                    <div>Receber bônus</div>
-                    <div>Proporção de codificação de bônus</div>
-                </div>
+                {!!dataSource?.length &&
+                    dataSource.map((item) => {
+                        return (
+                            <div
+                                key={item.claim_time}
+                                className={clsx(styles.item, styles.recordItem)}
+                            >
+                                <div>
+                                    {dayjs(item.claim_time * 1000).format("YYYY/MM/DD HH:mm:ss")}
+                                </div>
+                                <div>{item.amount_1}</div>
+                                <div>{item.rollover_1}</div>
+                                <div>{item.amount_2}</div>
+                                <div>{item.rollover_2}</div>
+                            </div>
+                        );
+                    })}
                 <InfiniteScroll loadMore={loadMore} hasMore={false}></InfiniteScroll>
             </div>
         </div>

+ 43 - 43
src/components/Header/HeaderRight.tsx

@@ -1,58 +1,58 @@
 "use client";
-import { useEffect } from "react";
-import { useRouter } from "next/navigation";
 import { Link } from "@/i18n/routing";
 import { useWalletStore } from "@/stores/useWalletStore";
 import { getToken } from "@/utils/Cookies";
 import { useTranslations } from "next-intl";
+import { useRouter } from "next/navigation";
+import { useEffect } from "react";
 import styles from "./style.module.scss";
 
 const HeaderRight = () => {
-  const router = useRouter();
-  const t = useTranslations("Header");
+    const router = useRouter();
+    const t = useTranslations("Header");
 
-  const token = getToken();
-  const score = useWalletStore((state) => state.wallet.score);
+    const token = getToken();
+    const score = useWalletStore((state) => state.wallet.score);
 
-  // ✅ 主动预加载常用页面,仅在浏览器 + router ready 时执行
-  useEffect(() => {
-      router.prefetch("/profile");
-      router.prefetch("/deposit");
-      router.prefetch("/login?redirect=/");
-      router.prefetch("/register?redirect=/");
-  }, []);
+    // ✅ 主动预加载常用页面,仅在浏览器 + router ready 时执行
+    useEffect(() => {
+        router.prefetch("/profile");
+        router.prefetch("/deposit");
+        router.prefetch("/login?redirect=/");
+        router.prefetch("/register?redirect=/");
+    }, []);
 
-  return (
-      <div className={styles.headerRight}>
-          <div className={styles.right}>
-              {token ? (
-                  <>
-                      <Link
-                          href={"/profile"}
-                          className={"flex items-center text-[0.12rem]"}
-                          prefetch
-                      >
-                          <i className={"iconfont icon-yonghu mr-[0.03rem]"}></i>
-                          <span>{score}</span>
-                      </Link>
+    return (
+        <div className={styles.headerRight}>
+            <div className={styles.right}>
+                {token ? (
+                    <>
+                        <Link
+                            href={"/profile"}
+                            className={"flex items-center text-[0.12rem]"}
+                            prefetch
+                        >
+                            <i className={"iconfont icon-yonghu mr-[0.03rem]"}></i>
+                            <span>{score}</span>
+                        </Link>
 
-                      <Link href={"/deposit"} prefetch className={styles.rightActive}>
-                          {t("deposit")}
-                      </Link>
-                  </>
-              ) : (
-                  <>
-                      <Link href={"/login?redirect=/"} prefetch className={styles.leftActive}>
-                          {t("login")}
-                      </Link>
-                      <Link href={"/register?redirect=/"} prefetch className={styles.rightActive}>
-                          {t("register")}
-                      </Link>
-                  </>
-              )}
-          </div>
-      </div>
-  );
+                        <Link href={"/deposit"} prefetch className={styles.rightActive}>
+                            {t("deposit")}
+                        </Link>
+                    </>
+                ) : (
+                    <>
+                        <Link href={"/login?redirect=/"} prefetch className={styles.leftActive}>
+                            {t("login")}
+                        </Link>
+                        <Link href={"/register?redirect=/"} prefetch className={styles.rightActive}>
+                            {t("register")}
+                        </Link>
+                    </>
+                )}
+            </div>
+        </div>
+    );
 };
 
 export default HeaderRight;