From ef4889ba2eadf7c3df6982a63c69ebb26e5abaaf Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Fri, 26 Aug 2022 14:55:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20H5=E9=AB=98=E5=BE=B7=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E4=BD=8D=E7=BD=AE=E6=90=9C=E7=B4=A2=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system-routes/choose-location/index.vue | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/platforms/h5/components/system-routes/choose-location/index.vue b/src/platforms/h5/components/system-routes/choose-location/index.vue index b4466a27e..6bf292a0f 100644 --- a/src/platforms/h5/components/system-routes/choose-location/index.vue +++ b/src/platforms/h5/components/system-routes/choose-location/index.vue @@ -269,33 +269,22 @@ export default { const self = this window.AMap.plugin('AMap.PlaceSearch', function () { - var autoOptions = { + const placeSearch = new window.AMap.PlaceSearch({ city: '全国', pageSize: 10, pageIndex: self.pageIndex - } - var placeSearch = new window.AMap.PlaceSearch(autoOptions) - if (self.searching) { - placeSearch.searchNearBy(self.keyword, [self.longitude, self.latitude], 50000, function (status, result) { - if (status === 'error') { - console.error(result) - } else if (status === 'no_data') { - self.hasNextPage = false - } else { - self.pushData(result.poiList.pois) - } - }) - } else { - placeSearch.searchNearBy('', [self.longitude, self.latitude], 5000, function (status, result) { - if (status === 'error') { - console.error(result) - } else if (status === 'no_data') { - self.hasNextPage = false - } else { - self.pushData(result.poiList.pois) - } - }) - } + }) + const keyword = self.searching ? self.keyword : '' + const radius = self.searching ? 50000 : 5000 + placeSearch.searchNearBy(keyword, [self.longitude, self.latitude], radius, function (status, result) { + if (status === 'error') { + console.error(result) + } else if (status === 'no_data') { + self.hasNextPage = false + } else { + self.pushData(result.poiList.pois) + } + }) self.loading = false }) } -- GitLab