|
|
@ -2,6 +2,7 @@ import Vue from "vue"; |
|
|
import wx from "weixin-js-sdk"; |
|
|
import wx from "weixin-js-sdk"; |
|
|
import axios from "axios"; |
|
|
import axios from "axios"; |
|
|
import wxShareModel from "../models/wxShare-model.js"; |
|
|
import wxShareModel from "../models/wxShare-model.js"; |
|
|
|
|
|
import { isEmpty } from "@/common/util"; |
|
|
let instance = axios.create(); |
|
|
let instance = axios.create(); |
|
|
//引入BMap
|
|
|
//引入BMap
|
|
|
import BMap from "BMap"; |
|
|
import BMap from "BMap"; |
|
|
@ -33,7 +34,7 @@ Vue.prototype.wxLocation = function () { |
|
|
}); |
|
|
}); |
|
|
wx.ready(() => { |
|
|
wx.ready(() => { |
|
|
// 首次进入页面进会弹窗确认地理位置
|
|
|
// 首次进入页面进会弹窗确认地理位置
|
|
|
if (localStorage.getItem("latitude") == null) { |
|
|
|
|
|
|
|
|
if (localStorage.getItem("latitude") == null || localStorage.getItem("latitude") == undefined) { |
|
|
wx.getLocation({ |
|
|
wx.getLocation({ |
|
|
type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
|
|
type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
|
|
success: function (res) { |
|
|
success: function (res) { |
|
|
@ -48,6 +49,7 @@ Vue.prototype.wxLocation = function () { |
|
|
jsonp: "callback", |
|
|
jsonp: "callback", |
|
|
success: function (data) { |
|
|
success: function (data) { |
|
|
// alert('data.result.location.lng:' + data.result.location.lng + '-----data.result.location.lat:' + data.result.location.lat);
|
|
|
// 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("latitude", data.result.location.lat); |
|
|
localStorage.setItem("longitude", data.result.location.lng); |
|
|
localStorage.setItem("longitude", data.result.location.lng); |
|
|
resolve("定位成功") |
|
|
resolve("定位成功") |
|
|
|