Browse Source

feat: 修改

year 3 hours ago
parent
commit
4d6acb2513

+ 37 - 4
src/app/[locale]/(doings)/rank/page.tsx

@@ -10,6 +10,7 @@ import {
 } from "@/api/activity";
 import { userInfoApi } from "@/api/login";
 import CustomButton from "@/components/CustomButton";
+import CutDown from "@/components/CutDown";
 import HeaderBack from "@/components/HeaderBack";
 import Tabs from "@/components/Tabs";
 import { HeaderImageMap, RankSourceMap } from "@/enums";
@@ -28,7 +29,7 @@ const Page = () => {
     });
     const router = useRouter();
     const [initLoading, setInitLoading] = React.useState<boolean>(true);
-    const [areaId, setAreaId] = React.useState<number>(1);
+    // const [areaId, setAreaId] = React.useState<number>(1);
     const [loading, setLoading] = React.useState<boolean>(false);
     const [data, setData] = React.useState<RankDetail>({} as RankDetail);
     const [noMore, setNoMore] = React.useState<boolean>(false);
@@ -85,6 +86,8 @@ const Page = () => {
         const result: any = [];
         Object.keys(SourceObject[currentSource.source]).forEach((key) => {
             const curType = RankSourceMap.get(Number(key)) || ({} as any);
+            const curData = SourceObject[currentSource.source][key];
+
             result.push({
                 id: key,
                 name: (
@@ -93,7 +96,19 @@ const Page = () => {
                         <div className="flex flex-row items-center justify-center gap-[5px] text-[12px] text-[var(--primary-button)]">
                             <i className="iconfont icon-daojishi-hui !text-[13px]"></i>
                             <div className="countdownTimer needsclick flex flex-row items-center justify-center gap-[1px]">
-                                <span>01</span>:<span>01</span>:<span>01</span>
+                                <CutDown
+                                    endTime={(curData?.end_time * 1000 - Date.now()) / 1000}
+                                    itemStyle={{
+                                        backgroundColor: "transportant",
+                                        fontSize: "12px",
+                                        color: "var(--primary-button)",
+                                        width: "auto",
+                                    }}
+                                    splitStyle={{
+                                        margin: "0 .01rem",
+                                        color: "var(--primary-button)",
+                                    }}
+                                ></CutDown>
                             </div>
                         </div>
                     </div>
@@ -103,6 +118,16 @@ const Page = () => {
         return result;
     }, [SourceObject, currentSource]);
 
+    const areaId = React.useMemo(() => {
+        if (
+            !SourceObject ||
+            !SourceObject[currentSource.source] ||
+            !SourceObject[currentSource.source][currentSource.type]
+        )
+            return 0;
+        return SourceObject[currentSource.source][currentSource.type]?.area_id || 0;
+    }, [currentSource, SourceObject]);
+
     const getRankData = async () => {
         const res = await getRank();
         if (res.code === 200) {
@@ -118,11 +143,14 @@ const Page = () => {
         pageInfo.current.page = 0;
         setRankList([]);
         setData({} as any);
-        // getData(areaId);
+        getData(areaId);
     }, [areaId]);
 
     const getData = async (id: number) => {
         if (loading) return;
+        if (!id) {
+            return;
+        }
         try {
             setLoading(true);
             if (pageInfo.current?.page === 1) {
@@ -180,7 +208,11 @@ const Page = () => {
                             ></Tabs>
                         </div>
                         <div className={styles.tabType}>
-                            <Tabs items={Tab2Cfg}></Tabs>
+                            <Tabs
+                                items={Tab2Cfg}
+                                activeKey={currentSource.type}
+                                onChanage={(val) => sourceChange(val, "type")}
+                            ></Tabs>
                         </div>
                         <div className="min-h-[0] flex-1 overflow-auto">
                             <div
@@ -331,6 +363,7 @@ const Page = () => {
                                 <InfiniteScroll
                                     hasMore={!noMore}
                                     loadMore={async () => {
+                                        if (loading || !pageInfo.current.page) return;
                                         pageInfo.current.page++;
                                         await getData(areaId);
                                     }}

+ 3 - 1
src/app/[locale]/(doings)/weekAidFund/page.tsx

@@ -190,9 +190,11 @@ const Page = () => {
                         onClick={openDialog}
                         disabled={
                             ![0, 1].includes(data?.last_week?.status || 0) ||
-                            data?.last_week?.normal_amount === 0
+                            data?.last_week?.normal_amount === 0 ||
+                            !data
                         }
                     >
+                        {!data && "Unopened"}
                         {(data?.last_week?.status === 0 || data?.last_week?.normal_amount === 0) &&
                             "Unopened"}
                         {data?.last_week?.status === 1 && "Receber"}

+ 18 - 8
src/components/CutDown/index.tsx

@@ -4,10 +4,14 @@ import useCountDown from "@/hooks/useCountdown";
 const TimeLeft = ({
     endTime,
     itemBgColor = "#4c546e",
+    itemStyle = {},
+    splitStyle = {},
     onEnd,
 }: {
     endTime: number;
-    itemBgColor: string;
+    itemBgColor?: string;
+    itemStyle?: React.CSSProperties;
+    splitStyle?: React.CSSProperties;
     onEnd?: Function;
 }) => {
     const [countdown, time] = useCountDown({
@@ -28,37 +32,43 @@ const TimeLeft = ({
                             `flex items-center justify-center rounded-[0.0347rem]` +
                             " h-[0.2083rem] w-[0.2083rem]"
                         }
-                        style={{ backgroundColor: itemBgColor }}
+                        style={{ backgroundColor: itemBgColor, ...itemStyle }}
                     >
                         {`${time.days}`.padStart(2, "0")}
                     </div>
-                    <span className={"mx-[0.0247rem]"}>:</span>
+                    <span className={"mx-[0.0247rem]"} style={{ ...splitStyle }}>
+                        :
+                    </span>
                     <div
                         className={
                             `flex items-center justify-center rounded-[0.0347rem]` +
                             " h-[0.2083rem] w-[0.2083rem]"
                         }
-                        style={{ backgroundColor: itemBgColor }}
+                        style={{ backgroundColor: itemBgColor, ...itemStyle }}
                     >
                         {`${time.hours}`.padStart(2, "0")}
                     </div>
-                    <span className={"mx-[0.0247rem]"}>:</span>
+                    <span className={"mx-[0.0247rem]"} style={{ ...splitStyle }}>
+                        :
+                    </span>
                     <div
                         className={
                             `flex items-center justify-center rounded-[0.0347rem]` +
                             " h-[0.2083rem] w-[0.2083rem]"
                         }
-                        style={{ backgroundColor: itemBgColor }}
+                        style={{ backgroundColor: itemBgColor, ...itemStyle }}
                     >
                         {`${time.minutes}`.padStart(2, "0")}
                     </div>
-                    <span className={"mx-[0.0247rem]"}>:</span>
+                    <span className={"mx-[0.0247rem]"} style={{ ...splitStyle }}>
+                        :
+                    </span>
                     <div
                         className={
                             `flex items-center justify-center rounded-[0.0347rem]` +
                             " h-[0.2083rem] w-[0.2083rem]"
                         }
-                        style={{ backgroundColor: itemBgColor }}
+                        style={{ backgroundColor: itemBgColor, ...itemStyle }}
                     >
                         {`${time.seconds}`.padStart(2, "0")}
                     </div>

+ 1 - 1
src/components/ShareText/index.tsx

@@ -19,7 +19,7 @@ const ShareText: React.FC<Props> = ({ text, className }) => {
     const localText = React.useMemo(() => {
         return `${text?.replace(/{%}/g, decodeURIComponent(url))}`;
     }, [text, url]);
-
+    if (!text) return null;
     return (
         <div
             className={clsx(