wx.getLocation出现invalid url domain(特殊)
发布于 5 年前 作者 lei87 15220 次浏览 来自 问答

我的一个页面需要用到wx.getLocation,我直接用微信扫一扫这个页面是可以正常使用的,功能也正常

现在我有个需求就是从另一个页面跳转过来这个页面,就会出现invalid url domain错误

不知道域名有没有关系

直接扫的返回域名是这样的http://www.我的域名.net/roadgate/open.aspx

而跳转过去的域名是这样的http://我的域名.net/RoadGate/open.aspx

不知道问题出在哪里

部分代表如下

<script src="…/js/jquery-1.9.1.min.js" type=“text/javascript”></script>

    <script type=“text/javascript” src=“http://res.wx.qq.com/open/js/jweixin-1.0.0.js”></script>

    <script type=“text/javascript”>

        $(document).ready(function () {

            var url = window.location;

            $.post("…/Handler_post.ashx?act=loadconfig&url=" + escape(url), function (data) {

                var obj = jQuery.parseJSON(data);

                wx.config({

                    debug: false,

                    appId: obj.appId,

                    timestamp: obj.timestamp,

                    nonceStr: obj.nonceStr,

                    signature: obj.signature,

                    jsApiList: [

                “chooseImage”,

                “uploadImage”,

                “downloadImage”,

                “previewImage”,

                “getLocation”,

                “openLocation”

            ]

                });

            });

            wx.ready(function () {

                GetLocation();

            });

        });

        function GetLocation() {

            wx.getLocation({

                type: ‘wgs84’, // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入’gcj02’

                success: function (res) {

                    lat = res.latitude; // 纬度,浮点数,范围为90 ~ -90

                    lon = res.longitude; // 经度,浮点数,范围为180 ~ -180。

 

                },

                cancel: function (res) {

                    alert(“请允许获取地址后再次扫描”);

                },

                fail: function (res) {

                    alert(JSON.stringify(res));//跳转的话会进入到这里

                },

                error: function (res) {

                    //alert(res);

                }

            });

        }

2 回复

可是跳转过去

js获取出来的地址就是大写的啊.这没有错啊.微信返回过来的也是大写的域名地址

是匹配的

大小写?

回到顶部