列表接口
This commit is contained in:
@@ -3,7 +3,6 @@ import Taro from '@tarojs/taro'
|
|||||||
import img from "../../config/images";
|
import img from "../../config/images";
|
||||||
import { ListCardProps } from "../../../types/list/types";
|
import { ListCardProps } from "../../../types/list/types";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
// import SkeletonComponent from "../../components/Skeleton";
|
|
||||||
|
|
||||||
const ListCard: React.FC<ListCardProps> = ({
|
const ListCard: React.FC<ListCardProps> = ({
|
||||||
id,
|
id,
|
||||||
@@ -15,7 +14,7 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
maxCount,
|
maxCount,
|
||||||
skillLevel,
|
skillLevel,
|
||||||
matchType,
|
matchType,
|
||||||
images,
|
images=[],
|
||||||
shinei,
|
shinei,
|
||||||
}) => {
|
}) => {
|
||||||
const renderItemImage = (src: string) => {
|
const renderItemImage = (src: string) => {
|
||||||
@@ -30,28 +29,25 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
|
|
||||||
// 根据图片数量决定展示样式
|
// 根据图片数量决定展示样式
|
||||||
const renderImages = () => {
|
const renderImages = () => {
|
||||||
if (images.length === 0) return null;
|
if (images?.length === 0) return null;
|
||||||
|
|
||||||
if (images.length === 1) {
|
if (images?.length === 1) {
|
||||||
return (
|
return (
|
||||||
<View className="single-image">
|
<View className="single-image">
|
||||||
<View className="image-container">
|
<View className="image-container">
|
||||||
{/* <Image src={images[0]} className="image" mode="aspectFill" /> */}
|
|
||||||
{renderItemImage(images[0])}
|
{renderItemImage(images[0])}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (images.length === 2) {
|
if (images?.length === 2) {
|
||||||
return (
|
return (
|
||||||
<View className="double-image">
|
<View className="double-image">
|
||||||
<View className="image-container">
|
<View className="image-container">
|
||||||
{/* <Image src={images[0]} className="image" mode="aspectFill" /> */}
|
|
||||||
{renderItemImage(images[0])}
|
{renderItemImage(images[0])}
|
||||||
</View>
|
</View>
|
||||||
<View className="image-container">
|
<View className="image-container">
|
||||||
{/* <Image src={images[1]} className="image" mode="aspectFill" /> */}
|
|
||||||
{renderItemImage(images[1])}
|
{renderItemImage(images[1])}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -61,9 +57,9 @@ const ListCard: React.FC<ListCardProps> = ({
|
|||||||
// 3张或更多图片
|
// 3张或更多图片
|
||||||
return (
|
return (
|
||||||
<View className="triple-image">
|
<View className="triple-image">
|
||||||
<View className="image-container">{renderItemImage(images[0])}</View>
|
<View className="image-container">{renderItemImage(images?.[0])}</View>
|
||||||
<View className="image-container">{renderItemImage(images[1])}</View>
|
<View className="image-container">{renderItemImage(images?.[1])}</View>
|
||||||
<View className="image-container">{renderItemImage(images[2])}</View>
|
<View className="image-container">{renderItemImage(images?.[2])}</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,14 +13,17 @@ import {useGlobalState} from '@/store/global'
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
import CustomerNavBar from "@/components/CustomNavbar";
|
import CustomerNavBar from "@/components/CustomNavbar";
|
||||||
import GuideBar from "@/components/GuideBar";
|
import GuideBar from "@/components/GuideBar";
|
||||||
|
import { useDictionaryActions } from "@/store/dictionaryStore";
|
||||||
|
|
||||||
const ListPage = () => {
|
const ListPage = () => {
|
||||||
// 从 store 获取数据和方法
|
// 从 store 获取数据和方法
|
||||||
const store = useListStore() || {};
|
const store = useListStore() || {};
|
||||||
|
|
||||||
const { statusNavbarHeightInfo } = useGlobalState() || {}
|
const { statusNavbarHeightInfo } = useGlobalState() || {}
|
||||||
// console.log("===store===", store);
|
const { getDictionaryValue } = useDictionaryActions() || {};
|
||||||
// console.log('===statusNavbarHeightInfo', statusNavbarHeightInfo)
|
console.log('===getDictionaryValue', getDictionaryValue('court_type'));
|
||||||
|
// locationOptions 室内
|
||||||
|
// game_play 玩法
|
||||||
const {
|
const {
|
||||||
isShowFilterPopup,
|
isShowFilterPopup,
|
||||||
error,
|
error,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { TennisMatch } from "../store/listStore";
|
import { TennisMatch } from "../store/listStore";
|
||||||
|
import httpService from "./httpService";
|
||||||
|
|
||||||
// 模拟网络延迟
|
// 模拟网络延迟
|
||||||
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
@@ -91,14 +92,11 @@ export const getTennisMatches = async (params?: {
|
|||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
location?: string;
|
location?: string;
|
||||||
skillLevel?: string;
|
skillLevel?: string;
|
||||||
}): Promise<TennisMatch[]> => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
// 生成动态数据
|
return httpService.post('/venues/list', params, { showLoading: false })
|
||||||
const matches = generateDynamicData();
|
|
||||||
|
|
||||||
return matches;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("API调用失败:", error);
|
console.error("列表数据获取失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -81,11 +81,13 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
|||||||
set({ loading: true, error: null })
|
set({ loading: true, error: null })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const matches = await getTennisMatches(params)
|
const resData = await getTennisMatches(params) || {};
|
||||||
|
const { data = {}, code } = resData;
|
||||||
|
const { count, rows } = data;
|
||||||
set({
|
set({
|
||||||
matches,
|
matches: rows || [],
|
||||||
loading: false,
|
loading: false,
|
||||||
lastRefreshTime: new Date().toISOString()
|
// lastRefreshTime: new Date().toISOString()
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user