列表接口
This commit is contained in:
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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 { getDictionaryValue } = useDictionaryActions() || {};
|
||||
console.log('===getDictionaryValue', getDictionaryValue('court_type'));
|
||||
// locationOptions 室内
|
||||
// game_play 玩法
|
||||
const {
|
||||
isShowFilterPopup,
|
||||
error,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user