diff --git a/app/(tabs)/top.tsx b/app/(tabs)/top.tsx index 724d24c..f4d9008 100644 --- a/app/(tabs)/top.tsx +++ b/app/(tabs)/top.tsx @@ -28,6 +28,12 @@ interface LocationData { export default function OwnerPage() { const insets = useSafeAreaInsets(); const router = useRouter(); + const HOT_CITIES = [ + ['北京', '上海', '广州', '深圳'], + ['杭州', '成都', '乌鲁木齐', '武汉'], + ['西安', '重庆', '西宁', '哈尔滨'], + ['长沙', '南宁', '贵阳', '昆明'] + ]; // 位置搜索数据 const [locationSearch, setLocationSearch] = useState(''); // 位置弹窗 @@ -166,6 +172,11 @@ export default function OwnerPage() { }; }, [fetchLocationData]); + useEffect(() => { + // console.log(locationData); + + }, [locationSearch]) + return ( { Keyboard.dismiss(); @@ -211,9 +222,8 @@ export default function OwnerPage() { onChangeText={setLocationSearch} value={locationSearch} placeholder="输入城市名进行搜索" - onEndEditing={() => { - console.log('输入完成'); - // 在这里执行搜索或其他操作 + onEndEditing={(text) => { + setLocationSearch(text.nativeEvent.text) }} /> @@ -233,30 +243,24 @@ export default function OwnerPage() { {/* 热门城市 */} 热门城市 - - 北京 - 上海 - 广州 - 深圳 - - - 杭州 - 成都 - 乌鲁木齐 - 武汉 - - - 西安 - 重庆 - 西宁 - 哈尔滨 - - - 长沙 - 南宁 - 贵阳 - 昆明 - + {HOT_CITIES.map((row, rowIndex) => ( + + {row.map((city, cityIndex) => ( + { + setLocationSearch(city); + }} + > + {city} + + ))} + + ))} @@ -312,7 +316,6 @@ const styles = StyleSheet.create({ borderRadius: 24, paddingLeft: 40, // 给图标留出空间 paddingVertical: 8, - color: '#4C320C', paddingRight: 16, fontSize: 14, lineHeight: 16, @@ -337,5 +340,12 @@ const styles = StyleSheet.create({ backgroundColor: "#FBFBFB", padding: 16, borderRadius: 24 + }, + cityRow: { + display: 'flex', + flexDirection: 'row', + flexWrap: 'wrap', + justifyContent: 'space-between', + marginBottom: 16 } }); \ No newline at end of file