diff --git a/src/app.ts b/src/app.ts index 03ca3a2..baff6c5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -22,7 +22,7 @@ class App extends Component { // 初始化字典数据 this.initDictionaryData() this.getNavBarHeight() - this.getLocation() + // this.getLocation() } componentDidShow() { } @@ -46,10 +46,10 @@ class App extends Component { } // 获取位置信息 - getLocation = () => { - const { getCurrentLocationInfo } = useGlobalStore.getState() - getCurrentLocationInfo() - } + // getLocation = () => { + // const { getCurrentLocationInfo } = useGlobalStore.getState() + // getCurrentLocationInfo() + // } render() { // this.props.children 是将要会渲染的页面 diff --git a/src/pages/list/index.tsx b/src/pages/list/index.tsx index 46f7c5e..51869fb 100644 --- a/src/pages/list/index.tsx +++ b/src/pages/list/index.tsx @@ -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 = () => { {/* 自定义导航 */} + {/* */} ()((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()((set, get) => ({ ...params, }; + // 是否选择了智能排序 const isIntegrate = distanceQuickFilter?.quick === "0"; let fetchFn = getGamesList; diff --git a/types/list/types.ts b/types/list/types.ts index 69393c9..1b36d8b 100644 --- a/types/list/types.ts +++ b/types/list/types.ts @@ -37,8 +37,6 @@ export interface ListState { isShowFilterPopup: boolean filterOptions: IFilterOptions filterCount: number - // distance: string | number - quickFilter: string | number distanceData: any[] quickFilterData: any[] distanceQuickFilter: {