fix: 折扣页无定位缓存时主动获取定位,保证商铺距离展示
This commit is contained in:
@@ -56,14 +56,21 @@ export default {
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const loc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
||||
? { lng: uni.getStorageSync('lng'), lat: uni.getStorageSync('lat') }
|
||||
: null
|
||||
if (loc) {
|
||||
this.lng = loc.lng
|
||||
this.lat = loc.lat
|
||||
const hasLoc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
||||
if (hasLoc) {
|
||||
this.lng = uni.getStorageSync('lng')
|
||||
this.lat = uni.getStorageSync('lat')
|
||||
this.loadList()
|
||||
} else {
|
||||
// xuchao: 定位仅在首页触发过,直接进本页无缓存时主动获取一次,保证距离列可展示
|
||||
import('@/common/location.js').then(module => module.default.getLocation())
|
||||
.then(({ lng, lat }) => {
|
||||
this.lng = lng
|
||||
this.lat = lat
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => this.loadList())
|
||||
}
|
||||
this.loadList()
|
||||
},
|
||||
methods: {
|
||||
loadList() {
|
||||
|
||||
Reference in New Issue
Block a user