Ver Fonte

feat: 修改

year há 2 meses atrás
pai
commit
6e7b26202d

+ 10 - 21
.env.local

@@ -1,24 +1,13 @@
-# 环境
 #baseurl
-# NEXT_PUBLIC_BASE_URL=http://192.168.0.71:8800
-NEXT_PUBLIC_BASE_URL=http://192.168.0.84:8800
-# NEXT_PUBLIC_BASE_URL=https://3rd-api.tiktokjakjkl.icu
+NEXT_PUBLIC_BASE_URL=https://hk-api.tiktokjakjkl.icu
 #share link
-NEXT_PUBLIC_SHARE_URL=http://192.168.0.84:3000
-
+NEXT_PUBLIC_SHARE_URL=https://hk-site.tiktokjakjkl.icu
 #firebase
-NEXT_PUBLIC_FIREBASE_APIKEY=AIzaSyDAWORGKhdyzb5KeqTi535VmD5gN2Cdle8
-NEXT_PUBLIC_FIREBASE_AUTHDOMAIN=bcwin-a99b1.firebaseapp.com
-
-
-
-
-NEXT_PUBLIC_FIREBASE_PROJECTID=bcwin-a99b1
-NEXT_PUBLIC_FIREBASE_STORAGEBUCKET=bcwin-a99b1.appspot.com
-NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID=1055413612814
-NEXT_PUBLIC_FIREBASE_APPID=1:1055413612814:web:7a563237de8e43849d275f
-
-
-
-NEXT_PUBLIC_FIREBASE_MEASUREMENTID=G-467M2BYJMS
-NEXT_PUBLIC_FIREBASE_KEYS=BAOsT7kii-ctLzGrgXe_wYhfuxlme1v4njnD0uPSKp3DpSnrUa2e709b9dRaeYVU7jF_qIx1y9tEv0CvilDCdnM
+NEXT_PUBLIC_FIREBASE_APIKEY=AIzaSyCIE8xtySsYztsSgmQJx_aqPrrpHEuvgvw
+NEXT_PUBLIC_FIREBASE_AUTHDOMAIN=bcwin777-1bdda.firebaseapp.com
+NEXT_PUBLIC_FIREBASE_PROJECTID=bcwin777-1bdda
+NEXT_PUBLIC_FIREBASE_STORAGEBUCKET=bcwin777-1bdda.firebasestorage.app
+NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID=542456379513
+NEXT_PUBLIC_FIREBASE_APPID=1:542456379513:web:851a46fc639085170bfca8
+NEXT_PUBLIC_FIREBASE_MEASUREMENTID=G-GV6Y8DXHHD
+NEXT_PUBLIC_FIREBASE_KEYS=BOCfpA08vK6uxhMdRblnx9gPVBLx9WpTn9AutVNhHQQpVtXzDIKW0X6cmsNRaFDhyFDJfMqWjqC7mq6uDFIKU_M

+ 25 - 5
src/api/depositsApi.ts

@@ -88,11 +88,11 @@ export interface ShopPayRewardItem {
     MaxReward: number;
 }
 export interface ShopActivityRewardItem {
-    ItemID: number;
-    Reward: number;
-    Amount: number;
-    Rollover: number;
-    MaxReward: number;
+    item_id: number;
+    reward: number;
+    amount: number;
+    rollover: number;
+    max_reward: number;
 }
 export interface ShopProductItem {
     id: number;
@@ -114,6 +114,7 @@ export interface ShopInfo {
     renter_id: number;
     has_pay: boolean;
     num: number;
+    type: 1 | 2;
     products: ShopProductItem[];
     condition: {
         Min: number;
@@ -128,3 +129,22 @@ export const getShopInfoApi = (data: { shop_id: number }) => {
         data,
     });
 };
+
+export interface ShopClaim {
+    coin_type: number;
+    amount: number;
+}
+
+export interface ShopClaimRes {
+    code: number;
+    reward: ShopClaim[];
+    extra_reward: ShopClaim[];
+}
+
+export const doClaimShopApi = (data: { id: number }) => {
+    return server.request<ShopClaimRes>({
+        url: "/v1/api/user/shop/claimShopReward",
+        method: "POST",
+        data,
+    });
+};

+ 9 - 7
src/app/[locale]/(TabBar)/deposit/DepositData.tsx

@@ -65,10 +65,9 @@ const DepositData: FC<Props> = (props) => {
 
     const currentProduct = useMemo(() => {
         if (!shopInfo?.products?.length) return null;
-        console.log("currentProduct", amount);
-        let result = shopInfo?.products?.find((item) => item.pay / 100 === amount);
+        let result = shopInfo?.products?.find((item) => item.par_value === amount);
         if (!result) {
-            result = shopInfo?.products?.find((item) => item.pay === 0);
+            result = shopInfo?.products?.find((item) => item.par_value === 0);
         }
         return result;
     }, [shopInfo?.products, amount]);
@@ -76,6 +75,7 @@ const DepositData: FC<Props> = (props) => {
     const tipModelRef = useRef<ModalProps>(null); // 充值清空打码量弹窗
     const [formData, setFormData] = useState<any>({}); // 存放表单数据
     const onFinish = async (values: any) => {
+        if (!amount) return Toast.show({ content: t("form.amount") });
         const params = {
             ...values,
             channel_id: currentChannel?.id,
@@ -203,10 +203,12 @@ const DepositData: FC<Props> = (props) => {
                             </Form.Item>
                         </>
                     ) : null}
+
                     <Form.Item
                         name="amount"
                         label=""
                         rules={[{ required: true, type: "number", validator: amountValidator }]}
+                        style={{ display: shopInfo?.type === 2 ? "block" : "none" }}
                     >
                         <Input
                             placeholder={`${t("DepositPage.Montante")}: (${shopInfo?.condition?.Min}-${shopInfo?.condition?.Max})`}
@@ -219,18 +221,18 @@ const DepositData: FC<Props> = (props) => {
                         <div className={"flex-1"}>
                             <ul className="ul-box">
                                 {shopInfo?.products?.map((item, index) => {
-                                    if (item.pay <= 0) return null;
+                                    if (item.par_value <= 0) return null;
                                     return (
                                         <li
-                                            className={amount == item.pay / 100 ? "active" : ""}
+                                            className={amount == item.par_value ? "active" : ""}
                                             key={index}
-                                            onClick={() => amountChange(item.pay / 100)}
+                                            onClick={() => amountChange(item.par_value)}
                                         >
                                             {!!item.is_hot && <span className="hot"></span>}
                                             <div className="amountContent">
                                                 {/* <span className="iconfont icon-unit-brl"></span> */}
                                                 <span className="iconfont">R$</span>
-                                                <span> {item.pay / 100}</span>
+                                                <span> {item.par_value}</span>
                                             </div>
 
                                             <Reward data={item} />

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

@@ -1,5 +1,6 @@
 "use client";
 import { getShopInfoApi, getShopListApi, ShopInfo } from "@/api/depositsApi";
+import Loading from "@/components/Loading";
 import React from "react";
 import DepositData from "./DepositData";
 import Left from "./Left";
@@ -9,6 +10,7 @@ const Deposit = () => {
     const [shopTypeList, setShopTypeList] = React.useState<any[]>([]);
     const [currentChannel, setCurrentChannel] = React.useState<any>({});
     const [shopInfo, setShopInfo] = React.useState<ShopInfo>({} as ShopInfo);
+    const [loading, setLoading] = React.useState(false);
 
     const actChange = (idx: number) => {
         setActIdx(idx);
@@ -40,12 +42,17 @@ const Deposit = () => {
             setShopInfo({} as ShopInfo);
             return;
         }
-        const res = await getShopInfoApi({ shop_id: id });
-        if (res?.code === 200 && res?.data) {
-            res.data.products.sort((a: any, b: any) => {
-                return a.pay - b.pay;
-            }); //TODO: sort sho
-            setShopInfo(res.data);
+        try {
+            setLoading(true);
+            const res = await getShopInfoApi({ shop_id: id });
+            if (res?.code === 200 && res?.data) {
+                res.data.products.sort((a: any, b: any) => {
+                    return a.pay - b.pay;
+                }); //TODO: sort sho
+                setShopInfo(res.data);
+            }
+        } finally {
+            setLoading(false);
         }
     };
 
@@ -66,13 +73,20 @@ const Deposit = () => {
             </div>
 
             <div className="flex-1 overflow-auto">
-                <DepositData
-                    onActiveChange={doChangeChannel}
-                    currentChannel={currentChannel}
-                    setChannel={doChangeChannel}
-                    shopInfo={shopInfo}
-                    channel={currentShop?.pay_channel || []}
-                />
+                {!loading && (
+                    <DepositData
+                        onActiveChange={doChangeChannel}
+                        currentChannel={currentChannel}
+                        setChannel={doChangeChannel}
+                        shopInfo={shopInfo}
+                        channel={currentShop?.pay_channel || []}
+                    />
+                )}
+                {loading && (
+                    <div className="flex h-[100%] items-center justify-center">
+                        <Loading></Loading>
+                    </div>
+                )}
             </div>
         </div>
     );

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

@@ -1,7 +1,18 @@
 "use client";
 import GlobalNotify from "@/components/ModalPopup/GlobalNotifyModal";
 
+import {
+    doClaimShopApi,
+    getShopInfoApi,
+    ShopActivityRewardItem,
+    ShopInfo,
+    ShopProductItem,
+} from "@/api/depositsApi";
+import { formatAmount } from "@/utils/index";
+import { Toast } from "antd-mobile";
 import clsx from "clsx";
+import { useTranslations } from "next-intl";
+import { useSearchParams } from "next/navigation";
 import React from "react";
 import "swiper/css/pagination";
 import { Pagination } from "swiper/modules";
@@ -9,10 +20,40 @@ import { Swiper, SwiperClass, SwiperSlide } from "swiper/react";
 import styles from "./page.module.scss";
 
 const CardPage = () => {
+    const searchParams = useSearchParams();
     const swiperRef = React.useRef<SwiperClass | null>(null);
     const [act, setAct] = React.useState(0);
     const [amount, setAmount] = React.useState<any>({});
     const [visible, setVisible] = React.useState<boolean>(false);
+    const [shopInfo, setShopInfo] = React.useState<ShopInfo>({} as ShopInfo);
+    const [loading, setLoading] = React.useState(false);
+    const shop_id = React.useMemo(() => {
+        return Number(searchParams.get("shop_id"));
+    }, []);
+    const t = useTranslations();
+
+    React.useEffect(() => {
+        getInfo();
+    }, []);
+
+    const getInfo = async () => {
+        if (!shop_id) {
+            setShopInfo({} as ShopInfo);
+            return;
+        }
+        try {
+            setLoading(true);
+            const res = await getShopInfoApi({ shop_id });
+            if (res?.code === 200 && res?.data) {
+                res.data.products.sort((a: any, b: any) => {
+                    return a.pay - b.pay;
+                }); //TODO: sort sho
+                setShopInfo(res.data);
+            }
+        } finally {
+            setLoading(false);
+        }
+    };
 
     const doChange = (type: 1 | -1) => {
         if (swiperRef.current) {
@@ -25,6 +66,66 @@ const CardPage = () => {
         return [1, 2, 3, 4, 5];
     }, []);
 
+    const getActiveInfo = (itemData: ShopProductItem) => {
+        const amountInfo = itemData.activity_reward.find((item: ShopActivityRewardItem) => {
+            return item.item_id === 1;
+        });
+        const boundsInfo = itemData.activity_reward.find((item: ShopActivityRewardItem) => {
+            return item.item_id === 2;
+        });
+        return {
+            amount: amountInfo?.amount || 0,
+            amountRollover: amountInfo?.rollover || 0,
+            bouns: boundsInfo?.amount || 0,
+            bounsRollover: boundsInfo?.rollover || 0,
+        };
+    };
+
+    const doClaim = async (itemData: ShopProductItem) => {
+        if (!itemData.id) {
+            Toast.show({ content: "Missing product ID" });
+            return;
+        }
+        if (itemData.is_suss !== 0) {
+            return;
+        }
+        try {
+            const res = await doClaimShopApi({
+                id: itemData.id,
+            });
+
+            if (res.code === 200 && res?.data?.code === 1) {
+                const amountObj: any = {};
+                if (res?.data?.reward) {
+                    res?.data?.reward.forEach((item: any) => {
+                        amountObj[`coin_${item.coin_type}`] = formatAmount(item.amount);
+                    });
+                }
+                if (res?.data?.extra_reward) {
+                    res?.data?.extra_reward.forEach((item: any) => {
+                        amountObj[`coin_${item.coin_type}`] = formatAmount(
+                            new BigNumber(amountObj[`coin_${item.coin_type}`] || 0)
+                                .plus(item.amount)
+                                .toString()
+                        );
+                    });
+                }
+                setAmount(amountObj);
+                setVisible(true);
+                getInfo();
+            } else {
+                throw new Error(t(`code.400`));
+            }
+        } catch (error: any) {
+            if (error) {
+                Toast.show({
+                    content: error.message || error.toString(),
+                    maskClickable: false,
+                });
+            }
+        }
+    };
+
     return (
         <div className={styles.CardPage}>
             <div className={styles.top}>
@@ -45,147 +146,160 @@ const CardPage = () => {
                         clickable: true,
                     }}
                 >
-                    {data.map((key) => {
-                        return (
-                            <SwiperSlide
-                                key={key}
-                                className={clsx(styles.swiperSlide, {
-                                    [styles.swiperSlideBlue]: key === 1,
-                                    [styles.swiperSlideGold]: key === 2,
-                                })}
-                            >
-                                <div className={styles.swiperItem}>
-                                    <div
-                                        className={clsx(
-                                            "flex flex-row items-center justify-between",
-                                            styles.swiperItemTop
-                                        )}
-                                    >
-                                        <div className={clsx(styles.leftContent, "pl-[.1rem]")}>
-                                            CARTãO DE MêS{key}
-                                        </div>
+                    {!!shopInfo?.products?.length &&
+                        shopInfo?.products.map((item) => {
+                            const itemInfo = getActiveInfo(item);
+                            return (
+                                <SwiperSlide
+                                    key={item.id}
+                                    className={clsx(styles.swiperSlide, {
+                                        [styles.swiperSlideBlue]: item.id === 1,
+                                        [styles.swiperSlideGold]: item.id === 2,
+                                    })}
+                                >
+                                    <div className={styles.swiperItem}>
                                         <div
                                             className={clsx(
-                                                styles.rightContent,
-                                                "pr-[.12rem] pt-[.02rem] text-[.1rem]"
+                                                "flex flex-row items-center justify-between",
+                                                styles.swiperItemTop
                                             )}
                                         >
-                                            Já foi comprado
-                                        </div>
-                                    </div>
-                                    <div className={styles.cardContainerOut}>
-                                        <div className={styles.cardContent}>
-                                            <div className={styles.cardLeft}>
-                                                <div className={clsx("text-[.12rem] font-bold")}>
-                                                    PARA RECARREGAR
-                                                </div>
-                                                <div
-                                                    className={clsx(
-                                                        "my-[.04rem] text-[.36rem] font-bold",
-                                                        styles.money
-                                                    )}
-                                                >
-                                                    500R
-                                                </div>
-                                                <div className="pb-[.2rem] text-[.15rem] font-bold">
-                                                    EXTRA 271%
-                                                </div>
+                                            <div className={clsx(styles.leftContent, "pl-[.1rem]")}>
+                                                {shop_id === 4 && "CARTãO DE MêS"}
+                                                {shop_id === 3 && "Cartão Semanal"}
                                             </div>
-                                            <div className={styles.cardRight}>
-                                                <div
-                                                    className={clsx(
-                                                        "text-[.12rem] font-bold",
-                                                        styles.text
-                                                    )}
-                                                >
-                                                    RECEBA POR DIA
-                                                </div>
-                                                <div className="text-[.12rem] font-bold">
-                                                    NUMERÁRIO 10R
-                                                </div>
-                                                <div className="text-[.12rem] font-bold">
-                                                    BÔNUS 38R
-                                                </div>
-                                            </div>
-                                            <div className={styles.rili}>
-                                                <div className={styles.riliContent}>
-                                                    <div className="text-[.14rem] font-bold text-[#ac4b31]">
-                                                        30
-                                                    </div>
-                                                    <div className="text-[.12rem] text-[#ac4b31]">
-                                                        dias
-                                                    </div>
-                                                </div>
-                                            </div>
-                                        </div>
-                                        <div className={styles.lingqu}>
                                             <div
                                                 className={clsx(
-                                                    styles.lingquTop,
-                                                    "text-[.15rem] font-bold text-[#e4292d]"
+                                                    styles.rightContent,
+                                                    "pr-[.12rem] pt-[.02rem] text-[.1rem]"
                                                 )}
                                             >
-                                                Receba por dia
+                                                {item.is_suss > -1 && "Já foi comprado"}
                                             </div>
-                                            <div className={clsx(styles.lingquContent)}>
-                                                <div className={clsx(styles.lingquInfo)}>
-                                                    {key == 2 && (
-                                                        <>
-                                                            <div className="text-center text-[.16rem] font-bold text-[#fffc03]">
-                                                                Você ainda não comprou
-                                                            </div>
-                                                            <div className={styles.btn2}>
-                                                                comprar
-                                                            </div>
-                                                        </>
-                                                    )}
-                                                    {key !== 2 && (
-                                                        <>
-                                                            <div
-                                                                className={clsx(
-                                                                    "text-[.18rem] font-bold",
-                                                                    styles.receiveText
-                                                                )}
-                                                            >
-                                                                NUMERÁRIO 10R
-                                                            </div>
-                                                            <div
-                                                                className={clsx(
-                                                                    "text-[.18rem]",
-                                                                    styles.receiveText
-                                                                )}
-                                                            >
-                                                                +
-                                                            </div>
-                                                            <div
-                                                                className={clsx(
-                                                                    "text-[.18rem] font-bold",
-                                                                    styles.receiveText
-                                                                )}
-                                                            >
-                                                                BÔNUS 38R
-                                                            </div>
-                                                            <div
-                                                                className={clsx(
-                                                                    "mt-[.08rem] text-[.18rem] font-bold",
-                                                                    styles.receiveText2
-                                                                )}
-                                                            >
-                                                                XX DIAS RESTANTES
-                                                            </div>
-                                                            <div className={styles.btn}>
-                                                                Resgatar
-                                                            </div>
-                                                        </>
-                                                    )}
+                                        </div>
+                                        <div className={styles.cardContainerOut}>
+                                            <div className={styles.cardContent}>
+                                                <div className={styles.cardLeft}>
+                                                    <div
+                                                        className={clsx("text-[.12rem] font-bold")}
+                                                    >
+                                                        PARA RECARREGAR
+                                                    </div>
+                                                    <div
+                                                        className={clsx(
+                                                            "my-[.04rem] text-[.36rem] font-bold",
+                                                            styles.money
+                                                        )}
+                                                    >
+                                                        {item.par_value}R
+                                                    </div>
+                                                    <div className="pb-[.2rem] text-[.15rem] font-bold">
+                                                        EXTRA {item.desc}%
+                                                    </div>
+                                                </div>
+                                                <div className={styles.cardRight}>
+                                                    <div
+                                                        className={clsx(
+                                                            "text-[.12rem] font-bold",
+                                                            styles.text
+                                                        )}
+                                                    >
+                                                        RECEBA POR DIA
+                                                    </div>
+                                                    <div className="text-[.12rem] font-bold">
+                                                        NUMERÁRIO {itemInfo.amount}R
+                                                    </div>
+                                                    <div className="text-[.12rem] font-bold">
+                                                        BÔNUS {itemInfo.bouns}R
+                                                    </div>
+                                                </div>
+                                                <div className={styles.rili}>
+                                                    <div className={styles.riliContent}>
+                                                        <div className="text-[.14rem] font-bold text-[#ac4b31]">
+                                                            {shop_id === 4 ? "30" : ""}
+                                                            {shop_id === 3 ? "7" : ""}
+                                                        </div>
+                                                        <div className="text-[.12rem] text-[#ac4b31]">
+                                                            dias
+                                                        </div>
+                                                    </div>
                                                 </div>
                                             </div>
+                                            {item.is_suss > -1 && (
+                                                <div className={styles.lingqu}>
+                                                    <div
+                                                        className={clsx(
+                                                            styles.lingquTop,
+                                                            "text-[.15rem] font-bold text-[#e4292d]"
+                                                        )}
+                                                    >
+                                                        Receba por dia
+                                                    </div>
+                                                    <div className={clsx(styles.lingquContent)}>
+                                                        <div className={clsx(styles.lingquInfo)}>
+                                                            {item.id == 2 && (
+                                                                <>
+                                                                    <div className="text-center text-[.16rem] font-bold text-[#fffc03]">
+                                                                        Você ainda não comprou
+                                                                    </div>
+                                                                    <div className={styles.btn2}>
+                                                                        comprar
+                                                                    </div>
+                                                                </>
+                                                            )}
+                                                            {item.id !== 2 && (
+                                                                <>
+                                                                    <div
+                                                                        className={clsx(
+                                                                            "text-[.18rem] font-bold",
+                                                                            styles.receiveText
+                                                                        )}
+                                                                    >
+                                                                        NUMERÁRIO{itemInfo.amount}R
+                                                                    </div>
+                                                                    <div
+                                                                        className={clsx(
+                                                                            "text-[.18rem]",
+                                                                            styles.receiveText
+                                                                        )}
+                                                                    >
+                                                                        +
+                                                                    </div>
+                                                                    <div
+                                                                        className={clsx(
+                                                                            "text-[.18rem] font-bold",
+                                                                            styles.receiveText
+                                                                        )}
+                                                                    >
+                                                                        BÔNUS {itemInfo.bouns}R
+                                                                    </div>
+                                                                    <div
+                                                                        className={clsx(
+                                                                            "mt-[.08rem] text-[.18rem] font-bold",
+                                                                            styles.receiveText2
+                                                                        )}
+                                                                    >
+                                                                        {item.days} DIAS RESTANTES
+                                                                    </div>
+                                                                    <div
+                                                                        className={styles.btn}
+                                                                        onClick={() =>
+                                                                            doClaim(item)
+                                                                        }
+                                                                    >
+                                                                        Resgatar
+                                                                    </div>
+                                                                </>
+                                                            )}
+                                                        </div>
+                                                    </div>
+                                                </div>
+                                            )}
                                         </div>
                                     </div>
-                                </div>
-                            </SwiperSlide>
-                        );
-                    })}
+                                </SwiperSlide>
+                            );
+                        })}
                 </Swiper>
                 <div className={styles.pagation}>
                     <div
@@ -215,20 +329,18 @@ const CardPage = () => {
                         <div>Taxa de retirada de dinheiro</div>
                         <div>Bônus retirada nultiplicação</div>
                     </div>
-                    <div className={styles.configItem}>
-                        <div>1</div>
-                        <div>2</div>
-                        <div>3</div>
-                        <div>4</div>
-                        <div>5</div>
-                    </div>
-                    <div className={styles.configItem}>
-                        <div>1</div>
-                        <div>2</div>
-                        <div>3</div>
-                        <div>4</div>
-                        <div>5</div>
-                    </div>
+                    {shopInfo?.products?.map((item) => {
+                        const itemInfo = getActiveInfo(item);
+                        return (
+                            <div key={item.id} className={styles.configItem}>
+                                <div>{item.par_value}</div>
+                                <div>{itemInfo.amount}</div>
+                                <div>{itemInfo.bouns}</div>
+                                <div>{itemInfo.amountRollover}</div>
+                                <div>{itemInfo.bounsRollover}</div>
+                            </div>
+                        );
+                    })}
                 </div>
                 <div className={styles.introbox}>
                     <div className={styles.introContainer}>