微信公众号h5获取位置,部分手机已经打开了定位但是一直提示微信不能确定你的位置,这是什么原因呢?
发布于 3 年前 作者 juanguo 14819 次浏览 来自 问答

api:getLocation

代码片段:app.$options.api.share({

					url: window.location.href

				})

				.then(res => {

					this.$wx.config({

						debug: false, // 开启调试模式,调用的所有api的返回值会在客户端console.log出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。

						appId: res.data.data\["appid"\], // 必填,公众号的唯一标识

						timestamp: res.data.data\["timestamp"\], // 必填,生成签名的时间戳

						nonceStr: res.data.data\["noncestr"\], // 必填,生成签名的随机串

						signature: res.data.data\["signature"\], // 必填,签名

						jsApiList: \['updateTimelineShareData', 'updateAppMessageShareData', 'getLocation',

							'openLocation'

						\] // 必填,需要使用的JS接口列表

					});

					let \_this = this;

					this.$wx.ready(function() {

_this.$wx.getLocation({

type: 'gcj02',

success(res) {

console.log(res, "获取经纬度")

let latitude = res.latitude;

let longitude = res.longitude;

_this.latitude = latitude

_this.longitude = longitude

// alert(333)

_this.get_Query(latitude, longitude)

},

fail: err => {

console.log(err)

uni.showToast({

title:"用户拒绝了授权",

icon:"none",

duration:5000

})

}

})

							})

					})

				})
1 回复

你好,麻烦提供下机型,微信版本号和复现链接

回到顶部