From c4d30b8990568695c8b79cdf7c257d0bd1991629 Mon Sep 17 00:00:00 2001 From: cheng <545895878@qq.com> Date: Tue, 21 Jul 2026 21:45:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(event-create):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E9=80=89=E6=8B=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 manifest.json 中的 requiredPrivateInfos 配置 - 实现先获取用户当前位置再打开地图选点的功能 - 添加定位失败时的降级处理机制 - 新增 openLocationPicker 方法支持传入经纬度参数 - 重构 chooseLocation 方法逻辑提升用户体验 --- manifest.json | 1 - pages/event-create/event-create.vue | 24 +++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 519a5af..34a3d2d 100644 --- a/manifest.json +++ b/manifest.json @@ -41,7 +41,6 @@ "minified" : true }, "usingComponents" : true, - "requiredPrivateInfos" : ["chooseLocation", "getLocation"], "permission" : { "scope.userLocation" : { "desc" : "用于选择酒局地点和导航" diff --git a/pages/event-create/event-create.vue b/pages/event-create/event-create.vue index 3a958ba..28d7b2a 100644 --- a/pages/event-create/event-create.vue +++ b/pages/event-create/event-create.vue @@ -158,7 +158,20 @@ export default { this.form.time = e.detail.value }, chooseLocation() { - uni.chooseLocation({ + // 先获取用户当前位置,以当前位置为中心打开地图选点 + uni.getLocation({ + type: 'gcj02', + success: (loc) => { + this.openLocationPicker(loc.latitude, loc.longitude) + }, + fail: () => { + // 定位失败时仍打开选点(地图默认位置) + this.openLocationPicker() + } + }) + }, + openLocationPicker(latitude, longitude) { + const options = { success: (res) => { this.form.location = res.name || res.address || '' this.form.address = res.address || '' @@ -166,9 +179,14 @@ export default { this.form.longitude = res.longitude }, fail: () => { - // 用户取消或无权限,不做处理 + // 用户取消,不做处理 } - }) + } + if (latitude && longitude) { + options.latitude = latitude + options.longitude = longitude + } + uni.chooseLocation(options) }, changePeople(delta) { const val = this.form.maxPeople + delta