flat: 合并代码
This commit is contained in:
@@ -9,6 +9,11 @@ import {
|
||||
} from '@/common/globalFunction.js'
|
||||
import config from '../config';
|
||||
|
||||
const defalutLongLat = {
|
||||
longitude: 120.382665,
|
||||
latitude: 36.066938
|
||||
}
|
||||
|
||||
const useLocationStore = defineStore("location", () => {
|
||||
// 定义状态
|
||||
const longitudeVal = ref(null) // 经度
|
||||
@@ -25,46 +30,39 @@ const useLocationStore = defineStore("location", () => {
|
||||
resole(data)
|
||||
},
|
||||
fail: function(data) {
|
||||
longitudeVal.value = 120.382665
|
||||
latitudeVal.value = 36.066938
|
||||
resole({
|
||||
longitude: 120.382665,
|
||||
latitude: 36.066938
|
||||
})
|
||||
longitudeVal.value = defalutLongLat.longitude
|
||||
latitudeVal.value = defalutLongLat.latitude
|
||||
resole(defalutLongLat)
|
||||
msg('用户位置获取失败')
|
||||
console.log('失败3', data)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
highAccuracyExpireTime: 3000,
|
||||
isHighAccuracy: true,
|
||||
timeout: 2000,
|
||||
// highAccuracyExpireTime: 3000,
|
||||
// isHighAccuracy: true,
|
||||
// timeout: 2000,
|
||||
success: function(data) {
|
||||
longitudeVal.value = Number(data.longitude)
|
||||
latitudeVal.value = Number(data.latitude)
|
||||
resole(data)
|
||||
},
|
||||
fail: function(data) {
|
||||
longitudeVal.value = 120.382665
|
||||
latitudeVal.value = 36.066938
|
||||
resole({
|
||||
longitude: 120.382665,
|
||||
latitude: 36.066938
|
||||
})
|
||||
longitudeVal.value = defalutLongLat.longitude
|
||||
latitudeVal.value = defalutLongLat.latitude
|
||||
resole(defalutLongLat)
|
||||
msg('用户位置获取失败')
|
||||
console.log('失败2', data)
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
longitudeVal.value = 120.382665
|
||||
latitudeVal.value = 36.066938
|
||||
resole({
|
||||
longitude: 120.382665,
|
||||
latitude: 36.066938
|
||||
})
|
||||
longitudeVal.value = defalutLongLat.longitude
|
||||
latitudeVal.value = defalutLongLat.latitude
|
||||
resole(defalutLongLat)
|
||||
msg('测试环境,使用模拟定位')
|
||||
console.log('失败', data)
|
||||
console.log('失败1', e)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -84,7 +82,7 @@ const useLocationStore = defineStore("location", () => {
|
||||
latitudeVal
|
||||
|
||||
}
|
||||
},{
|
||||
}, {
|
||||
unistorage: true,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user