getLocation() {
uni.getLocation({
type: 'gcj02',
altitude: true,
success(res) {
let latAndLon = {
mylog: res.longitude,
mylat: res.latitude
}
uni.setStorageSync('latAndLon', latAndLon)
}
})
},
getSetting() {
const that = this
uni.getSetting({
success(res) {
if (res.authSetting['scope.userLocation']) {
that.getLocation()
} else {
that.getAuthorize()
}
}
})
},
getAuthorize() {
let that = this
uni.authorize({
scope: 'scope.userLocation',
success(res) {
that.getLocation()
},
fail(err) {
uni.showModal({
title: '提示',
content: '请授权位置获取附近的商家!',
showCancel: false,
confirmText: '确认授权',
success() {
uni.openSetting({
success(res) {},
fail(err) {}
})
}
})
}
})
},
|