列表页获取位置信息
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.initDictionaryData()
|
||||||
this.getNavBarHeight()
|
this.getNavBarHeight()
|
||||||
this.getLocation()
|
// this.getLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidShow() { }
|
componentDidShow() { }
|
||||||
@@ -46,10 +46,10 @@ class App extends Component<AppProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取位置信息
|
// 获取位置信息
|
||||||
getLocation = () => {
|
// getLocation = () => {
|
||||||
const { getCurrentLocationInfo } = useGlobalStore.getState()
|
// const { getCurrentLocationInfo } = useGlobalStore.getState()
|
||||||
getCurrentLocationInfo()
|
// getCurrentLocationInfo()
|
||||||
}
|
// }
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// this.props.children 是将要会渲染的页面
|
// this.props.children 是将要会渲染的页面
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ import ListContainer from "@/container/listContainer";
|
|||||||
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
||||||
import { withAuth } from "@/components";
|
import { withAuth } from "@/components";
|
||||||
// import img from "@/config/images";
|
// import img from "@/config/images";
|
||||||
|
// import ShareCardCanvas from "@/components/ShareCardCanvas/example";
|
||||||
|
|
||||||
const ListPage = () => {
|
const ListPage = () => {
|
||||||
// 从 store 获取数据和方法
|
// 从 store 获取数据和方法
|
||||||
const store = useListStore() || {};
|
const store = useListStore() || {};
|
||||||
|
|
||||||
const { statusNavbarHeightInfo, location = {} } = useGlobalState() || {};
|
const { statusNavbarHeightInfo, location = {}, getCurrentLocationInfo } = useGlobalState() || {};
|
||||||
const { totalHeight } = statusNavbarHeightInfo || {};
|
const { totalHeight } = statusNavbarHeightInfo || {};
|
||||||
const {
|
const {
|
||||||
isShowFilterPopup,
|
isShowFilterPopup,
|
||||||
@@ -53,13 +54,18 @@ const ListPage = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (location?.address) {
|
getLocation()
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 获取位置信息
|
||||||
|
const getLocation = async () => {
|
||||||
|
const location = await getCurrentLocationInfo()
|
||||||
// 保存位置
|
// 保存位置
|
||||||
updateState({ location });
|
updateState({ location });
|
||||||
// 页面加载时获取数据
|
// 页面加载时获取数据
|
||||||
getMatchesData();
|
getMatchesData();
|
||||||
|
return location;
|
||||||
}
|
}
|
||||||
}, [location]);
|
|
||||||
|
|
||||||
const refreshMatches = () => {
|
const refreshMatches = () => {
|
||||||
initialFilterSearch();
|
initialFilterSearch();
|
||||||
@@ -133,6 +139,7 @@ const ListPage = () => {
|
|||||||
<View>
|
<View>
|
||||||
{/* 自定义导航 */}
|
{/* 自定义导航 */}
|
||||||
<CustomerNavBar />
|
<CustomerNavBar />
|
||||||
|
{/* <ShareCardCanvas /> */}
|
||||||
<View className={styles.listPage}>
|
<View className={styles.listPage}>
|
||||||
<View
|
<View
|
||||||
className={`${styles.listTopSearchWrapper} ${
|
className={`${styles.listTopSearchWrapper} ${
|
||||||
|
|||||||
@@ -63,10 +63,6 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
|||||||
filterOptions: defaultFilterOptions,
|
filterOptions: defaultFilterOptions,
|
||||||
// 综合筛选 选择的筛选数量
|
// 综合筛选 选择的筛选数量
|
||||||
filterCount: 0,
|
filterCount: 0,
|
||||||
// 距离筛选
|
|
||||||
// distance: defaultDistance,
|
|
||||||
// 快捷筛选
|
|
||||||
quickFilter: 1, // 1: 默认 2: 好评 3: 销量
|
|
||||||
// 距离筛选数据
|
// 距离筛选数据
|
||||||
distanceData: [
|
distanceData: [
|
||||||
{ id: 0, label: "全城", value: "" },
|
{ id: 0, label: "全城", value: "" },
|
||||||
@@ -171,6 +167,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
|||||||
...params,
|
...params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 是否选择了智能排序
|
||||||
const isIntegrate = distanceQuickFilter?.quick === "0";
|
const isIntegrate = distanceQuickFilter?.quick === "0";
|
||||||
let fetchFn = getGamesList;
|
let fetchFn = getGamesList;
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ export interface ListState {
|
|||||||
isShowFilterPopup: boolean
|
isShowFilterPopup: boolean
|
||||||
filterOptions: IFilterOptions
|
filterOptions: IFilterOptions
|
||||||
filterCount: number
|
filterCount: number
|
||||||
// distance: string | number
|
|
||||||
quickFilter: string | number
|
|
||||||
distanceData: any[]
|
distanceData: any[]
|
||||||
quickFilterData: any[]
|
quickFilterData: any[]
|
||||||
distanceQuickFilter: {
|
distanceQuickFilter: {
|
||||||
|
|||||||
Reference in New Issue
Block a user