1 Commits

Author SHA1 Message Date
筱野
ee579df162 修改详情弹出 2026-02-01 23:56:47 +08:00
2 changed files with 28 additions and 22 deletions

View File

@@ -63,7 +63,6 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
area, area,
cityQrCode, cityQrCode,
districts, districts,
fetchMatches,
gamesNum, // 新增:获取球局数量 gamesNum, // 新增:获取球局数量
} = store; } = store;
@@ -78,7 +77,6 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
pageOption, pageOption,
isShowNoData, isShowNoData,
} = listPageState || {}; } = listPageState || {};
console.log('===matches', matches)
const scrollContextRef = useRef(null); const scrollContextRef = useRef(null);
const scrollViewRef = useRef(null); const scrollViewRef = useRef(null);
@@ -94,8 +92,6 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
// 记录上一次加载数据时的城市,用于检测城市变化 // 记录上一次加载数据时的城市,用于检测城市变化
const lastLoadedAreaRef = useRef<[string, string] | null>(null); const lastLoadedAreaRef = useRef<[string, string] | null>(null);
const prevIsActiveRef = useRef(isActive); const prevIsActiveRef = useRef(isActive);
// 首次加载标记:避免切回 tab 时使用 isRefresh 导致智能排序顺序抖动
const hasLoadedOnceRef = useRef(false);
// 处理距离筛选显示/隐藏 // 处理距离筛选显示/隐藏
const handleDistanceFilterVisibleChange = useCallback( const handleDistanceFilterVisibleChange = useCallback(
@@ -234,14 +230,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
// 只有当页面激活时才加载位置和列表数据 // 只有当页面激活时才加载位置和列表数据
if (isActive) { if (isActive) {
const firstLoad = !hasLoadedOnceRef.current; getLocation().catch((error) => {
getLocation(firstLoad)
.then(() => {
if (firstLoad) {
hasLoadedOnceRef.current = true;
}
})
.catch((error) => {
console.error('获取位置信息失败:', error); console.error('获取位置信息失败:', error);
}); });
} }
@@ -370,7 +359,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
}; };
}, []); }, []);
const getLocation = async (useRefresh = true) => { const getLocation = async () => {
const location = await getCurrentLocationInfo(); const location = await getCurrentLocationInfo();
updateState({ location }); updateState({ location });
if (location && location.latitude && location.longitude) { if (location && location.latitude && location.longitude) {
@@ -381,7 +370,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
} }
} }
// 先调用列表接口 // 先调用列表接口
await fetchMatches({}, useRefresh); await getMatchesData();
// 列表接口完成后,再调用数量接口 // 列表接口完成后,再调用数量接口
await fetchGetGamesCount(); await fetchGetGamesCount();
// 初始数据加载完成后,记录当前城市 // 初始数据加载完成后,记录当前城市

View File

@@ -1,4 +1,4 @@
import React, { useState, useCallback, forwardRef, useImperativeHandle, useEffect } from 'react' import React, { useState, useCallback, forwardRef, useImperativeHandle } from 'react'
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import { View, Text, Image, ScrollView } from '@tarojs/components' import { View, Text, Image, ScrollView } from '@tarojs/components'
import images from '@/config/images' import images from '@/config/images'
@@ -70,6 +70,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
onAnyInput onAnyInput
}, ref) => { }, ref) => {
const [openPicker, setOpenPicker] = useState(false); const [openPicker, setOpenPicker] = useState(false);
const [scrollTop, setScrollTop] = useState(0);
const { getDictionaryValue } = useDictionaryActions() const { getDictionaryValue } = useDictionaryActions()
const court_type = getDictionaryValue('court_type') || [] const court_type = getDictionaryValue('court_type') || []
const court_surface = getDictionaryValue('court_surface') || [] const court_surface = getDictionaryValue('court_surface') || []
@@ -170,14 +171,27 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
const changeTextarea = (value) => {
if (value) {
// 先滚动到底部
setScrollTop(scrollTop ? scrollTop + 1 : 9999);
// 使用 setTimeout 确保滚动后再更新 openPicker
}
}
const changePicker = (value) => { const changePicker = (value) => {
setOpenPicker(value) setOpenPicker(value);
} }
console.log(stadium,'stadiumstadium'); console.log(stadium,'stadiumstadium');
return ( return (
<View className='stadium-detail'> <View className='stadium-detail'>
<ScrollView className='stadium-detail-scroll' refresherBackground="#FAFAFA" scrollY={!openPicker}> <ScrollView
className='stadium-detail-scroll'
refresherBackground="#FAFAFA"
scrollY={!openPicker}
scrollTop={scrollTop}
>
{/* 已选球场 */} {/* 已选球场 */}
<View <View
className={`stadium-item`} className={`stadium-item`}
@@ -220,9 +234,12 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
<View className='textarea-tag-container'> <View className='textarea-tag-container'>
<TextareaTag <TextareaTag
value={formData[item.prop]} value={formData[item.prop]}
onChange={(value) => updateFormData(item.prop, value)} onChange={(value) => {
onBlur={() => changePicker(false)} changeTextarea(true)
onFocus={() => changePicker(true)} updateFormData(item.prop, value)
}}
// onBlur={() => changeTextarea(false)}
onFocus={() => changeTextarea(true)}
placeholder='有其他场地信息可备注' placeholder='有其他场地信息可备注'
options={(item.options || []).map((o) => ({ label: o, value: o }))} options={(item.options || []).map((o) => ({ label: o, value: o }))}
/> />