From bc279cccb0276116b17b7994bf1cc38814ca0443 Mon Sep 17 00:00:00 2001 From: lfs3 Date: Mon, 26 Aug 2019 14:30:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=BD=8Dbug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/wxLocation.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/models/wxLocation.js b/src/models/wxLocation.js index d840322..b35f0c3 100644 --- a/src/models/wxLocation.js +++ b/src/models/wxLocation.js @@ -18,12 +18,17 @@ Vue.prototype.wxLocation = function () { nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回 signature: jsApiSignConfig.signature, // 必填,签名 由接口返回 jsApiList: [ - "onMenuShareAppMessage", - "onMenuShareTimeline", - "onMenuShareQQ", - "onMenuShareWeibo", - "onMenuShareQZone" - ] + 'checkJsApi', 'openLocation', 'getLocation' + ], + }); + wx.checkJsApi({ + jsApiList: ['getLocation'], + success: function (res) { + if (res.checkResult.getLocation == false) { + alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!'); + return; + } + } }); wx.ready(() => { // 首次进入页面进会弹窗确认地理位置 @@ -46,7 +51,7 @@ Vue.prototype.wxLocation = function () { }); }, cancel: function () { - alter("拒绝定位"); + alert("拒绝定位"); } }); } else { @@ -54,7 +59,7 @@ Vue.prototype.wxLocation = function () { } alert("lat:" + localStorage.getItem("latitude") + ";lng:" + localStorage.getItem("longitude")); wx.error(function (res) { - alter("wx-js初始化: " + res); + alert("wx-js初始化: " + res); }); }); });