function getAuthor() {
wx.getLocation({
type: 'wgs84',
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
}
})
wx.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
openSetting();
}
}
})
}
function openSetting() {
wx.openSetting({
success: (res) => {
if (!res.authSetting['scope.userLocation']) {
showRemind();
}
}, fail: (res) => {
if (!res.authSetting['scope.userLocation']) {
showRemind();
}
}
})
}
function showRemind() {
wx.showModal({
title: '温馨提醒',
content: '需要获取您的地理位置才能使用小程序',
showCancel: false,
confirmText: '获取位置',
success: function (res) {
if (res.confirm) {
getAuthor();
}
},fail: (res) => {
getAuthor();
}
})
}
微信小程序 兼容用户拒绝获取位置权限 用户拒绝权限处理
猜你喜欢
转载自blog.csdn.net/Qinhaolei/article/details/77989438
今日推荐
周排行