Browse Source

定位返回空值问题处理

feature/3.1.0-小区合伙人
lfs3 6 years ago
parent
commit
b6dc8df503
1 changed files with 3 additions and 1 deletions
  1. 4
      src/models/wxLocation.js

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

Loading…
Cancel
Save