feat : 一体机定位直到成功,其他环境循环2分钟定位, 上传加入文件校验
This commit is contained in:
@@ -11,13 +11,15 @@ import config from '../config';
|
||||
|
||||
const defalutLongLat = {
|
||||
longitude: 120.382665,
|
||||
latitude: 36.066938
|
||||
latitude: 36.066938,
|
||||
}
|
||||
|
||||
const useLocationStore = defineStore("location", () => {
|
||||
// 定义状态
|
||||
const longitudeVal = ref(null) // 经度
|
||||
const latitudeVal = ref(null) //纬度
|
||||
const timer = ref(null)
|
||||
const count = ref(0)
|
||||
|
||||
function getLocation() { // 获取经纬度两个平台
|
||||
return new Promise((resole, reject) => {
|
||||
@@ -66,6 +68,21 @@ const useLocationStore = defineStore("location", () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
function getLocationLoop(gap = 1000 * 60 * 2) {
|
||||
console.log(`🔄开始循环获取定位,间隔:${Math.floor(gap/1000)}秒`)
|
||||
const run = () => {
|
||||
count.value++
|
||||
console.log(`📍第${count.value}次获取定位`)
|
||||
getLocation()
|
||||
}
|
||||
run()
|
||||
timer.value = setInterval(run,gap);
|
||||
}
|
||||
|
||||
function clearGetLocationLoop(params) {
|
||||
clearInterval(timer.value)
|
||||
timer.value = null
|
||||
}
|
||||
|
||||
function longitude() {
|
||||
return longitudeVal.value
|
||||
@@ -78,9 +95,10 @@ const useLocationStore = defineStore("location", () => {
|
||||
// 导入
|
||||
return {
|
||||
getLocation,
|
||||
getLocationLoop,
|
||||
clearGetLocationLoop,
|
||||
longitudeVal,
|
||||
latitudeVal
|
||||
|
||||
latitudeVal,
|
||||
}
|
||||
}, {
|
||||
unistorage: true,
|
||||
|
||||
Reference in New Issue
Block a user