刷新列表的时候重新获取经纬度
This commit is contained in:
@ -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 })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user