diff --git a/packages/uni-h5/src/service/api/location/chooseLocation/LoctaionPicker.tsx b/packages/uni-h5/src/service/api/location/chooseLocation/LoctaionPicker.tsx index 7af21004fa685d5146a3ac009d7765170ea87e61..c1c117678eace1ebe126de96c03f529fdec7bfd6 100644 --- a/packages/uni-h5/src/service/api/location/chooseLocation/LoctaionPicker.tsx +++ b/packages/uni-h5/src/service/api/location/chooseLocation/LoctaionPicker.tsx @@ -188,43 +188,27 @@ function useList(state: State) { ) } else if (mapInfo.type === MapType.AMAP) { window.AMap.plugin('AMap.PlaceSearch', function () { - var autoOptions = { + const placeSearch = new (window.AMap as any).PlaceSearch({ city: '全国', pageSize: 10, pageIndex: listState.pageIndex, - } - var placeSearch = new (window.AMap as any).PlaceSearch(autoOptions) - if (state.searching) { - placeSearch.searchNearBy( - state.keyword, - [state.longitude, state.latitude], - 50000, - function (status: string, result: any) { - if (status === 'error') { - console.error(result) - } else if (status === 'no_data') { - listState.hasNextPage = false - } else { - pushData(result.poiList.pois) - } - } - ) - } else { - placeSearch.searchNearBy( - '', - [state.longitude, state.latitude], - 5000, - function (status: string, result: any) { - if (status === 'error') { - console.error(result) - } else if (status === 'no_data') { - listState.hasNextPage = false - } else { - pushData(result.poiList.pois) - } + }) + const keyword = state.searching?state.keyword:'' + const radius = state.searching?50000:5000 + placeSearch.searchNearBy( + keyword, + [state.longitude, state.latitude], + radius, + function (status: string, result: any) { + if (status === 'error') { + console.error(result) + } else if (status === 'no_data') { + listState.hasNextPage = false + } else { + pushData(result.poiList.pois) } - ) - } + } + ) listState.loading = false }) }