⚡ 统一地图选址搜索为高德 place/text 并展示分页候选

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-28 00:19:17 +08:00
parent b5043575e4
commit 8b9c908237
10 changed files with 166 additions and 158 deletions
+24 -23
View File
@@ -270,7 +270,7 @@ import { createOption } from '@/option/base/common-address';
import { mapGetters } from 'vuex';
import { downloadXls } from '@/utils/util';
import { getToken } from '@/utils/auth';
import { normalizeMapSearchResults } from '@/utils/map-search';
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
import { isMobile } from '@/utils/validate';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
@@ -1112,31 +1112,32 @@ export default {
this.$message.warning('请输入地址关键词');
return;
}
if (this.mapLoading) return;
this.mapSearchResults = [];
this.mapLoading = true;
this.loadAmap()
.then(() => {
this.mapLoading = true;
this.ensureAmapGeocoder()
.then(() => this.runAmapGeocode('location', keyword))
.then(result => {
this.mapSearchResults = normalizeMapSearchResults(result, keyword);
const point = this.resolveMapPoint(result);
if (!point) {
this.mapStatus = '未找到匹配地址';
this.$message.warning('地图搜索无匹配地址');
return;
}
this.pickMapPoint(point, keyword);
})
.catch(() => {
this.mapStatus = '地图搜索失败';
this.$message.error('地图搜索失败,请稍后重试');
})
.finally(() => {
this.mapLoading = false;
});
.then(() => searchAmapPlaceText(keyword))
.then(pois => {
this.mapSearchResults = normalizeMapSearchResults(pois, keyword);
const first = this.mapSearchResults[0];
if (!first?.location) {
this.mapStatus = '未找到匹配地址';
this.$message.warning('地图搜索无匹配地址');
return;
}
return this.$nextTick().then(() => {
if (typeof this.amap?.resize === 'function') {
this.amap.resize();
}
this.pickMapPoint(first.location, first.address || first.name || keyword);
});
})
.catch(() => {
this.$message.error('高德地图组件加载失败,请稍后重试或重新打开弹窗');
this.mapStatus = '未找到匹配地址';
this.$message.warning('地图搜索无匹配地址');
})
.finally(() => {
this.mapLoading = false;
});
},
selectMapSearchResult(item) {