diff --git a/public/index.html b/public/index.html index 782f1b5..0f85304 100644 --- a/public/index.html +++ b/public/index.html @@ -1,15 +1,21 @@ - + - 蜂快到家后台管理系统 + <%= htmlWebpackPlugin.options.title %> + +
diff --git a/src/components/CommunitySelect/index.vue b/src/components/CommunitySelect/index.vue new file mode 100644 index 0000000..63724f8 --- /dev/null +++ b/src/components/CommunitySelect/index.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/src/components/MapPicker/index.vue b/src/components/MapPicker/index.vue new file mode 100644 index 0000000..072e026 --- /dev/null +++ b/src/components/MapPicker/index.vue @@ -0,0 +1,232 @@ + + + + + \ No newline at end of file diff --git a/src/config/map.js b/src/config/map.js new file mode 100644 index 0000000..19c7225 --- /dev/null +++ b/src/config/map.js @@ -0,0 +1,4 @@ +export const MAP_CONFIG = { + key: 'fd47f3d4f54b675693c7d59dcd2a6c5f', + securityJsCode: '6c7f5a402a13bf2dee1a4bbe0d8023c7' +} \ No newline at end of file diff --git a/src/utils/amap.js b/src/utils/amap.js index 365a36a..d9587b8 100644 --- a/src/utils/amap.js +++ b/src/utils/amap.js @@ -1,6 +1,20 @@ -export function initAMap() { +// 高德地图配置 +const MAP_CONFIG = { + key: 'fd47f3d4f54b675693c7d59dcd2a6c5f', + securityJsCode: '93527b49270ba2142f47f0407da7c0d6' +} + +// 设置安全密钥 +window._AMapSecurityConfig = { + securityJsCode: MAP_CONFIG.securityJsCode +} + +let isMapLoaded = false + +// 加载高德地图及其插件 +export const loadAMap = () => { return new Promise((resolve, reject) => { - if (window.AMap) { + if (isMapLoaded && window.AMap) { resolve(window.AMap) return } @@ -8,26 +22,41 @@ export function initAMap() { const script = document.createElement('script') script.type = 'text/javascript' script.async = true - script.src = `https://webapi.amap.com/maps?v=2.0&key=fd47f3d4f54b675693c7d59dcd2a6c5f&plugin=AMap.PlaceSearch,AMap.AutoComplete,AMap.Geocoder&callback=initAMapCallback` - - window.initAMapCallback = () => { + script.src = `https://webapi.amap.com/maps?v=2.0&key=${MAP_CONFIG.key}&plugin=AMap.Geocoder,AMap.AutoComplete,AMap.PlaceSearch` + + script.onload = () => { + isMapLoaded = true resolve(window.AMap) } + + script.onerror = () => { + reject(new Error('加载高德地图失败')) + } - script.onerror = reject document.head.appendChild(script) }) } // 创建地图实例 -export function createMap(container, options = {}) { +export const createMap = (container, options = {}) => { const defaultOptions = { zoom: 15, - viewMode: '2D' + viewMode: '2D', + center: [116.397428, 39.90923] // 默认中心点 } - - return new window.AMap.Map(container, { - ...defaultOptions, + return new window.AMap.Map(container, { ...defaultOptions, ...options }) +} + +// 创建地址搜索服务 +export const createAutoComplete = (options = {}) => { + return new window.AMap.AutoComplete({ + city: '全国', + citylimit: true, ...options }) +} + +// 创建地理编码服务 +export const createGeocoder = () => { + return new window.AMap.Geocoder() } \ No newline at end of file diff --git a/src/views/community/CommunityList.vue b/src/views/community/CommunityList.vue index 6d4284b..7841db8 100644 --- a/src/views/community/CommunityList.vue +++ b/src/views/community/CommunityList.vue @@ -73,58 +73,14 @@ :wrapper-col="{ span: 16 }" class="community-form" > - - - - - - - -
-
-
-
- - - - - - - - - - - + @@ -133,18 +89,23 @@