vue2-client 1.8.241 → 1.8.242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -170,7 +170,9 @@ export default {
|
|
|
170
170
|
return
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
debounce(() => {
|
|
174
|
+
this.selected(null, this.addressInput)
|
|
175
|
+
}, 200)()
|
|
174
176
|
},
|
|
175
177
|
initMap (aMap) {
|
|
176
178
|
this.map = new (aMap).Map('addressSearchCombobox_map', { // 设置地图容器id
|
|
@@ -198,23 +200,24 @@ export default {
|
|
|
198
200
|
this.addressObj.lng_lat = _arr[1]
|
|
199
201
|
this.map.setCenter(this.addressObj.lng_lat.split(','))
|
|
200
202
|
},
|
|
201
|
-
selected () {
|
|
203
|
+
selected (_value, _addstr) {
|
|
202
204
|
let result
|
|
203
205
|
if (this.searchResultType !== 'Default') {
|
|
204
206
|
if (this.searchResultType === 'Array') {
|
|
205
|
-
result = [this.addressObj.address, this.addressObj.lng_lat]
|
|
207
|
+
result = [_addstr || this.addressObj.address, this.addressObj.lng_lat]
|
|
206
208
|
} else {
|
|
207
209
|
result = {}
|
|
208
|
-
result[this.resultKeys.address] = this.addressObj.address
|
|
210
|
+
result[this.resultKeys.address] = _addstr || this.addressObj.address
|
|
209
211
|
result[this.resultKeys.coords] = this.addressObj.lng_lat
|
|
210
212
|
}
|
|
211
213
|
}
|
|
212
|
-
this.addressInput = this.addressObj.address
|
|
213
|
-
console.log(' result--- ', result)
|
|
214
214
|
this.visible = false
|
|
215
215
|
this.$emit('onSelect', JSON.stringify(result))
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
// 如果传递了地址 是为了更新上级 不做省市区检验处理
|
|
217
|
+
if (!_addstr) {
|
|
218
|
+
this.addressInput = this.addressObj.address
|
|
219
|
+
this.$emit('onDivisionsChange', Object.assign({}, result, { divisions: this.divisions, vm: this }))
|
|
220
|
+
}
|
|
218
221
|
},
|
|
219
222
|
// 懒加载检索方法
|
|
220
223
|
fetchFunction (value) {
|
|
@@ -283,51 +286,53 @@ export default {
|
|
|
283
286
|
watch: {
|
|
284
287
|
'visible' (val) {
|
|
285
288
|
if (val) {
|
|
286
|
-
|
|
287
|
-
this.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
289
|
+
this.$nextTick(() => {
|
|
290
|
+
GetGDMap(this.gaode_secret_key, this.gaode_key).then(aMap => {
|
|
291
|
+
this.initMap(aMap)
|
|
292
|
+
this.mapAutocomplete = new (aMap).AutoComplete({
|
|
293
|
+
// city 限定城市,默认全国
|
|
294
|
+
city: '全国',
|
|
295
|
+
dragEnable: true,
|
|
296
|
+
animateEnable: false
|
|
297
|
+
})
|
|
298
|
+
this.positionPicker = new window.AMapUI.PositionPicker({
|
|
299
|
+
mode: 'dragMap',
|
|
300
|
+
map: this.map
|
|
301
|
+
})
|
|
302
|
+
this.positionPicker.on('success', (positionResult) => {
|
|
303
|
+
console.log(positionResult)
|
|
304
|
+
console.log(positionResult.position)
|
|
305
|
+
// 设置 行政区划信息
|
|
306
|
+
if (positionResult?.regeocode?.addressComponent) {
|
|
307
|
+
const { addressComponent } = positionResult?.regeocode
|
|
308
|
+
this.divisions.province = addressComponent.province
|
|
309
|
+
this.divisions.city = addressComponent.city
|
|
310
|
+
this.divisions.district = addressComponent.district
|
|
311
|
+
this.divisions.township = addressComponent.township
|
|
312
|
+
this.divisions.towncode = addressComponent.towncode
|
|
313
|
+
this.divisions.street = addressComponent.street
|
|
314
|
+
// 试着获取小区
|
|
315
|
+
if (positionResult?.regeocode?.aois && positionResult?.regeocode?.aois.length) {
|
|
316
|
+
// 取第一个当做小区
|
|
317
|
+
this.divisions.area = positionResult?.regeocode?.aois[0]?.name
|
|
318
|
+
} else if (positionResult?.regeocode?.pois && positionResult?.regeocode?.pois.length) {
|
|
319
|
+
// 取第一个当做小区
|
|
320
|
+
this.divisions.area = positionResult?.regeocode?.pois[0]?.name
|
|
321
|
+
}
|
|
322
|
+
this.divisions.str =
|
|
323
|
+
`${addressComponent.province}${addressComponent.city}${addressComponent.district}${addressComponent.township}`
|
|
317
324
|
}
|
|
318
|
-
this.divisions.str
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
this.
|
|
324
|
-
}
|
|
325
|
-
this.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
this.positionPicker.on('fail', function (positionResult) {
|
|
325
|
+
if (this.divisions.str && positionResult.address.startsWith(this.divisions.str)) {
|
|
326
|
+
// 如果 省市区信息和获取到的地址的前缀一致 那么省市区前缀禁止修改只能修改后面的 通过 onchange事件拦截
|
|
327
|
+
this.readOnlyDivisions = true
|
|
328
|
+
}
|
|
329
|
+
this.addressObj.address = positionResult.address
|
|
330
|
+
this.addressObj.lng_lat = `${positionResult.position.lng},${positionResult.position.lat}`
|
|
331
|
+
})
|
|
332
|
+
this.positionPicker.on('fail', function (positionResult) {
|
|
333
|
+
})
|
|
334
|
+
this.positionPicker.start()
|
|
329
335
|
})
|
|
330
|
-
this.positionPicker.start()
|
|
331
336
|
})
|
|
332
337
|
}
|
|
333
338
|
}
|