Browse Source

feat: 修改

year 1 tháng trước cách đây
mục cha
commit
9edc09a46a
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      src/app/[locale]/(TabBar)/deposit/page.tsx

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

@@ -13,6 +13,7 @@ const Deposit = () => {
     const [currentChannel, setCurrentChannel] = React.useState<any>({});
     const [shopInfo, setShopInfo] = React.useState<ShopInfo | null>(null);
     const [loading, setLoading] = React.useState(false);
+    const [isInit, setIsInit] = React.useState(true);
 
     const actChange = (idx: number) => {
         setActIdx(idx);
@@ -33,7 +34,7 @@ const Deposit = () => {
     }, [actIdx, shopTypeList]);
 
     React.useEffect(() => {
-        if (!shopInfo || (shopInfo.id === 1 && shopInfo.num <= 0)) {
+        if ((!shopInfo || (shopInfo.id === 1 && shopInfo.num <= 0)) && !isInit) {
             setShopTypeList((listValue) => {
                 return listValue.filter((item) => {
                     return item.id !== 1;
@@ -74,6 +75,7 @@ const Deposit = () => {
     };
 
     const getInfo = async (id: number, isClear = true) => {
+        setIsInit(true);
         if (!id) {
             setShopInfo(null);
             return;
@@ -88,6 +90,9 @@ const Deposit = () => {
                 res.data.products.sort((a: any, b: any) => {
                     return a.order - b.order;
                 });
+                if (res?.data.id === 1 && res?.data.num === 0) {
+                    res.data.products = [];
+                }
                 setShopInfo(res?.data || {});
             }
         } catch {