From e2ef8e185e0d21917b5f1f2421c1aa042e3a63c3 Mon Sep 17 00:00:00 2001 From: qiang Date: Wed, 24 Mar 2021 14:18:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(h5):=20=E9=80=89=E6=8B=A9=E5=9C=B0=E7=82=B9?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=A9=E5=A4=A7=E6=90=9C=E7=B4=A2=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=20fixed=20#2453=20#2434?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system-routes/choose-location/index.vue | 59 ++++++++++++------- 1 file changed, 39 insertions(+), 20 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 0b8555c88..2f81917fc 100644 --- a/src/platforms/h5/components/system-routes/choose-location/index.vue +++ b/src/platforms/h5/components/system-routes/choose-location/index.vue @@ -9,17 +9,17 @@ @regionchange="_regionchange" >
-
- -
@@ -77,7 +77,7 @@ {{ item.name }}
- {{ item.distance ? item.distance + "米 | " : "" }}{{ item.address }} + {{ item.distance | distance }}{{ item.address }}
@@ -95,6 +95,17 @@ const key = __uniConfig.qqMapKey export default { name: 'SystemChooseLocation', + filters: { + distance (distance) { + if (distance > 100) { + return `${distance > 1000 ? (distance / 1000).toFixed(1) + 'k' : distance.toFixed(0)}m | ` + } else if (distance > 0) { + return '100m内 | ' + } else { + return '' + } + } + }, data () { return { latitude: 0, @@ -105,12 +116,16 @@ export default { list: [], keyword: '', searching: false, - loading: true + loading: true, + adcode: '' } }, computed: { selected () { return this.list[this.selectedIndex] + }, + boundary () { + return this.adcode ? `region(${this.adcode},1,${this.latitude},${this.longitude})` : `nearby(${this.latitude},${this.longitude},5000)` } }, created () { @@ -173,7 +188,7 @@ export default { }, _getList () { this.loading = true - const url = this.searching ? `https://apis.map.qq.com/ws/place/v1/search?output=jsonp&key=${key}&boundary=nearby(${this.latitude},${this.longitude},1000)&keyword=${this.keyword}&page_size=${this.pageSize}&page_index=${this.pageIndex}` : `https://apis.map.qq.com/ws/geocoder/v1/?output=jsonp&key=${key}&location=${this.latitude},${this.longitude}&get_poi=1&poi_options=page_size=${this.pageSize};page_index=${this.pageIndex}` + const url = this.searching ? `https://apis.map.qq.com/ws/place/v1/search?output=jsonp&key=${key}&boundary=${this.boundary}&keyword=${this.keyword}&page_size=${this.pageSize}&page_index=${this.pageIndex}` : `https://apis.map.qq.com/ws/geocoder/v1/?output=jsonp&key=${key}&location=${this.latitude},${this.longitude}&get_poi=1&poi_options=page_size=${this.pageSize};page_index=${this.pageIndex}` // TODO 列表加载失败提示 getJSONP(url, { callback: 'callback' @@ -181,8 +196,12 @@ export default { this.loading = false if (this.searching && 'data' in res && res.data.length) { this._pushData(res.data) - } else if ('result' in res && res.result.pois) { - this._pushData(res.result.pois) + } else if ('result' in res) { + const result = res.result + this.adcode = result.ad_info ? result.ad_info.adcode : '' + if (result.pois) { + this._pushData(result.pois) + } } }, () => { this.loading = false @@ -234,10 +253,10 @@ export default { .uni-system-choose-location .map { position: absolute; - top: -40px; + top: 0; left: 0; width: 100%; - height: 380px; + height: 300px; } .uni-system-choose-location .map-location { -- GitLab