首先绑定open-type,绑定点击事件,bindopenSetting时间,在这里官方文档也有提示openSetting打开授权设置页
<view>请开启定位权限</view>
<button open-type="openSetting" bindopensetting="settingCallback">去开启</button>
通过事件回调对象返回的scope.userLocation == true 判断用户已授权,从而进行重新获取用户位置
// 设置页回调
settingCallback(e) {
// 判断用户点击的使用小程序时授权
if (e.detail.authSetting['scope.userLocation'] == true) {
// 重新获取用户位置
this.getLoaction();
}
},