From 541139912b7583007bfd2120e6a12a337af48d07 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期四, 25 七月 2024 17:56:13 +0800 Subject: [PATCH] 提交 --- admin/src/components/business/OperaShopWindow.vue | 75 ++++++++++++++++++++++--------------- 1 files changed, 45 insertions(+), 30 deletions(-) diff --git a/admin/src/components/business/OperaShopWindow.vue b/admin/src/components/business/OperaShopWindow.vue index 547c708..b382539 100644 --- a/admin/src/components/business/OperaShopWindow.vue +++ b/admin/src/components/business/OperaShopWindow.vue @@ -63,6 +63,8 @@ <script> import BaseOpera from '@/components/base/BaseOpera' import GlobalWindow from '@/components/common/GlobalWindow' +import { jsonp } from 'vue-jsonp' + export default { name: 'OperaShopWindow', extends: BaseOpera, @@ -71,8 +73,8 @@ return { geocoder: null, map: [], - searchValue:'', - marker:null, + searchValue: '', + marker: null, // 琛ㄥ崟鏁版嵁 provinces: [], cities: [], @@ -108,9 +110,22 @@ }) }, methods: { - searchAddress( ){ - if(this.geocoder && this.searchValue){ - this.geocoder.getLocation(this.searchValue) + searchAddress () { + if ( this.searchValue) { + var that = this + jsonp('https://apis.map.qq.com/ws/geocoder/v1/', { + address: this.searchValue, + key: 'HIDBZ-2QXL4-TAWUD-XET6Q-EKTJE-CCBSQ', + output: 'jsonp' + }).then(result => { + console.log(result) + if(result.result.location){ + that.changePostion(result.result.location.lng, result.result.location.lat) + } + }).catch(error => { + // 璇锋眰澶辫触澶勭悊 + console.log(error) + }) } }, initMap (lat, long) { @@ -120,20 +135,20 @@ center: center, zoom: 17 }) - this.changePostion(long,lat) + this.changePostion(long, lat) qq.maps.event.addListener(this.map, 'click', function (event) { that.changePostion(event.latLng.lng, event.latLng.lat) } ) - this.geocoder = new qq.maps.Geocoder() + /* this.geocoder = new qq.maps.Geocoder() this.geocoder.setComplete(function (result) { - that.changePostion(result.detail.location.lng,result.detail.location.lat) + that.changePostion(result.detail.location.lng, result.detail.location.lat) }) // 鑻ユ湇鍔¤姹傚け璐ワ紝鍒欒繍琛屼互涓嬪嚱鏁� - this.geocoder.setError(function () { - console.log('閫嗚В鏋愬け璐�') - }) + this.geocoder.setError(function (e) { + console.log(that.searchValue + '=====閫嗚В鏋愬け璐�') + })*/ }, open (title, target) { this.title = title @@ -157,7 +172,7 @@ const mapContainer = this.$refs.mapContainer // 鑾峰彇鍦板浘瀹瑰櫒 if (mapContainer) { // 鍒濆鍖栧湴鍥句箣鍓嶆鏌ュ鍣ㄦ槸鍚﹀瓨鍦� - this.initMap(this.form.latitude,this.form.longitude) + this.initMap(this.form.latitude, this.form.longitude) // 鍒濆鍖栬吘璁湴鍥� } }) @@ -167,12 +182,12 @@ .then(res => { this.provinces = res }) - if(this.form.provinceCode){ - this.selectProvince(this.form.provinceCode,true) + if (this.form.provinceCode) { + this.selectProvince(this.form.provinceCode, true) } }, // 閫夋嫨鐪佷唤 - selectProvince (val,isInit) { + selectProvince (val, isInit) { this.provinces.forEach(item => { if (item.id == val) { this.form.provinceName = item.name @@ -180,36 +195,36 @@ }) this.cities = [] this.areas = [] - if(!isInit){ + if (!isInit) { this.form.cityName = '' this.form.areaCode = '' this.form.cityCode = '' this.form.areaName = '' } - if(!val || val ==''){ + if (!val || val == '') { return } this.api.areaList({ pid: val }) .then(res => { this.cities = res - if(isInit){ - this.selectCity(this.form.cityCode,isInit) + if (isInit) { + this.selectCity(this.form.cityCode, isInit) } }) }, // 閫夋嫨鍩庡競 - selectCity (val,isInit) { + selectCity (val, isInit) { this.cities.forEach(item => { if (item.id == val) { this.form.cityName = item.name } }) this.areas = [] - if(!isInit){ + if (!isInit) { this.form.areaCode = '' this.form.areaName = '' } - if(!val || val ==''){ + if (!val || val == '') { return } this.api.areaList({ pid: val }) @@ -224,24 +239,24 @@ } }) }, - changeMapCenter(){ - this.searchValue = (this.form.provinceName||'')+(this.form.cityName||'')+(this.form.areaName||'')+(this.form.address||'') + changeMapCenter () { + this.searchValue = (this.form.provinceName || '') + (this.form.cityName || '') + (this.form.areaName || '') + (this.form.address || '') this.searchAddress() }, changePostion (lng, lat) { if (lng || lat) { this.form.longitude = lng this.form.latitude = lat - if(this.map){ - if(this.marker){ + if (this.map) { + if (this.marker) { this.marker.setMap(null) } - var pos =new qq.maps.LatLng(lat,lng); + var pos = new qq.maps.LatLng(lat, lng) this.map.setCenter(pos) - this.marker= new qq.maps.Marker({ + this.marker = new qq.maps.Marker({ position: pos, - animation:qq.maps.MarkerAnimation.DROP, - map:this.map + animation: qq.maps.MarkerAnimation.DROP, + map: this.map }) } } -- Gitblit v1.9.3