feat(event-create): 优化位置选择功能

- 移除 manifest.json 中的 requiredPrivateInfos 配置
- 实现先获取用户当前位置再打开地图选点的功能
- 添加定位失败时的降级处理机制
- 新增 openLocationPicker 方法支持传入经纬度参数
- 重构 chooseLocation 方法逻辑提升用户体验
This commit is contained in:
cg
2026-07-21 21:45:27 +08:00
parent eaa0d7101f
commit c4d30b8990
2 changed files with 21 additions and 4 deletions
+21 -3
View File
@@ -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