This commit is contained in:
lcj
2026-07-15 16:53:38 +08:00
parent 073dfa5c00
commit 5cab2be283
4008 changed files with 49859 additions and 1095 deletions
+30
View File
@@ -0,0 +1,30 @@
export default {
getLocation() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(pos) => {
const lng = pos.coords.longitude
const lat = pos.coords.latitude
uni.setStorageSync('lng', lng)
uni.setStorageSync('lat', lat)
resolve({ lng, lat })
},
(err) => {
console.log('定位失败:', err.message)
reject(err)
},
{ timeout: 10000, enableHighAccuracy: false }
)
} else {
reject(new Error('浏览器不支持定位'))
}
})
},
getCachedLocation() {
return {
lng: uni.getStorageSync('lng') || '',
lat: uni.getStorageSync('lat') || ''
}
}
}