微信获取当前位置-vue中

来源:互联网 发布:2017百万公众网络测试 编辑:程序博客网 时间:2024/05/21 09:23
//获取微信配置getShopWxConfig(){    let that = this;    let params = {        url: 'http://www.123.com/shop/index1.html'    }    getShopWxConfigData(params).then(res => {        console.log(res)        wx.config({            debug: false,            appId: res.appId,            nonceStr: res.nonceStr,            timestamp: res.timestamp,            url: res.url,            signature: res.signature,            jsApiList: [                'checkJsApi', 'openLocation', 'getLocation'            ],        })        wx.checkJsApi({            jsApiList: ['getLocation'],            success: function (res) {                if (res.checkResult.getLocation == false) {                    alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');                    return;                }            }        });        wx.ready(function () {//                wx.invoke('getLocation', 'openLocation', {}, function(res) {//                    //alert(res.err_msg + "唯一");//                });            wx.getLocation({                success: function (res) {//                                console.log(res)                    that.pointY = res.latitude; // 纬度,浮点数,范围为90 ~ -90                    that.pointX = res.longitude; // 经度,浮点数,范围为180 ~ -180。                    that.point = new BMap.Point(that.pointX,that.pointY);                    that.marker = new BMap.Marker(that.point); // 创建点                    that.getShopFjStudio()                },                cancel: function (res) {                    alert('用户拒绝授权获取地理位置');                    that.getShopFjStudio()                }            });        });        wx.error(function (res) {//                        console.log(res)            that.getShopFjStudio()        });    }).catch(res => {        console.log(res)    })},
阅读全文
0 0
原创粉丝点击