From 9b6e38edce807f38d244f29110424fb98c73dc88 Mon Sep 17 00:00:00 2001
From: aaron <>
Date: Thu, 9 Jan 2025 17:44:22 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=AE=B6=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E5=9F=BA=E7=A1=80=E5=AE=8C=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/index.html | 12 +-
src/components/CommunitySelect/index.vue | 39 +++
src/components/MapPicker/index.vue | 232 ++++++++++++++
src/config/map.js | 4 +
src/utils/amap.js | 51 ++-
src/views/community/CommunityList.vue | 280 +++-------------
src/views/merchant/List.vue | 386 ++++++++++++++++++++++-
7 files changed, 747 insertions(+), 257 deletions(-)
create mode 100644 src/components/CommunitySelect/index.vue
create mode 100644 src/components/MapPicker/index.vue
create mode 100644 src/config/map.js
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"
>
-
-
-
- {{ label }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -133,18 +89,23 @@