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