wx.miniprogram.redirectto API报错 {errMsg: "invokeMiniProgramAPI:fail, the permission value is offline verifying"}, 之前一直没问题, 昨天突然报错
<!DOCTYPE html>
<html>
<head>
<title>授权</title>
<script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script>
/**获取url参数方法*/
function getParameterByName(name, url) {
if(!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
//匹配所有符合条件的,并取最后一个
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)",'g');
var results = url.match(regex);
var tempResults= results!=null && results[results.length-1]!=undefined?results[results.length-1]:'';
var finalResults=regex.exec(tempResults);
if(!finalResults) return "";
if(!finalResults[2]) return '';
return decodeURIComponent(finalResults[2].replace(/\+/g, " "));
}
if (getParameterByName('code')) {/**重新跳回小程序的方法*/
wx.miniProgram.redirectTo({url: '/pages/out/out?code=' + getParameterByName('code')})
//wx.miniProgram.switchTab({url: '/pages/index/index/main?code=' + getParameterByName('code')})
}else{
/**公众号授权方法*/
var uri = window.location.href;
window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxba45c92ec95c55bc&redirect_uri="+uri+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
}
</script>
</head>
<body>
<!-- <span style="background: red">haha</span> -->
</body>
</html>
请问你的问题解决了么,我也遇见这个问题了。不过我的没有成功跳转过,一开始就报同样的错
我猜是因为那个地址不是常规地址,是个tab
先试下 wx.miniProgram.switchTab 不带参数
如果不行,再试下wx.miniProgram.navigateTo