wx.getFuzzyLocation BUG 微信小程序官方BUG 临时处理办法

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,一个真的 一个假的,可以先做后面的 官方修复了后可以不用改代码

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值