列表接口

This commit is contained in:
juguohong
2025-08-30 13:40:25 +08:00
parent f0b02e832f
commit 1cb303b86d
4 changed files with 22 additions and 23 deletions

View File

@@ -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<ListCardProps> = ({
id,
@@ -15,7 +14,7 @@ const ListCard: React.FC<ListCardProps> = ({
maxCount,
skillLevel,
matchType,
images,
images=[],
shinei,
}) => {
const renderItemImage = (src: string) => {
@@ -30,28 +29,25 @@ const ListCard: React.FC<ListCardProps> = ({
// 根据图片数量决定展示样式
const renderImages = () => {
if (images.length === 0) return null;
if (images?.length === 0) return null;
if (images.length === 1) {
if (images?.length === 1) {
return (
<View className="single-image">
<View className="image-container">
{/* <Image src={images[0]} className="image" mode="aspectFill" /> */}
{renderItemImage(images[0])}
</View>
</View>
);
}
if (images.length === 2) {
if (images?.length === 2) {
return (
<View className="double-image">
<View className="image-container">
{/* <Image src={images[0]} className="image" mode="aspectFill" /> */}
{renderItemImage(images[0])}
</View>
<View className="image-container">
{/* <Image src={images[1]} className="image" mode="aspectFill" /> */}
{renderItemImage(images[1])}
</View>
</View>
@@ -61,9 +57,9 @@ const ListCard: React.FC<ListCardProps> = ({
// 3张或更多图片
return (
<View className="triple-image">
<View className="image-container">{renderItemImage(images[0])}</View>
<View className="image-container">{renderItemImage(images[1])}</View>
<View className="image-container">{renderItemImage(images[2])}</View>
<View className="image-container">{renderItemImage(images?.[0])}</View>
<View className="image-container">{renderItemImage(images?.[1])}</View>
<View className="image-container">{renderItemImage(images?.[2])}</View>
</View>
);
};

View File

@@ -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,

View File

@@ -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<TennisMatch[]> => {
}) => {
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;
}
};

View File

@@ -81,11 +81,13 @@ export const useListStore = create<TennisStore>()((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) {