20220720处理getFuzzyLocation 微信小程序官方BUG 临时办法
微信小程序发布了最新的地理位置获取为背景
几乎不可能申请到原有的getLocation
但是getFuzzyLocation 申请的很快(这个要在自己的小程序主页申请,就是发布那个网站)
现在最新办的微信开发工具都不能使用这个功能
wx.getFuzzyLocation({
type: 'wgs84',
success (res) {
const latitude = res.latitude
const longitude = res.longitude
},fail 这里打印就可以看到
})
除非真机调试,但是太麻烦了 给出零时处理方式:
uni.showLoading({
title: '加载中...',
mask: false
});
return new Promise((resolve, reject) => {
wx.getFuzzyLocation({
type: 'wgs84',
success(res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
resolve({
'longitude': res.longitude,
'latitude': res.latitude
})
},
fail: () => {
console.log("getFuzzyLocation失效,也用resolve编写一个地理位置");
resolve({
'longitude': 104.085697,
'latitude': 30.632406
})
}
});
}).then((value) => {
// console.log('resolve');
this.userLongitude = value.longitude
this.userLatitude = value.latitude
console.log("this.userLatitude: ", this.userLatitude);
console.log("this.userLongitude: ", this.userLongitude);
后面自己写, 两个resolve,一个真的 一个假的,可以先做后面的 官方修复了后可以不用改代码