First bind open-type, bind click event, bindopenSetting time, here the official document also prompts openSetting to open the authorization setting page
<view>请开启定位权限</view>
<button open-type="openSetting" bindopensetting="settingCallback">去开启</button>
Use the scope.userLocation == true returned by the event callback object to judge that the user has been authorized, so as to reacquire the user location
// 设置页回调
settingCallback(e) {
// 判断用户点击的使用小程序时授权
if (e.detail.authSetting['scope.userLocation'] == true) {
// 重新获取用户位置
this.getLoaction();
}
},