提交 e2ef8e18 编写于 作者: Q qiang

fix(h5): 选择地点支持扩大搜索范围 fixed #2453 #2434

上级 8c2eee57
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
{{ item.name }} {{ item.name }}
</div> </div>
<div class="list-item-detail"> <div class="list-item-detail">
{{ item.distance ? item.distance + "米 | " : "" }}{{ item.address }} {{ item.distance | distance }}{{ item.address }}
</div> </div>
</div> </div>
</v-uni-scroll-view> </v-uni-scroll-view>
...@@ -95,6 +95,17 @@ const key = __uniConfig.qqMapKey ...@@ -95,6 +95,17 @@ const key = __uniConfig.qqMapKey
export default { export default {
name: 'SystemChooseLocation', 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 () { data () {
return { return {
latitude: 0, latitude: 0,
...@@ -105,12 +116,16 @@ export default { ...@@ -105,12 +116,16 @@ export default {
list: [], list: [],
keyword: '', keyword: '',
searching: false, searching: false,
loading: true loading: true,
adcode: ''
} }
}, },
computed: { computed: {
selected () { selected () {
return this.list[this.selectedIndex] return this.list[this.selectedIndex]
},
boundary () {
return this.adcode ? `region(${this.adcode},1,${this.latitude},${this.longitude})` : `nearby(${this.latitude},${this.longitude},5000)`
} }
}, },
created () { created () {
...@@ -173,7 +188,7 @@ export default { ...@@ -173,7 +188,7 @@ export default {
}, },
_getList () { _getList () {
this.loading = true 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 列表加载失败提示 // TODO 列表加载失败提示
getJSONP(url, { getJSONP(url, {
callback: 'callback' callback: 'callback'
...@@ -181,8 +196,12 @@ export default { ...@@ -181,8 +196,12 @@ export default {
this.loading = false this.loading = false
if (this.searching && 'data' in res && res.data.length) { if (this.searching && 'data' in res && res.data.length) {
this._pushData(res.data) this._pushData(res.data)
} else if ('result' in res && res.result.pois) { } else if ('result' in res) {
this._pushData(res.result.pois) const result = res.result
this.adcode = result.ad_info ? result.ad_info.adcode : ''
if (result.pois) {
this._pushData(result.pois)
}
} }
}, () => { }, () => {
this.loading = false this.loading = false
...@@ -234,10 +253,10 @@ export default { ...@@ -234,10 +253,10 @@ export default {
.uni-system-choose-location .map { .uni-system-choose-location .map {
position: absolute; position: absolute;
top: -40px; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 380px; height: 300px;
} }
.uni-system-choose-location .map-location { .uni-system-choose-location .map-location {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册