flat: 对接经纬度

This commit is contained in:
Apcallover
2025-11-24 18:40:59 +08:00
parent 9f92fc47cb
commit 378f71f3c7

View File

@@ -16,46 +16,34 @@ const useLocationStore = defineStore("location", () => {
function getLocation() {
return new Promise((resole, reject) => {
uni.getLocation({
type: 'wgs84',
altitude: true,
isHighAccuracy: true,
enableHighAccuracy: true, // 关键参数:启用传感器辅助
timeout: 10000,
success: function(res) {
const resd = {
longitude: 120.382665,
latitude: 36.066938
try {
lightAppJssdk.map.getLocation({
success: function(data) {
longitudeVal.value = Number(data.longitude)
latitudeVal.value = Number(data.latitude)
resole(data)
},
fail: function(data) {
longitudeVal.value = 120.382665
latitudeVal.value = 36.066938
resole({
longitude: 120.382665,
latitude: 36.066938
})
msg('用户位置获取失败')
console.log('失败', data)
}
if (config.UsingSimulatedPositioning) { // 使用模拟定位
longitudeVal.value = resd.longitude
latitudeVal.value = resd.latitude
msg('用户位置获取成功')
resole(resd)
} else {
longitudeVal.value = res.longitude
latitudeVal.value = res.latitude
msg('用户位置获取成功')
resole(res)
}
},
fail: function(err) {
// longitudeVal.value = ''
// latitudeVal.value = ''
// reject(err)
const resd = {
longitude: 120.382665,
latitude: 36.066938
}
longitudeVal.value = resd.longitude
latitudeVal.value = resd.latitude
msg('用户位置获取失败,使用模拟定位')
resole(resd)
},
complete: function(e) {
console.warn('getUserLocation' + JSON.stringify(e))
}
})
})
} catch (e) {
longitudeVal.value = 120.382665
latitudeVal.value = 36.066938
resole({
longitude: 120.382665,
latitude: 36.066938
})
msg('测试环境,使用模拟定位')
console.log('失败', data)
}
})
}