fix:更新新地图接口
This commit is contained in:
parent
768fc88fca
commit
055b328432
@ -177,6 +177,54 @@ uni.getLocation({
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const getShowApiAddress = () => {
|
||||
// ShowAPI(易源数据) 逆地理编码
|
||||
const SHOWAPI_APP_KEY = 'C59885FE214644168eB4197eFe9a48b9'
|
||||
return new Promise<{ formatted_address: string }>((resolve, reject) => {
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
altitude: true,
|
||||
isHighAccuracy: true,
|
||||
success(res) {
|
||||
console.log(res, '经纬度')
|
||||
const url = `https://route.showapi.com/238-3?appKey=${SHOWAPI_APP_KEY}&lng=${res.longitude}&lat=${res.latitude}&from=5`
|
||||
uni.request({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
success(res: any) {
|
||||
console.log(res, 'address')
|
||||
data.value.current_city = res?.data?.showapi_res_body?.addressComponent || {}
|
||||
},
|
||||
fail(res) {
|
||||
resolve({ formatted_address: '拒绝定位' })
|
||||
console.error('获取地址失败:', res)
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先允许定位!',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
uni.openSetting()
|
||||
console.log('用户点击确定')
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fail(e) {
|
||||
console.log('拒绝定位', e)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
loading,
|
||||
hasError,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user