在安卓端和开发工具里面都能正常获取到经纬度,传入的url就是页面初始进入的url
let url
if (navigator.userAgent.indexOf('iPhone') !== -1) { // BUG: IOS获取签名传递的URL必须是项目一打开的首页URL,否则签名无效
url = Cache.get('href') ? Cache.get('href') : location.href
} else { // 安卓传递当前页面URL
url = location.href
}
// 此处存在BUG如果url中存在参数需要陷阱行转码才能传给后端,否则生成的签名错误 encodeURIComponent(url)
getJsSdk({ url: encodeURIComponent(url)}).then(res=>{
wx.config({
debug: false,
appId: res?.data?.appId,
timestamp: res?.data?.timestamp,
nonceStr: res?.data?.noncestr,
signature: res?.data?.signature,
jsApiList: ['getLocation']
})
wx.ready(()=>{
wx.checkJsApi({
jsApiList: ['getLocation'],
success: function(res){
console.log(res)
if (res.checkResult['getLocation']) {
wx.getLocation({
type: 'wgs84',
isHighAccuracy: true,
altitude: true,
success: function(res){
const latitude = res.latitude
const longitude = res.longitude
map.value.setCenter([res.longitude, res.latitude]);
showInfoClick({
lnglat: [res.longitude, res.latitude]
})
},
fail(res) {
title.value = JSON.stringify(res)
}
})
} else {
alert('你的微信版本过低,请更新至最新版本。');
}
}
})
})
}).catch(err=>{
})

最后你是怎么处理的?
vue的问题,跟jssdk没关系
问题就是你写注释的那句话