From 8930e13f3f729e313dce0312a4d8d57dd6223f48 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Wed, 8 Jan 2025 09:03:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B0=8F=E5=8C=BA=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 5 + src/api/community.js | 9 + src/main.js | 6 +- src/utils/amap.js | 31 +- src/views/community/CommunityList.vue | 412 +++++++++++++++++++++++++- 5 files changed, 452 insertions(+), 11 deletions(-) diff --git a/public/index.html b/public/index.html index 4da3fe2..8476fd8 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,11 @@ DM Admin +
diff --git a/src/api/community.js b/src/api/community.js index 78bdf37..0c21e1a 100644 --- a/src/api/community.js +++ b/src/api/community.js @@ -16,4 +16,13 @@ export function getBuildingList(params) { method: 'get', params }) +} + +// 添加新小区 +export function createCommunity(data) { + return request({ + url: '/api/community/', + method: 'post', + data + }) } \ No newline at end of file diff --git a/src/main.js b/src/main.js index 1dfb70b..c7d3467 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,9 @@ import { Divider, Tag, Modal, - Select + Select, + InputNumber, + AutoComplete } from 'ant-design-vue' import 'ant-design-vue/dist/antd.css' @@ -39,5 +41,7 @@ app.use(Divider) app.use(Tag) app.use(Modal) app.use(Select) +app.use(InputNumber) +app.use(AutoComplete) app.mount('#app') \ No newline at end of file diff --git a/src/utils/amap.js b/src/utils/amap.js index 25de81e..4bd40f2 100644 --- a/src/utils/amap.js +++ b/src/utils/amap.js @@ -1,20 +1,37 @@ export function initAMap() { return new Promise((resolve, reject) => { if (window.AMap) { - resolve(window.AMap); + // 如果已经加载过,直接加载插件 + window.AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], () => { + resolve(window.AMap); + }); return; } - + + // 加载高德地图脚本 const script = document.createElement('script'); script.type = 'text/javascript'; script.async = true; - script.src = `https://webapi.amap.com/maps?v=2.0&key=fd47f3d4f54b675693c7d59dcd2a6c5f`; - - script.onerror = reject; - script.onload = () => { + script.src = `https://webapi.amap.com/maps?v=2.0&key=fd47f3d4f54b675693c7d59dcd2a6c5f&plugin=AMap.PlaceSearch,AMap.AutoComplete&callback=initAMapCallback`; + + // 创建回调函数 + window.initAMapCallback = () => { resolve(window.AMap); }; - + + script.onerror = () => { + reject(new Error('加载地图失败')); + }; + document.head.appendChild(script); }); +} + +// 添加地图工具函数 +export function createMap(container, options = {}) { + return new window.AMap.Map(container, { + zoom: 13, + viewMode: '2D', + ...options + }); } \ No newline at end of file diff --git a/src/views/community/CommunityList.vue b/src/views/community/CommunityList.vue index 78c8269..8ecc2e6 100644 --- a/src/views/community/CommunityList.vue +++ b/src/views/community/CommunityList.vue @@ -2,6 +2,7 @@

小区列表

+ 添加小区
+ + + + + + + + + + + + +
+
+
+
+ + + + + + + + + + + + + + + +
+