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("定位成功")