微信公众号调用wx.getLocation获取位置?
微信公众号调用wx.getLocation, 第一次会走fail回调,报getLocation:fail, the permission value is online verifying,刷新一下页面,再点击获取位置,就正常了 getLocal() { var _this = this let url = window.location.href _this.$api.local(url).then((res) => { wx.config({ beta: true, debug: true, appId: res.data.appId, timestamp: res.data.timestamp, nonceStr: res.data.nonceStr, signature: res.data.signature, jsApiList: ['checkJsApi', 'getLocation', 'openLocation'] }); wx.checkJsApi({ jsApiList: ['getLocation'], success: function (res) { if (res.checkResult.getLocation == false) { Toast('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!'); return; } }, fail: function (res) { console.info('checkJsApi fail=' + JSON.stringify(res)) } }); wx.ready(function () { wx.getLocation({ type: "gcj02", success: function (res) { }, cancel: function (res) { Toast('查看附件机器,首先要授权位置信息') }, fail: function (res) { console.info('ready getLocation fail=' + JSON.stringify(res)) Toast('出现故障,请联系管理员') } }); }) }).catch((res) => {}) },