@styzy/vue-amap 1.2.0 → 1.3.0

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.
@@ -22,7 +22,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-ctn[data-v-0a8871e0],.v-amap-c
22
22
 
23
23
  /***/ }),
24
24
 
25
- /***/ 405:
25
+ /***/ 785:
26
26
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
27
27
 
28
28
  "use strict";
@@ -36,14 +36,14 @@ __webpack_require__.r(__webpack_exports__);
36
36
 
37
37
  var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
38
38
  // Module
39
- ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-place-search-input input[data-v-65bc08c3]{display:inline-block;box-sizing:border-box;padding:0 15px;width:100%;height:40px;outline:0;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;background-image:none;color:#606266;font-size:inherit;line-height:40px;transition:border-color .2s cubic-bezier(.645,.045,.355,1);-webkit-appearance:none}", ""]);
39
+ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-place-search-input[data-v-0b77a6ce]{position:relative}.v-amap-place-search-input input[data-v-0b77a6ce]{display:inline-block;box-sizing:border-box;padding:0 15px;width:100%;height:40px;outline:0;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;background-image:none;color:#606266;font-size:inherit;line-height:40px;transition:border-color .2s cubic-bezier(.645,.045,.355,1);-webkit-appearance:none}.v-amap-place-search-input input[data-v-0b77a6ce]::-webkit-input-placeholder{color:#c0c4cc}.v-amap-place-search-input input.is-disabled[data-v-0b77a6ce]{border-color:#e4e7ed;background-color:#f5f7fa;color:#c0c4cc;cursor:not-allowed}.v-amap-place-search-input .option-ctn[data-v-0b77a6ce]{position:absolute;top:100%;right:0;left:0;z-index:1;box-sizing:border-box;border:1px solid #dcdfe6;background-color:#fff}.v-amap-place-search-input .option-ctn .option[data-v-0b77a6ce]{overflow:hidden;padding-right:5px;padding-left:15px;height:40px;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:40px;cursor:pointer}.v-amap-place-search-input .option-ctn .option[data-v-0b77a6ce]:hover{background-color:#f4f5f6}.v-amap-place-search-input .option-ctn .option .name[data-v-0b77a6ce]{color:#424242}.v-amap-place-search-input .option-ctn .option .city[data-v-0b77a6ce]{margin-left:10px;color:#aaa}", ""]);
40
40
  // Exports
41
41
  /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
42
42
 
43
43
 
44
44
  /***/ }),
45
45
 
46
- /***/ 136:
46
+ /***/ 192:
47
47
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
48
48
 
49
49
  "use strict";
@@ -184,35 +184,35 @@ var update = add("7ebf2e0a", content, true, {"sourceMap":false,"shadowMode":fals
184
184
 
185
185
  /***/ }),
186
186
 
187
- /***/ 698:
187
+ /***/ 985:
188
188
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
189
189
 
190
190
  // style-loader: Adds some css to the DOM by adding a <style> tag
191
191
 
192
192
  // load the styles
193
- var content = __webpack_require__(405);
193
+ var content = __webpack_require__(785);
194
194
  if(content.__esModule) content = content.default;
195
195
  if(typeof content === 'string') content = [[module.id, content, '']];
196
196
  if(content.locals) module.exports = content.locals;
197
197
  // add the styles to the DOM
198
198
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
199
- var update = add("cd442028", content, true, {"sourceMap":false,"shadowMode":false});
199
+ var update = add("f9ce54c6", content, true, {"sourceMap":false,"shadowMode":false});
200
200
 
201
201
  /***/ }),
202
202
 
203
- /***/ 692:
203
+ /***/ 427:
204
204
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
205
205
 
206
206
  // style-loader: Adds some css to the DOM by adding a <style> tag
207
207
 
208
208
  // load the styles
209
- var content = __webpack_require__(136);
209
+ var content = __webpack_require__(192);
210
210
  if(content.__esModule) content = content.default;
211
211
  if(typeof content === 'string') content = [[module.id, content, '']];
212
212
  if(content.locals) module.exports = content.locals;
213
213
  // add the styles to the DOM
214
214
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
215
- var update = add("c612253c", content, true, {"sourceMap":false,"shadowMode":false});
215
+ var update = add("41bfd6da", content, true, {"sourceMap":false,"shadowMode":false});
216
216
 
217
217
  /***/ }),
218
218
 
@@ -1341,16 +1341,37 @@ var VAMapPolygon_component = normalizeComponent(
1341
1341
  )
1342
1342
 
1343
1343
  /* harmony default export */ var VAMapPolygon = (VAMapPolygon_component.exports);
1344
- ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/pug-plain-loader/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=template&id=65bc08c3&scoped=true&lang=pug
1345
- var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"v-amap-place-search-input"},[_c('input',{directives:[{name:"model",rawName:"v-model",value:(_vm.inputValue),expression:"inputValue"}],ref:"input",attrs:{"placeholder":_vm.placeholder},domProps:{"value":(_vm.inputValue)},on:{"blur":function($event){return _vm.handleBlur()},"input":function($event){if($event.target.composing)return;_vm.inputValue=$event.target.value}}})])
1344
+ ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/pug-plain-loader/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=template&id=0b77a6ce&scoped=true&lang=pug
1345
+ var VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"v-amap-place-search-input"},[_c('input',{ref:"input",class:{ 'is-disabled': _vm.disabled },attrs:{"disabled":_vm.disabled,"placeholder":_vm.placeholder},domProps:{"value":_vm.value},on:{"blur":function($event){return _vm.handleBlur()},"focus":function($event){return _vm.handleFocus()},"input":function($event){return _vm.handleInput($event)}}}),(_vm.placeList.length)?_c('div',{staticClass:"option-ctn"},_vm._l((_vm.placeList),function(place){return _c('div',{staticClass:"option",attrs:{"title":place.name + place.cityname},on:{"click":function($event){return _vm.handlePlaceSelect(place)}}},[_c('span',{staticClass:"name"},[_vm._v(_vm._s(place.name))]),_c('span',{staticClass:"city"},[_vm._v(_vm._s(place.cityname))])])}),0):_vm._e()])
1346
1346
  }
1347
- var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_staticRenderFns = []
1348
-
1347
+ var VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_staticRenderFns = []
1348
+
1349
+
1350
+ ;// CONCATENATED MODULE: ./src/utils/isParentNode.js
1351
+ // 是否是父节点
1352
+ const isParentNode = function (parentObj, obj) {
1353
+ if (parentObj === obj) return false
1354
+ while (
1355
+ obj != undefined &&
1356
+ obj != null &&
1357
+ obj.tagName &&
1358
+ obj.tagName.toUpperCase() != 'BODY'
1359
+ ) {
1360
+ if (obj == parentObj) {
1361
+ return true
1362
+ }
1363
+ obj = obj.parentNode
1364
+ }
1365
+ return false
1366
+ }
1367
+
1368
+ /* harmony default export */ var utils_isParentNode = (isParentNode);
1349
1369
 
1350
1370
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1351
1371
 
1352
1372
 
1353
1373
 
1374
+
1354
1375
  /* harmony default export */ var VAMapPlaceSearchInputvue_type_script_lang_js = ({
1355
1376
  name: 'VAMapPlaceSearchInput',
1356
1377
  model: {
@@ -1366,6 +1387,10 @@ var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_stat
1366
1387
  type: String,
1367
1388
  default: ''
1368
1389
  },
1390
+ disabled: {
1391
+ type: Boolean,
1392
+ default: false
1393
+ },
1369
1394
  customEnable: {
1370
1395
  type: Boolean,
1371
1396
  default: true
@@ -1374,95 +1399,135 @@ var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_stat
1374
1399
  data() {
1375
1400
  return {
1376
1401
  AMap: null,
1377
- inputValue: '',
1378
- placeName: '',
1379
- autocompleteListener: null,
1380
- placeSearchListener: null
1402
+ placeSearch: null,
1403
+ placeList: [],
1404
+ place: null
1381
1405
  }
1382
1406
  },
1383
- async mounted() {
1384
- this.AMap = await loader.load()
1385
- this.addListener()
1407
+ watch: {
1408
+ place() {
1409
+ this.$emit('change', this.place ? this.place.name : '')
1410
+ this.$emit(
1411
+ 'locationChange',
1412
+ this.place
1413
+ ? [this.place.location.lng, this.place.location.lat]
1414
+ : null
1415
+ )
1416
+ this.$emit('placeChange', this.place)
1417
+ }
1386
1418
  },
1387
- destroyed() {
1388
- this.removeListener()
1419
+ mounted() {
1420
+ window.addEventListener('click', this.optionsHideListener, true)
1421
+ window.addEventListener('contextmenu', this.optionsHideListener, true)
1422
+ },
1423
+ beforeDestroy() {
1424
+ window.removeEventListener('click', this.optionsHideListener, true)
1425
+ window.removeEventListener(
1426
+ 'contextmenu',
1427
+ this.optionsHideListener,
1428
+ true
1429
+ )
1389
1430
  },
1390
1431
  methods: {
1391
- async addListener() {
1392
- const autocomplete = new this.AMap.Autocomplete({
1393
- input: this.$refs.input
1394
- }),
1395
- placeSearch = new this.AMap.PlaceSearch({})
1396
-
1397
- this.autocompleteListener = this.AMap.event.addListener(
1398
- autocomplete,
1399
- 'select',
1400
- event => {
1401
- this.placeName = event.poi.name
1402
- placeSearch.search(event.poi.name)
1403
- }
1404
- )
1405
-
1406
- this.placeSearchListener = this.AMap.event.addListener(
1407
- placeSearch,
1408
- 'complete',
1409
- event => {
1410
- var position = null
1411
- if (
1412
- event &&
1413
- event.poiList &&
1414
- event.poiList.pois &&
1415
- event.poiList.pois.length
1416
- ) {
1417
- position = [
1418
- event.poiList.pois[0].location.lng,
1419
- event.poiList.pois[0].location.lat
1420
- ]
1421
- }
1422
-
1423
- if (!position && !this.customEnable) {
1424
- this.clear()
1425
- } else {
1426
- this.$emit('change', this.placeName)
1427
- this.$emit('locationChange', position)
1428
- }
1432
+ async createPlaceSearch() {
1433
+ this.AMap = await loader.load()
1434
+ this.placeSearch = new this.AMap.PlaceSearch({
1435
+ extensions: 'all'
1436
+ })
1437
+ },
1438
+ async getPlaceList() {
1439
+ if (!this.placeSearch) {
1440
+ await this.createPlaceSearch()
1441
+ }
1442
+ this.placeSearch.search(this.value, (status, result) => {
1443
+ if (status === 'complete') {
1444
+ this.placeList = result?.poiList?.pois || []
1445
+ } else {
1446
+ this.placeList = []
1429
1447
  }
1430
- )
1448
+ })
1431
1449
  },
1432
- removeListener() {
1433
- this.AMap.event.removeListener(this.autocompleteListener)
1434
- this.AMap.event.removeListener(this.placeSearchListener)
1450
+ async handleInput(event) {
1451
+ this.$emit('change', event.target.value)
1452
+ await this.$nextTick()
1453
+ this.getPlaceList()
1435
1454
  },
1436
- clear() {
1437
- this.inputValue = ''
1438
- this.placeName = ''
1439
- this.$emit('change', this.placeName)
1440
- this.$emit('locationChange', null)
1455
+ handlePlaceSelect(place = null) {
1456
+ this.place = place
1457
+ this.placeList = []
1458
+ },
1459
+ handleFocus() {
1460
+ if (this.value?.trim()) {
1461
+ this.getPlaceList()
1462
+ }
1441
1463
  },
1442
1464
  handleBlur() {
1443
- if (this.inputValue !== this.placeName) {
1444
- if (this.customEnable) {
1445
- this.$emit('change', this.inputValue)
1446
- } else {
1447
- this.clear()
1448
- }
1465
+ if (this.customEnable) return
1466
+ if (this.value !== this.place?.name) {
1467
+ this.clear()
1449
1468
  }
1450
1469
  },
1451
- handleInput(event) {
1452
- this.inputValue = event.target.value
1470
+ optionsHideListener(event) {
1471
+ if (utils_isParentNode(this.$el, event.target)) return
1472
+ this.placeList = []
1473
+ },
1474
+ clear() {
1475
+ this.place = null
1476
+ this.$emit('change', '')
1453
1477
  }
1478
+ // async addListener() {
1479
+ // const autocomplete = new this.AMap.Autocomplete({
1480
+ // input: this.$refs.input
1481
+ // }),
1482
+ // placeSearch = new this.AMap.PlaceSearch({})
1483
+
1484
+ // this.autocompleteListener = this.AMap.event.addListener(
1485
+ // autocomplete,
1486
+ // 'select',
1487
+ // event => {
1488
+ // this.placeName = event.poi.name
1489
+ // placeSearch.search(event.poi.name)
1490
+ // }
1491
+ // )
1492
+
1493
+ // this.placeSearchListener = this.AMap.event.addListener(
1494
+ // placeSearch,
1495
+ // 'complete',
1496
+ // event => {
1497
+ // var position = null
1498
+ // if (
1499
+ // event &&
1500
+ // event.poiList &&
1501
+ // event.poiList.pois &&
1502
+ // event.poiList.pois.length
1503
+ // ) {
1504
+ // position = [
1505
+ // event.poiList.pois[0].location.lng,
1506
+ // event.poiList.pois[0].location.lat
1507
+ // ]
1508
+ // }
1509
+
1510
+ // if (!position && !this.customEnable) {
1511
+ // this.clear()
1512
+ // } else {
1513
+ // this.$emit('change', this.placeName)
1514
+ // this.$emit('locationChange', position)
1515
+ // }
1516
+ // }
1517
+ // )
1518
+ // },
1454
1519
  }
1455
1520
  });
1456
1521
 
1457
1522
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1458
1523
  /* harmony default export */ var Components_VAMapPlaceSearchInputvue_type_script_lang_js = (VAMapPlaceSearchInputvue_type_script_lang_js);
1459
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=65bc08c3&prod&lang=stylus&scoped=true
1460
- var VAMapPlaceSearchInputvue_type_style_index_0_id_65bc08c3_prod_lang_stylus_scoped_true = __webpack_require__(698);
1461
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=65bc08c3&prod&lang=stylus&scoped=true
1524
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=0b77a6ce&prod&lang=stylus&scoped=true
1525
+ var VAMapPlaceSearchInputvue_type_style_index_0_id_0b77a6ce_prod_lang_stylus_scoped_true = __webpack_require__(985);
1526
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=0b77a6ce&prod&lang=stylus&scoped=true
1462
1527
 
1463
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=65bc08c3&prod&lang=stylus
1464
- var VAMapPlaceSearchInputvue_type_style_index_1_id_65bc08c3_prod_lang_stylus = __webpack_require__(692);
1465
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=65bc08c3&prod&lang=stylus
1528
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=0b77a6ce&prod&lang=stylus
1529
+ var VAMapPlaceSearchInputvue_type_style_index_1_id_0b77a6ce_prod_lang_stylus = __webpack_require__(427);
1530
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=0b77a6ce&prod&lang=stylus
1466
1531
 
1467
1532
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue
1468
1533
 
@@ -1476,11 +1541,11 @@ var VAMapPlaceSearchInputvue_type_style_index_1_id_65bc08c3_prod_lang_stylus = _
1476
1541
 
1477
1542
  var VAMapPlaceSearchInput_component = normalizeComponent(
1478
1543
  Components_VAMapPlaceSearchInputvue_type_script_lang_js,
1479
- VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_render,
1480
- VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_staticRenderFns,
1544
+ VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_render,
1545
+ VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_staticRenderFns,
1481
1546
  false,
1482
1547
  null,
1483
- "65bc08c3",
1548
+ "0b77a6ce",
1484
1549
  null
1485
1550
 
1486
1551
  )
@@ -1502,7 +1567,7 @@ var VAMapPlaceSearchInput_component = normalizeComponent(
1502
1567
  ]);
1503
1568
 
1504
1569
  ;// CONCATENATED MODULE: ./package.json
1505
- var package_namespaceObject = {"i8":"1.2.0"};
1570
+ var package_namespaceObject = {"i8":"1.3.0"};
1506
1571
  ;// CONCATENATED MODULE: ./src/config/index.js
1507
1572
 
1508
1573