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() { function getLocation() {
return new Promise((resole, reject) => { return new Promise((resole, reject) => {
uni.getLocation({ try {
type: 'wgs84', lightAppJssdk.map.getLocation({
altitude: true, success: function(data) {
isHighAccuracy: true, longitudeVal.value = Number(data.longitude)
enableHighAccuracy: true, // 关键参数:启用传感器辅助 latitudeVal.value = Number(data.latitude)
timeout: 10000, resole(data)
success: function(res) { },
const resd = { fail: function(data) {
longitude: 120.382665, longitudeVal.value = 120.382665
latitude: 36.066938 latitudeVal.value = 36.066938
resole({
longitude: 120.382665,
latitude: 36.066938
})
msg('用户位置获取失败')
console.log('失败', data)
} }
if (config.UsingSimulatedPositioning) { // 使用模拟定位 })
longitudeVal.value = resd.longitude } catch (e) {
latitudeVal.value = resd.latitude longitudeVal.value = 120.382665
msg('用户位置获取成功') latitudeVal.value = 36.066938
resole(resd) resole({
} else { longitude: 120.382665,
longitudeVal.value = res.longitude latitude: 36.066938
latitudeVal.value = res.latitude })
msg('用户位置获取成功') msg('测试环境,使用模拟定位')
resole(res) console.log('失败', data)
} }
},
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))
}
})
}) })
} }