列表页获取位置信息
This commit is contained in:
10
src/app.ts
10
src/app.ts
@@ -22,7 +22,7 @@ class App extends Component<AppProps> {
|
||||
// 初始化字典数据
|
||||
this.initDictionaryData()
|
||||
this.getNavBarHeight()
|
||||
this.getLocation()
|
||||
// this.getLocation()
|
||||
}
|
||||
|
||||
componentDidShow() { }
|
||||
@@ -46,10 +46,10 @@ class App extends Component<AppProps> {
|
||||
}
|
||||
|
||||
// 获取位置信息
|
||||
getLocation = () => {
|
||||
const { getCurrentLocationInfo } = useGlobalStore.getState()
|
||||
getCurrentLocationInfo()
|
||||
}
|
||||
// getLocation = () => {
|
||||
// const { getCurrentLocationInfo } = useGlobalStore.getState()
|
||||
// getCurrentLocationInfo()
|
||||
// }
|
||||
|
||||
render() {
|
||||
// this.props.children 是将要会渲染的页面
|
||||
|
||||
@@ -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} ${
|
||||
|
||||
@@ -63,10 +63,6 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
filterOptions: defaultFilterOptions,
|
||||
// 综合筛选 选择的筛选数量
|
||||
filterCount: 0,
|
||||
// 距离筛选
|
||||
// distance: defaultDistance,
|
||||
// 快捷筛选
|
||||
quickFilter: 1, // 1: 默认 2: 好评 3: 销量
|
||||
// 距离筛选数据
|
||||
distanceData: [
|
||||
{ id: 0, label: "全城", value: "" },
|
||||
@@ -171,6 +167,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
||||
...params,
|
||||
};
|
||||
|
||||
// 是否选择了智能排序
|
||||
const isIntegrate = distanceQuickFilter?.quick === "0";
|
||||
let fetchFn = getGamesList;
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ export interface ListState {
|
||||
isShowFilterPopup: boolean
|
||||
filterOptions: IFilterOptions
|
||||
filterCount: number
|
||||
// distance: string | number
|
||||
quickFilter: string | number
|
||||
distanceData: any[]
|
||||
quickFilterData: any[]
|
||||
distanceQuickFilter: {
|
||||
|
||||
Reference in New Issue
Block a user