From b6dc8df5036f77d7cb174aaa92c7280e28a29e23 Mon Sep 17 00:00:00 2001 From: lfs3 Date: Thu, 26 Sep 2019 11:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E8=BF=94=E5=9B=9E=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E9=97=AE=E9=A2=98=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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/wxLocation.js b/src/models/wxLocation.js index c7a0dd9..a961948 100644 --- a/src/models/wxLocation.js +++ b/src/models/wxLocation.js @@ -2,6 +2,7 @@ import Vue from "vue"; import wx from "weixin-js-sdk"; import axios from "axios"; import wxShareModel from "../models/wxShare-model.js"; +import { isEmpty } from "@/common/util"; let instance = axios.create(); //引入BMap import BMap from "BMap"; @@ -33,7 +34,7 @@ Vue.prototype.wxLocation = function () { }); wx.ready(() => { // 首次进入页面进会弹窗确认地理位置 - if (localStorage.getItem("latitude") == null) { + if (localStorage.getItem("latitude") == null || localStorage.getItem("latitude") == undefined) { wx.getLocation({ type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' success: function (res) { @@ -48,6 +49,7 @@ Vue.prototype.wxLocation = function () { jsonp: "callback", success: function (data) { // alert('data.result.location.lng:' + data.result.location.lng + '-----data.result.location.lat:' + data.result.location.lat); + if(isEmpty(data.result.location.lat) || isEmpty( data.result.location.lng)) return; localStorage.setItem("latitude", data.result.location.lat); localStorage.setItem("longitude", data.result.location.lng); resolve("定位成功")