小程序web-view中跳回小程序,华为P20 Pro无法成功,请问是什么原因?
发布于 5 年前 作者 fanping 10424 次浏览 来自 官方Issues

如标题:小程序web-view中跳回小程序(wx.miniProgram.redirectTo),华为P20 Pro无法成功,报“invokeMiniProgramAPI: permission denied”,其他手机如小米,apple,VIVO又正常。请问是什么原因?谢谢。

1.错误提示如截图:

2.代码如下:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
	<link rel="stylesheet" type="text/css" href="loading.css">
</head>

<body>
	<div class="load-container load2" id="m-loading">
        <div class="loader">Loading...</div>
    </div>

    <script>
        let needReturn = false;
        let errmsg = getQueryString('errmsg');
        if (errmsg) {
            needReturn = true;
			document.write('<br/> Error message: ' + errmsg);
            alert(errmsg);
        }

        if (needReturn == false) {
            let step = getQueryString('step');
            if (step) {
                switch (step) {
                    case 'Completed':
                        var access_token = getQueryString('access_token');
				
						let url = '/pages/webview/webview?access_token=' + access_token;
						wx.miniProgram.getEnv(function(res) {
							console.log(res.miniprogram); // true
							if(res.miniprogram){
								wx.miniProgram.redirectTo({ url: url,
									success: function() {
									console.log("success");
									},
									fail: function(error) {
									console.log(error);
									alert(JSON.stringify(error));
									},
									complete: function() {
									console.log("complete");
									} });
							} else{
								alert('You are not in WeChat!');
							}
						});
							
                        break;
                    default:
                        break;
                }
            }
        }

    </script>

</body>

</html>
1 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)

回到顶部