使用wx.miniProgram.navigateTo从web-view里面的网页打开小程序的一个页面/pages/locat/locat时没有响应。在开发工具上能正常跳转的,但是在真机上就没有响应了。请求指导帮助!
网页:
<script src=“https://res.wx.qq.com/open/js/jweixin-1.3.2.js” charset=“utf-8”></script>
<script>
$(".dizhi_img").on(“click”,function () {
var mappoint = $(this).attr(“data-mappoint”).split(",");
var latitude = mappoint[1];
var longitude = mappoint[0];
var url = ‘/pages/location/location?latitude=’+encodeURIComponent(latitude)+’&longitude=’+encodeURIComponent(longitude)+
‘&name=’+encodeURIComponent($(this).attr(“data-name”))+’&address=’+encodeURIComponent($(this).attr(“data-address”));
wx.miniProgram.navigateTo({
url:url,
success: function(){
console.log(‘success’)
},
fail: function(){
console.log(‘fail’);
},
complete:function(){
console.log(‘complete’);
}
});
});
</script>
小程序:
new Promise((resolve, reject) => {
// 位置授权
wx.getSetting({
success(res) {
if (!res.authSetting[‘scope.userLocation’]) {
wx.authorize({
scope: ‘scope.userLocation’,
success(){
// 用户已经同意位置权限
resolve(true);
},
fail(){
resolve(false);
}
});
} else {
//用户原来已经授予过权限
resolve(true);
}
},
fail() {
resolve(false);
}
});
// resolve(localtiontag);
}).then((relc) => {
console.log(relc);
if(relc == true){
wx.getLocation({//获取当前经纬度
type: ‘wgs84’, //返回可以用于wx.openLocation的经纬度
success: function (res) {
wx.openLocation({//使用微信内置地图查看位置。
latitude: parseFloat(decodeURIComponent(options.latitude)),//要去的纬度-地址
longitude: parseFloat(decodeURIComponent(options.longitude)),//要去的经度-地址
name: decodeURIComponent(options.name),
address: decodeURIComponent(options.address)
});
}
});
}else{
wx.navigateBack({ changed: true });
}
});