year 1 ヶ月 前
コミット
49cc1b9831

+ 7 - 4
src/api/home.ts

@@ -155,6 +155,8 @@ export interface GameListRep {
     toDo?: () => void;
 
     is_favorite?: 0 | 1;
+
+    online_user?: number;
 }
 
 /**
@@ -367,10 +369,10 @@ export const gamesNoticeWinApi = () => {
     });
 };
 
-//收藏游戏
-export const setFavorite = (data: { game_id: number }) => {
+//收藏游戏列表
+export const getFavoriteList = (data: SearchProps) => {
     return server.post({
-        url: "/v1/api/user/user_collect",
+        url: "/v1/api/front/game_list_favorite",
         data,
     });
 };
@@ -383,8 +385,9 @@ export const toggleFavorite = (data: { game_id: number }) => {
 };
 
 // 获取历史记录
-export const getGameHistory = () => {
+export const getGameHistory = (data: SearchProps) => {
     return server.post<GameListRep>({
         url: "/v1/api/front/game_list_history",
+        data,
     });
 };

+ 1 - 0
src/app/[locale]/(TabBar)/[[...share]]/_home/HomeGames.tsx

@@ -64,6 +64,7 @@ const HomeGames = (props: Props) => {
             </div> */}
 
             {groupGames.map((group, index) => {
+                console.log(group, index);
                 if (group.type === 2 && providers) {
                     return (
                         <React.Fragment>

+ 18 - 3
src/app/[locale]/(TabBar)/gameList/[[...gameListFlag]]/page.tsx

@@ -1,5 +1,12 @@
 "use client";
-import { Category, GameListRep, getGameHistory, searchGameListApi, SearchProps } from "@/api/home";
+import {
+    Category,
+    GameListRep,
+    getFavoriteList,
+    getGameHistory,
+    searchGameListApi,
+    SearchProps,
+} from "@/api/home";
 import Box from "@/components/Box";
 import GroupCard from "@/components/Card/GroupCard";
 import HeaderBack from "@/components/HeaderBack";
@@ -49,7 +56,10 @@ const GameListFlag: FC<Props> = (props) => {
             res = await searchGameListApi(params.current);
         }
         if (Number(pageType) === PageType.History) {
-            res = await getGameHistory();
+            res = await getGameHistory(params as any);
+        }
+        if (Number(pageType) === PageType.Favorite) {
+            res = await getFavoriteList(params as any);
         }
 
         if (res?.code === 200) {
@@ -66,7 +76,12 @@ const GameListFlag: FC<Props> = (props) => {
             <HeaderBack showBack={true} title={searchParams.name} />
             <main className={"main-header pb-[.8rem]"}>
                 <Box>
-                    <GroupCard data={target.games} row={1} />
+                    <GroupCard
+                        data={target.games}
+                        row={1}
+                        isShowFavorite={true}
+                        isShowOnline={true}
+                    />
                     <InfiniteScroll loadMore={loadMore} hasMore={!target?.page?.is_end!} />
                 </Box>
             </main>

+ 3 - 1
src/components/Card/Card.tsx

@@ -170,7 +170,9 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
                         height={"1.54rem"}
                         className={"h-[100%] w-[100%]"}
                     />
-                    {props.isShowOnline && <div className={styles.cardOnline}>2323 On-Line</div>}
+                    {props.isShowOnline && (
+                        <div className={styles.cardOnline}>{item?.online_user} On-Line</div>
+                    )}
                     {props.isShowFavorite && (
                         <div
                             className={clsx(styles.favorite, { [styles.active]: isFavorite })}

+ 5 - 1
src/components/Card/SwiperGroup.tsx

@@ -60,7 +60,11 @@ const HomeSwiper: FC<PropsWithChildren<SwiperGroupProps>> = (props) => {
     const swiperData: SwiperDataItem[] = useMemo(() => {
         const result: any = [];
         const pageNum = page * group.line_num - 1;
-        const canshowList = group.game_list.splice(0, group.line_config_amount);
+        const totalLenth = group.game_list.length;
+        const canshowList =
+            totalLenth > group.line_config_amount
+                ? group.game_list.splice(0, group.line_config_amount)
+                : group.game_list;
 
         const len =
             parseInt(`${canshowList.length / pageNum}`) +

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

@@ -49,7 +49,7 @@ const HomeProvider: React.FC<Props> = ({ data }) => {
     return (
         <div className={styles.container}>
             <div className="mb-[.15rem] flex items-center">
-                <img className="mr-[.1rem] w-[.3rem]" src={data.image} alt="" />
+                {data.image && <img className="mr-[.1rem] w-[.3rem]" src={data.image} alt="" />}
                 <div className="text-[.15rem] font-bold">{data.category_name}</div>
             </div>
             <div className={styles.privoderBox}>