列表页获取位置信息

This commit is contained in:
李瑞
2025-09-08 22:36:17 +08:00
parent 9b508a2bf9
commit 2e3458d606
4 changed files with 21 additions and 19 deletions

View File

@@ -12,12 +12,13 @@ import ListContainer from "@/container/listContainer";
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
import { withAuth } from "@/components";
// import img from "@/config/images";
// import ShareCardCanvas from "@/components/ShareCardCanvas/example";
const ListPage = () => {
// 从 store 获取数据和方法
const store = useListStore() || {};
const { statusNavbarHeightInfo, location = {} } = useGlobalState() || {};
const { statusNavbarHeightInfo, location = {}, getCurrentLocationInfo } = useGlobalState() || {};
const { totalHeight } = statusNavbarHeightInfo || {};
const {
isShowFilterPopup,
@@ -53,13 +54,18 @@ const ListPage = () => {
});
useEffect(() => {
if (location?.address) {
// 保存位置
updateState({ location });
// 页面加载时获取数据
getMatchesData();
}
}, [location]);
getLocation()
}, []);
// 获取位置信息
const getLocation = async () => {
const location = await getCurrentLocationInfo()
// 保存位置
updateState({ location });
// 页面加载时获取数据
getMatchesData();
return location;
}
const refreshMatches = () => {
initialFilterSearch();
@@ -133,6 +139,7 @@ const ListPage = () => {
<View>
{/* 自定义导航 */}
<CustomerNavBar />
{/* <ShareCardCanvas /> */}
<View className={styles.listPage}>
<View
className={`${styles.listTopSearchWrapper} ${