uniapp 小程序位置授权步骤:
1.
"permission": {
"scope.userLocation": {
"desc": "位置信息"
}
},
"requiredPrivateInfos": ["getLocation", "chooseLocation"]
3.
/**
* 获取位置
* @param {g} e
*/
getLocation() {
uni.getLocation({
altitude: true,
type: 'wgs84',
success: (res) => {
let location = {
lon: res.longitude,
lat: res.latitude,
accuracy: res.accuracy,
speed: res.speed,
}
uni.setStorageSync('locationCheck', 1);
uni.setStorageSync('location', JSON.stringify(location));
},
fail: ((err) => {
console.log(err)
})
});
},