@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.
@@ -32,7 +32,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-ctn[data-v-0a8871e0],.v-amap-c
32
32
 
33
33
  /***/ }),
34
34
 
35
- /***/ 22:
35
+ /***/ 543:
36
36
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
37
37
 
38
38
  "use strict";
@@ -46,14 +46,14 @@ __webpack_require__.r(__webpack_exports__);
46
46
 
47
47
  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()));
48
48
  // Module
49
- ___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}", ""]);
49
+ ___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}", ""]);
50
50
  // Exports
51
51
  /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
52
52
 
53
53
 
54
54
  /***/ }),
55
55
 
56
- /***/ 875:
56
+ /***/ 354:
57
57
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
58
58
 
59
59
  "use strict";
@@ -194,35 +194,35 @@ var update = add("1bf2dbec", content, true, {"sourceMap":false,"shadowMode":fals
194
194
 
195
195
  /***/ }),
196
196
 
197
- /***/ 264:
197
+ /***/ 453:
198
198
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
199
199
 
200
200
  // style-loader: Adds some css to the DOM by adding a <style> tag
201
201
 
202
202
  // load the styles
203
- var content = __webpack_require__(22);
203
+ var content = __webpack_require__(543);
204
204
  if(content.__esModule) content = content.default;
205
205
  if(typeof content === 'string') content = [[module.id, content, '']];
206
206
  if(content.locals) module.exports = content.locals;
207
207
  // add the styles to the DOM
208
208
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
209
- var update = add("761553ec", content, true, {"sourceMap":false,"shadowMode":false});
209
+ var update = add("5fd0399d", content, true, {"sourceMap":false,"shadowMode":false});
210
210
 
211
211
  /***/ }),
212
212
 
213
- /***/ 155:
213
+ /***/ 930:
214
214
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
215
215
 
216
216
  // style-loader: Adds some css to the DOM by adding a <style> tag
217
217
 
218
218
  // load the styles
219
- var content = __webpack_require__(875);
219
+ var content = __webpack_require__(354);
220
220
  if(content.__esModule) content = content.default;
221
221
  if(typeof content === 'string') content = [[module.id, content, '']];
222
222
  if(content.locals) module.exports = content.locals;
223
223
  // add the styles to the DOM
224
224
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
225
- var update = add("66a45162", content, true, {"sourceMap":false,"shadowMode":false});
225
+ var update = add("ae650eda", content, true, {"sourceMap":false,"shadowMode":false});
226
226
 
227
227
  /***/ }),
228
228
 
@@ -1351,16 +1351,37 @@ var VAMapPolygon_component = normalizeComponent(
1351
1351
  )
1352
1352
 
1353
1353
  /* harmony default export */ var VAMapPolygon = (VAMapPolygon_component.exports);
1354
- ;// 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
1355
- 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}}})])
1354
+ ;// 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
1355
+ 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()])
1356
1356
  }
1357
- var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_staticRenderFns = []
1358
-
1357
+ var VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_staticRenderFns = []
1358
+
1359
+
1360
+ ;// CONCATENATED MODULE: ./src/utils/isParentNode.js
1361
+ // 是否是父节点
1362
+ const isParentNode = function (parentObj, obj) {
1363
+ if (parentObj === obj) return false
1364
+ while (
1365
+ obj != undefined &&
1366
+ obj != null &&
1367
+ obj.tagName &&
1368
+ obj.tagName.toUpperCase() != 'BODY'
1369
+ ) {
1370
+ if (obj == parentObj) {
1371
+ return true
1372
+ }
1373
+ obj = obj.parentNode
1374
+ }
1375
+ return false
1376
+ }
1377
+
1378
+ /* harmony default export */ var utils_isParentNode = (isParentNode);
1359
1379
 
1360
1380
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1361
1381
 
1362
1382
 
1363
1383
 
1384
+
1364
1385
  /* harmony default export */ var VAMapPlaceSearchInputvue_type_script_lang_js = ({
1365
1386
  name: 'VAMapPlaceSearchInput',
1366
1387
  model: {
@@ -1376,6 +1397,10 @@ var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_stat
1376
1397
  type: String,
1377
1398
  default: ''
1378
1399
  },
1400
+ disabled: {
1401
+ type: Boolean,
1402
+ default: false
1403
+ },
1379
1404
  customEnable: {
1380
1405
  type: Boolean,
1381
1406
  default: true
@@ -1384,95 +1409,135 @@ var VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_stat
1384
1409
  data() {
1385
1410
  return {
1386
1411
  AMap: null,
1387
- inputValue: '',
1388
- placeName: '',
1389
- autocompleteListener: null,
1390
- placeSearchListener: null
1412
+ placeSearch: null,
1413
+ placeList: [],
1414
+ place: null
1391
1415
  }
1392
1416
  },
1393
- async mounted() {
1394
- this.AMap = await loader.load()
1395
- this.addListener()
1417
+ watch: {
1418
+ place() {
1419
+ this.$emit('change', this.place ? this.place.name : '')
1420
+ this.$emit(
1421
+ 'locationChange',
1422
+ this.place
1423
+ ? [this.place.location.lng, this.place.location.lat]
1424
+ : null
1425
+ )
1426
+ this.$emit('placeChange', this.place)
1427
+ }
1396
1428
  },
1397
- destroyed() {
1398
- this.removeListener()
1429
+ mounted() {
1430
+ window.addEventListener('click', this.optionsHideListener, true)
1431
+ window.addEventListener('contextmenu', this.optionsHideListener, true)
1432
+ },
1433
+ beforeDestroy() {
1434
+ window.removeEventListener('click', this.optionsHideListener, true)
1435
+ window.removeEventListener(
1436
+ 'contextmenu',
1437
+ this.optionsHideListener,
1438
+ true
1439
+ )
1399
1440
  },
1400
1441
  methods: {
1401
- async addListener() {
1402
- const autocomplete = new this.AMap.Autocomplete({
1403
- input: this.$refs.input
1404
- }),
1405
- placeSearch = new this.AMap.PlaceSearch({})
1406
-
1407
- this.autocompleteListener = this.AMap.event.addListener(
1408
- autocomplete,
1409
- 'select',
1410
- event => {
1411
- this.placeName = event.poi.name
1412
- placeSearch.search(event.poi.name)
1413
- }
1414
- )
1415
-
1416
- this.placeSearchListener = this.AMap.event.addListener(
1417
- placeSearch,
1418
- 'complete',
1419
- event => {
1420
- var position = null
1421
- if (
1422
- event &&
1423
- event.poiList &&
1424
- event.poiList.pois &&
1425
- event.poiList.pois.length
1426
- ) {
1427
- position = [
1428
- event.poiList.pois[0].location.lng,
1429
- event.poiList.pois[0].location.lat
1430
- ]
1431
- }
1432
-
1433
- if (!position && !this.customEnable) {
1434
- this.clear()
1435
- } else {
1436
- this.$emit('change', this.placeName)
1437
- this.$emit('locationChange', position)
1438
- }
1442
+ async createPlaceSearch() {
1443
+ this.AMap = await loader.load()
1444
+ this.placeSearch = new this.AMap.PlaceSearch({
1445
+ extensions: 'all'
1446
+ })
1447
+ },
1448
+ async getPlaceList() {
1449
+ if (!this.placeSearch) {
1450
+ await this.createPlaceSearch()
1451
+ }
1452
+ this.placeSearch.search(this.value, (status, result) => {
1453
+ if (status === 'complete') {
1454
+ this.placeList = result?.poiList?.pois || []
1455
+ } else {
1456
+ this.placeList = []
1439
1457
  }
1440
- )
1458
+ })
1441
1459
  },
1442
- removeListener() {
1443
- this.AMap.event.removeListener(this.autocompleteListener)
1444
- this.AMap.event.removeListener(this.placeSearchListener)
1460
+ async handleInput(event) {
1461
+ this.$emit('change', event.target.value)
1462
+ await this.$nextTick()
1463
+ this.getPlaceList()
1445
1464
  },
1446
- clear() {
1447
- this.inputValue = ''
1448
- this.placeName = ''
1449
- this.$emit('change', this.placeName)
1450
- this.$emit('locationChange', null)
1465
+ handlePlaceSelect(place = null) {
1466
+ this.place = place
1467
+ this.placeList = []
1468
+ },
1469
+ handleFocus() {
1470
+ if (this.value?.trim()) {
1471
+ this.getPlaceList()
1472
+ }
1451
1473
  },
1452
1474
  handleBlur() {
1453
- if (this.inputValue !== this.placeName) {
1454
- if (this.customEnable) {
1455
- this.$emit('change', this.inputValue)
1456
- } else {
1457
- this.clear()
1458
- }
1475
+ if (this.customEnable) return
1476
+ if (this.value !== this.place?.name) {
1477
+ this.clear()
1459
1478
  }
1460
1479
  },
1461
- handleInput(event) {
1462
- this.inputValue = event.target.value
1480
+ optionsHideListener(event) {
1481
+ if (utils_isParentNode(this.$el, event.target)) return
1482
+ this.placeList = []
1483
+ },
1484
+ clear() {
1485
+ this.place = null
1486
+ this.$emit('change', '')
1463
1487
  }
1488
+ // async addListener() {
1489
+ // const autocomplete = new this.AMap.Autocomplete({
1490
+ // input: this.$refs.input
1491
+ // }),
1492
+ // placeSearch = new this.AMap.PlaceSearch({})
1493
+
1494
+ // this.autocompleteListener = this.AMap.event.addListener(
1495
+ // autocomplete,
1496
+ // 'select',
1497
+ // event => {
1498
+ // this.placeName = event.poi.name
1499
+ // placeSearch.search(event.poi.name)
1500
+ // }
1501
+ // )
1502
+
1503
+ // this.placeSearchListener = this.AMap.event.addListener(
1504
+ // placeSearch,
1505
+ // 'complete',
1506
+ // event => {
1507
+ // var position = null
1508
+ // if (
1509
+ // event &&
1510
+ // event.poiList &&
1511
+ // event.poiList.pois &&
1512
+ // event.poiList.pois.length
1513
+ // ) {
1514
+ // position = [
1515
+ // event.poiList.pois[0].location.lng,
1516
+ // event.poiList.pois[0].location.lat
1517
+ // ]
1518
+ // }
1519
+
1520
+ // if (!position && !this.customEnable) {
1521
+ // this.clear()
1522
+ // } else {
1523
+ // this.$emit('change', this.placeName)
1524
+ // this.$emit('locationChange', position)
1525
+ // }
1526
+ // }
1527
+ // )
1528
+ // },
1464
1529
  }
1465
1530
  });
1466
1531
 
1467
1532
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1468
1533
  /* harmony default export */ var Components_VAMapPlaceSearchInputvue_type_script_lang_js = (VAMapPlaceSearchInputvue_type_script_lang_js);
1469
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.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
1470
- var VAMapPlaceSearchInputvue_type_style_index_0_id_65bc08c3_prod_lang_stylus_scoped_true = __webpack_require__(264);
1471
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=65bc08c3&prod&lang=stylus&scoped=true
1534
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.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
1535
+ var VAMapPlaceSearchInputvue_type_style_index_0_id_0b77a6ce_prod_lang_stylus_scoped_true = __webpack_require__(453);
1536
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=0b77a6ce&prod&lang=stylus&scoped=true
1472
1537
 
1473
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.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
1474
- var VAMapPlaceSearchInputvue_type_style_index_1_id_65bc08c3_prod_lang_stylus = __webpack_require__(155);
1475
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=65bc08c3&prod&lang=stylus
1538
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-76.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-76.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-76.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-76.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
1539
+ var VAMapPlaceSearchInputvue_type_style_index_1_id_0b77a6ce_prod_lang_stylus = __webpack_require__(930);
1540
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=0b77a6ce&prod&lang=stylus
1476
1541
 
1477
1542
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue
1478
1543
 
@@ -1486,11 +1551,11 @@ var VAMapPlaceSearchInputvue_type_style_index_1_id_65bc08c3_prod_lang_stylus = _
1486
1551
 
1487
1552
  var VAMapPlaceSearchInput_component = normalizeComponent(
1488
1553
  Components_VAMapPlaceSearchInputvue_type_script_lang_js,
1489
- VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_render,
1490
- VAMapPlaceSearchInputvue_type_template_id_65bc08c3_scoped_true_lang_pug_staticRenderFns,
1554
+ VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_render,
1555
+ VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_staticRenderFns,
1491
1556
  false,
1492
1557
  null,
1493
- "65bc08c3",
1558
+ "0b77a6ce",
1494
1559
  null
1495
1560
 
1496
1561
  )
@@ -1512,7 +1577,7 @@ var VAMapPlaceSearchInput_component = normalizeComponent(
1512
1577
  ]);
1513
1578
 
1514
1579
  ;// CONCATENATED MODULE: ./package.json
1515
- var package_namespaceObject = {"i8":"1.2.0"};
1580
+ var package_namespaceObject = {"i8":"1.3.0"};
1516
1581
  ;// CONCATENATED MODULE: ./src/config/index.js
1517
1582
 
1518
1583