fix: 折扣页无定位缓存时主动获取定位,保证商铺距离展示
This commit is contained in:
@@ -56,14 +56,21 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
const loc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
const hasLoc = uni.getStorageSync('lng') && uni.getStorageSync('lat')
|
||||||
? { lng: uni.getStorageSync('lng'), lat: uni.getStorageSync('lat') }
|
if (hasLoc) {
|
||||||
: null
|
this.lng = uni.getStorageSync('lng')
|
||||||
if (loc) {
|
this.lat = uni.getStorageSync('lat')
|
||||||
this.lng = loc.lng
|
this.loadList()
|
||||||
this.lat = loc.lat
|
} 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: {
|
methods: {
|
||||||
loadList() {
|
loadList() {
|
||||||
|
|||||||
Reference in New Issue
Block a user