uni-app h5页面集成微信定位jssdk,一直报错哪位看下什么原因,附图和代码

Snip20200226_3.png
两个地方报错,是什么原因呢?
报错 wx.error=config:fail,Error: 系统错误,错误码:63002,invalid signature
报错 wx.getLocation失败res={"errMsg":"getLocation:fail, the permission value is offline verifying"}

html代码

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
        <script src="testSdk.js" type="text/javascript"></script>
        <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
        
    </head>
    <body>
        <div id="" style="font-size: 80px;">
            测试微信定位demo
        </div>
    </body>
</html>

js代码


var json;

$(function () {
    
    $.ajax({
        url: "http://mika_jjz.s3.samyak.cn/api/youzan/youzanAPI.ashx?act=getAdressInfo",
        dataType:'json',
        async: false,
        success:function (data)
        {
            console.log("data=" +JSON.stringify(data));
            json= data;
        }
    });
    
    
    console.log("json.Id=" + JSON.stringify(json.authorizer_appid));
    console.log("json.timestamp=" + JSON.stringify(json.timestamp));
    console.log("json.noncestr=" + JSON.stringify(json.noncestr));
    console.log("json.signature=" + JSON.stringify(json.signature));
    
    
    wx.config({
         debug: true,
         appId: json.authorizer_appid,
         timestamp: json.timestamp,
         nonceStr: json.noncestr,
         signature: json.signature,
         jsApiList: [
             "getLocation"
         ]
    });
     
    wx.error(function (res) {
        console.log("wx.error=" +res.errMsg); 
    }); 
    
    
    wx.ready(function () {
        wx.getLocation({
            type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
            success: function (res) {
                var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
                var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。 
                console.log("latitude=" + latitude);
                console.log("longitude=" + longitude);
                console.log('微信定位成功;'); 
                
            },
            fail: function(res){
                console.log('wx.getLocation失败res=' + JSON.stringify(res));
            }
        });
    });
});
阅读 3.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题