移除地理位置缓存
This commit is contained in:
@ -152,12 +152,12 @@ export function handleSetLocationCacheHooks(lat: number, lng: number) {
|
|||||||
|
|
||||||
// VERSION1: 初始化经纬度
|
// VERSION1: 初始化经纬度
|
||||||
export async function handleEnsureLocationAuthHooks() {
|
export async function handleEnsureLocationAuthHooks() {
|
||||||
// 1. 检查缓存
|
// 1. 检查缓存-先把缓存去掉
|
||||||
if (handleCheckLocationCacheHooks()) {
|
// if (handleCheckLocationCacheHooks()) {
|
||||||
const lat = uni.getStorageSync(LOCATION_LAT_KEY)
|
// const lat = uni.getStorageSync(LOCATION_LAT_KEY)
|
||||||
const lng = uni.getStorageSync(LOCATION_LNG_KEY)
|
// const lng = uni.getStorageSync(LOCATION_LNG_KEY)
|
||||||
if (lat && lng) return { lat, lng }
|
// if (lat && lng) return { lat, lng }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 2. 获取定位
|
// 2. 获取定位
|
||||||
return new Promise<{ lat: number, lng: number, }>((resolve) => {
|
return new Promise<{ lat: number, lng: number, }>((resolve) => {
|
||||||
|
|||||||
@ -185,6 +185,7 @@
|
|||||||
// Index.handleResetSearch()
|
// Index.handleResetSearch()
|
||||||
// }
|
// }
|
||||||
// canLocation.value = true
|
// canLocation.value = true
|
||||||
|
// 检测用户授权地理位置的缓存LOCATION_DENY_TIME_KEY
|
||||||
if (uni.getStorageSync(LOCATION_DENY_TIME_KEY)) {
|
if (uni.getStorageSync(LOCATION_DENY_TIME_KEY)) {
|
||||||
const location = await checkLocationAuthWithModal()
|
const location = await checkLocationAuthWithModal()
|
||||||
if (location) {
|
if (location) {
|
||||||
@ -223,6 +224,7 @@
|
|||||||
latitude.value = lat
|
latitude.value = lat
|
||||||
longitude.value = lng
|
longitude.value = lng
|
||||||
|
|
||||||
|
// 根据经纬度获取城市信息再重新赋值经纬度和城市
|
||||||
const location = await handleGetLocationCity(lat, lng)
|
const location = await handleGetLocationCity(lat, lng)
|
||||||
city.value = location.city
|
city.value = location.city
|
||||||
latitude.value = location.latitude
|
latitude.value = location.latitude
|
||||||
|
|||||||
Reference in New Issue
Block a user