刷新列表的时候重新获取经纬度

This commit is contained in:
wangxiaowei
2025-12-28 18:33:42 +08:00
parent 2622d5a572
commit 3d1f33107a
2 changed files with 50 additions and 8 deletions

View File

@ -307,3 +307,31 @@ function shouldShowAuthModal() {
const lastDeny = uni.getStorageSync(LOCATION_DENY_TIME_KEY)
return !lastDeny || (Date.now() - lastDeny > LOCATION_DENY_INTERVAL)
}
// 强制获取定位(不走缓存,每次都重新定位)
export function handleForceGetLocation(): Promise<{ lat: number, lng: number }> {
return new Promise((resolve) => {
uni.authorize({
scope: 'scope.userLocation',
success() {
uni.getLocation({
type: 'gcj02',
success(res) {
console.log("🚀 ~ 开始请求定位授权handleForceGetLocation ~ res:", res)
handleSetLocationCacheHooks(res.latitude, res.longitude)
resolve({ lat: res.latitude, lng: res.longitude })
},
fail() {
handleSetLocationCacheHooks(LOCATION_DEFAULT_LAT, LOCATION_DEFAULT_LNG)
resolve({ lat: LOCATION_DEFAULT_LAT, lng: LOCATION_DEFAULT_LNG })
}
})
},
fail() {
handleSetLocationCacheHooks(LOCATION_DEFAULT_LAT, LOCATION_DEFAULT_LNG)
resolve({ lat: LOCATION_DEFAULT_LAT, lng: LOCATION_DEFAULT_LNG })
}
})
})
}