From 1cb303b86d495313ceb5a33ea38029e266f0bec9 Mon Sep 17 00:00:00 2001 From: juguohong Date: Sat, 30 Aug 2025 13:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ListCard/index.tsx | 18 +++++++----------- src/pages/list/index.tsx | 9 ++++++--- src/services/listApi.ts | 10 ++++------ src/store/listStore.ts | 8 +++++--- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/components/ListCard/index.tsx b/src/components/ListCard/index.tsx index c91b3d3..ffaca58 100644 --- a/src/components/ListCard/index.tsx +++ b/src/components/ListCard/index.tsx @@ -3,7 +3,6 @@ import Taro from '@tarojs/taro' import img from "../../config/images"; import { ListCardProps } from "../../../types/list/types"; import "./index.scss"; -// import SkeletonComponent from "../../components/Skeleton"; const ListCard: React.FC = ({ id, @@ -15,7 +14,7 @@ const ListCard: React.FC = ({ maxCount, skillLevel, matchType, - images, + images=[], shinei, }) => { const renderItemImage = (src: string) => { @@ -30,28 +29,25 @@ const ListCard: React.FC = ({ // 根据图片数量决定展示样式 const renderImages = () => { - if (images.length === 0) return null; + if (images?.length === 0) return null; - if (images.length === 1) { + if (images?.length === 1) { return ( - {/* */} {renderItemImage(images[0])} ); } - if (images.length === 2) { + if (images?.length === 2) { return ( - {/* */} {renderItemImage(images[0])} - {/* */} {renderItemImage(images[1])} @@ -61,9 +57,9 @@ const ListCard: React.FC = ({ // 3张或更多图片 return ( - {renderItemImage(images[0])} - {renderItemImage(images[1])} - {renderItemImage(images[2])} + {renderItemImage(images?.[0])} + {renderItemImage(images?.[1])} + {renderItemImage(images?.[2])} ); }; diff --git a/src/pages/list/index.tsx b/src/pages/list/index.tsx index 220117b..3e2794e 100644 --- a/src/pages/list/index.tsx +++ b/src/pages/list/index.tsx @@ -13,14 +13,17 @@ import {useGlobalState} from '@/store/global' import { View } from "@tarojs/components"; import CustomerNavBar from "@/components/CustomNavbar"; import GuideBar from "@/components/GuideBar"; +import { useDictionaryActions } from "@/store/dictionaryStore"; const ListPage = () => { // 从 store 获取数据和方法 const store = useListStore() || {}; - const {statusNavbarHeightInfo } = useGlobalState() || {} - // console.log("===store===", store); - // console.log('===statusNavbarHeightInfo', statusNavbarHeightInfo) + const { statusNavbarHeightInfo } = useGlobalState() || {} + const { getDictionaryValue } = useDictionaryActions() || {}; + console.log('===getDictionaryValue', getDictionaryValue('court_type')); + // locationOptions 室内 + // game_play 玩法 const { isShowFilterPopup, error, diff --git a/src/services/listApi.ts b/src/services/listApi.ts index 77ebd65..eec41ca 100644 --- a/src/services/listApi.ts +++ b/src/services/listApi.ts @@ -1,4 +1,5 @@ import { TennisMatch } from "../store/listStore"; +import httpService from "./httpService"; // 模拟网络延迟 const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); @@ -91,14 +92,11 @@ export const getTennisMatches = async (params?: { pageSize?: number; location?: string; skillLevel?: string; -}): Promise => { +}) => { try { - // 生成动态数据 - const matches = generateDynamicData(); - - return matches; + return httpService.post('/venues/list', params, { showLoading: false }) } catch (error) { - console.error("API调用失败:", error); + console.error("列表数据获取失败:", error); throw error; } }; diff --git a/src/store/listStore.ts b/src/store/listStore.ts index b3fe98e..75454f6 100644 --- a/src/store/listStore.ts +++ b/src/store/listStore.ts @@ -81,11 +81,13 @@ export const useListStore = create()((set, get) => ({ set({ loading: true, error: null }) try { - const matches = await getTennisMatches(params) + const resData = await getTennisMatches(params) || {}; + const { data = {}, code } = resData; + const { count, rows } = data; set({ - matches, + matches: rows || [], loading: false, - lastRefreshTime: new Date().toISOString() + // lastRefreshTime: new Date().toISOString() }) } catch (error) {