$.ajax({
type : "POST",
url: path + '/xxx',
data : {
url : location.href
},
dataType : "json",
success : function(data) {
var configData = {
beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题
debug : true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId : data.appId, // 必填,公众号的唯一标识
timestamp : data.timestamp, // 必填,生成签名的时间戳
nonceStr : data.nonceStr, // 必填,生成签名的随机串
signature : data.signature,// 必填,签名,见附录1
jsApiList : [ 'checkJsApi','getLocation'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
};
// 加载微信SDK引入js
$.getScript('https://res.wx.qq.com/open/js/jweixin-1.6.0.js').done(
function() {
wx.config(configData);
wx.ready(function() {
wx.checkJsApi({
jsApiList: ['getLocation'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function(res) {
alert('checkJsApi'+JSON.stringify(res));
wx.getLocation({
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: function (res) {
lat = res.latitude; // 纬度,浮点数,范围为90 ~ -90
lng = res.longitude ; // 经度,浮点数,范围为180 ~ -180。
},
fail: function (err) {
alert('获取位置失败1:' + JSON.stringify(err));
},
cancel: function (res) {
alert('用户拒绝授权获取地理位置');
}
});
}
});
});
});
},error:function(res){
alert('定位失败,请检查手机定位权限是否开通');
console.log('WXERRresult:'+res);
}
});

你好,企业微信相关问题请到企业微信社区咨询:https://developer.work.weixin.qq.com/community/question