瀏覽代碼

Task H5定位等待指示器

rongxin_dev
Zhao 1 天之前
父節點
當前提交
6fefd1df69
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. +8
    -1
      src/components/Map/MapGisLine.vue
  2. +7
    -0
      src/components/Map/MapGisTagDTGCopy.vue

+ 8
- 1
src/components/Map/MapGisLine.vue 查看文件

@@ -23,6 +23,7 @@
import {getQueryLand} from "@/api/homesteadSurvey/zjdzd"; import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
import $ from "jquery"; import $ from "jquery";
import { getConfigKey } from "@/api/system/config"; import { getConfigKey } from "@/api/system/config";
import {Toast} from "vant";


export default { export default {
components: { components: {
@@ -147,11 +148,15 @@ export default {
// 2. 再尝试浏览器 // 2. 再尝试浏览器
if (navigator.geolocation) { if (navigator.geolocation) {
console.log('使用浏览器获取定位'); console.log('使用浏览器获取定位');
const loading = Toast.loading({
message: '定位中...',
duration: 0,
});
let timeout = this.getLocationTimeout(); let timeout = this.getLocationTimeout();
navigator.geolocation.getCurrentPosition( navigator.geolocation.getCurrentPosition(
(position) => { (position) => {
const { latitude, longitude } = position.coords; const { latitude, longitude } = position.coords;
console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);1
console.log('浏览器定位结果: 经纬度=' + longitude + ', ' + latitude);
let res = { let res = {
code: 200, code: 200,
data: { data: {
@@ -159,9 +164,11 @@ export default {
lat: latitude, lat: latitude,
}, },
}; };
loading.clear();
callback(res); callback(res);
}, },
(error) => { (error) => {
loading.clear();
console.log('定位失败: ' + error.message); console.log('定位失败: ' + error.message);
getQueryLand().then(callback); getQueryLand().then(callback);
}, },


+ 7
- 0
src/components/Map/MapGisTagDTGCopy.vue 查看文件

@@ -21,6 +21,7 @@
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import {getQueryLand} from "@/api/homesteadSurvey/zjdzd"; import {getQueryLand} from "@/api/homesteadSurvey/zjdzd";
import { getConfigKey } from "@/api/system/config"; import { getConfigKey } from "@/api/system/config";
import {Toast} from "vant";


export default { export default {
data() { data() {
@@ -143,6 +144,10 @@
// 2. 再尝试浏览器 // 2. 再尝试浏览器
if (navigator.geolocation) { if (navigator.geolocation) {
console.log('使用浏览器获取定位'); console.log('使用浏览器获取定位');
const loading = Toast.loading({
message: '定位中...',
duration: 0,
});
let timeout = this.getLocationTimeout(); let timeout = this.getLocationTimeout();
navigator.geolocation.getCurrentPosition( navigator.geolocation.getCurrentPosition(
(position) => { (position) => {
@@ -155,9 +160,11 @@
lat: latitude, lat: latitude,
}, },
}; };
loading.clear();
callback(res); callback(res);
}, },
(error) => { (error) => {
loading.clear();
console.log('定位失败: ' + error.message); console.log('定位失败: ' + error.message);
getQueryLand().then(callback); getQueryLand().then(callback);
}, },


Loading…
取消
儲存