diff --git a/src/api/secondHandCar.js b/src/api/secondHandCar.js index 6a1a6679..97950b75 100644 --- a/src/api/secondHandCar.js +++ b/src/api/secondHandCar.js @@ -102,4 +102,14 @@ export function auditCarInfoAgain(data){ contentType: 'application/json', data }) -} \ No newline at end of file +} + + +// 我的发布列表 +export function getAddressForService(data){ + return request({ + url: '/base/gaodeMap/getPlaceByAddress', + method:'GET', + params: data, + }) +} diff --git a/src/utils/map.js b/src/utils/map.js index b6b51fbd..a036e997 100644 --- a/src/utils/map.js +++ b/src/utils/map.js @@ -1,3 +1,4 @@ +import { getAddressForService } from "@/api/secondHandCar" // 获取定位, 返回 经纬度 export function getLocal(mapContext) { return new Promise((resolve, reject) => { @@ -46,7 +47,19 @@ export function getAddress(mapContext, lnglat) { // 输入提示 export function searchFun(mapContext, cityCode, keyword) { return new Promise((resolve) => { - mapContext.plugin('AMap.AutoComplete', function(){ + getAddressForService({ + city: '', + address: keyword + }).then((res) => { + if(res.code == 200) { + resolve(res?.data?.pois || []) + } else { + resolve([]) + } + }).catch(() => { + resolve([]) + }) + /*mapContext.plugin('AMap.AutoComplete', function(){ var autoOptions = { city: cityCode || '全国', }; @@ -61,7 +74,7 @@ export function searchFun(mapContext, cityCode, keyword) { resolve([]) } }) - }) + })*/ }) } diff --git a/src/views/report/addressMap.vue b/src/views/report/addressMap.vue index 1217ce23..0388bba1 100644 --- a/src/views/report/addressMap.vue +++ b/src/views/report/addressMap.vue @@ -75,13 +75,14 @@ } let content = '
'; let activeObj = this.addressList[this.activeIndex]; + let lanLat = activeObj.location.split(','); this.marker = new AMap.Marker({ - position: new AMap.LngLat( activeObj.location.lng, activeObj.location.lat ), + position: new AMap.LngLat( lanLat[0], lanLat[1] ), content: content, offset: new AMap.Pixel(-13, -30) }); this.map.add(this.marker) - this.map.setCenter([activeObj.location.lng, activeObj.location.lat]) + this.map.setCenter([lanLat[0], lanLat[1]]) }, successHandler() { if( this.activeIndex == null ) { @@ -89,10 +90,11 @@ return } let activeObj = this.addressList[this.activeIndex]; + let lanLat = activeObj.location.split(','); let _tempObj = { startPoiAddress: activeObj?.district + activeObj?.address + activeObj?.name, - startLat: activeObj?.location?.lat, - startLng: activeObj?.location?.lng, + startLat: lanLat[0], + startLng: lanLat[1], adCode: activeObj?.adcode, } sessionStorage.setItem('reportAddress', JSON.stringify(_tempObj))