刷新列表的时候重新获取经纬度
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 })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -38,23 +38,23 @@
|
||||
<text class="text-22rpx leading-32rpx text-[#818CA9] ml-36rpx">更多茶艺师点击预约</text>
|
||||
</view>
|
||||
|
||||
<view class="mt-16rpx relative w-690rpx h-180rpx mx-30rpx" @click="router.navigateTo(`/bundle_b/pages/tea-specialist/list`)">
|
||||
<!-- <view class="mt-16rpx relative w-690rpx h-180rpx mx-30rpx" @click="router.navigateTo(`/bundle_b/pages/tea-specialist/list`)">
|
||||
<wd-img width="690rpx" height="180rpx" :src="`${OSS}images/home/home_image7.png`" mode="scaleToFill" />
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<!-- <view class="relative mt-40rpx h-44rpx mx-30rpx">
|
||||
<view class="relative mt-40rpx h-44rpx mx-30rpx">
|
||||
<view class="absolute ele-center" >
|
||||
<wd-img width="252.04rpx" height="24.43rpx" :src="`${OSS}images/home/home_image3.png`" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="text-32rpx text[#303133] font-500 absolute top-0 ele-center">预约茶室</view>
|
||||
</view> -->
|
||||
<!-- <view class="mt-16rpx relative w-690rpx h-180rpx mx-30rpx">
|
||||
</view>
|
||||
<view class="mt-16rpx relative w-690rpx h-180rpx mx-30rpx">
|
||||
<wd-img width="690rpx" height="180rpx" :src="`${OSS}images/home/home_image2.png`" mode="scaleToFill" />
|
||||
<view class="h-64rpx absolute bottom-0 right-0 bg-[#4C9F44] text-[#fff] flex items-center px-26rpx rounded">
|
||||
<text class="mr-8rpx">一键约</text>
|
||||
<wd-img width="22rpx" height="18.06rpx" :src="`${OSS}icon/icon_arrow_right.png`" mode="aspectFit" />
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
|
||||
<view>
|
||||
@ -113,7 +113,7 @@
|
||||
import { router } from '@/utils/tools'
|
||||
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
||||
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
|
||||
import { LOCATION_DENY_TIME_KEY, handleEnsureLocationAuthHooks, LOCATION_DEFAULT_CITY, handleGetLocationCity, LOCATION_CITY_KEY } from '@/hooks/useLocation'
|
||||
import { LOCATION_DENY_TIME_KEY, handleEnsureLocationAuthHooks, LOCATION_DEFAULT_CITY, handleGetLocationCity, LOCATION_CITY_KEY, handleForceGetLocation } from '@/hooks/useLocation'
|
||||
import { getHomeBannerList } from '@/api/home'
|
||||
import { getHomeTeaStoreList } from '@/api/tea-room'
|
||||
import { useUserStore } from '@/store'
|
||||
@ -142,7 +142,13 @@
|
||||
const city_id = ref<number>(0)
|
||||
|
||||
let lastLocation = { lat: 0, lng: 0 }
|
||||
const canLocation = ref<boolean>(false)
|
||||
onShow(async () => {
|
||||
// if (canLocation) {
|
||||
// const location = await handleGetLocationCity(latitude.value, longitude.value)
|
||||
// Index.handleResetSearch()
|
||||
// }
|
||||
// canLocation.value = true
|
||||
if (uni.getStorageSync(LOCATION_DENY_TIME_KEY)) {
|
||||
const location = await checkLocationAuthWithModal()
|
||||
if (location) {
|
||||
@ -186,10 +192,18 @@
|
||||
* 茶室门店列表
|
||||
* @param mescroll
|
||||
*/
|
||||
upCallback: (mescroll) => {
|
||||
upCallback: async (mescroll) => {
|
||||
const userStore = useUserStore()
|
||||
const userId = userStore.userInfo?.id || 0
|
||||
|
||||
if (canLocation.value ) {
|
||||
console.log("🚀 ~ 重置定位:", canLocation)
|
||||
const location = await handleEnsureLocationAuthHooks()
|
||||
latitude.value = location.lat
|
||||
longitude.value = location.lng
|
||||
}
|
||||
canLocation.value = true
|
||||
|
||||
const filter = {
|
||||
page: mescroll.num,
|
||||
size: mescroll.size,
|
||||
|
||||
Reference in New Issue
Block a user