更新
This commit is contained in:
@@ -25,13 +25,18 @@ const instance = defineStore('user', {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
getPosition() {
|
getPosition() {
|
||||||
if (this.position.latitude && this.position.longitude) return
|
if (this.position.latitude && this.position.longitude) {
|
||||||
|
console.log('存在定位信息')
|
||||||
|
return
|
||||||
|
}
|
||||||
initAMap().then(() => {
|
initAMap().then(() => {
|
||||||
let AMap = Vue.prototype.$AMap
|
let AMap = Vue.prototype.$AMap
|
||||||
let geolocation = new AMap.Geolocation({
|
let geolocation = new AMap.Geolocation({
|
||||||
// enableHighAccuracy: true // 是否使用高精度定位,默认:true
|
// enableHighAccuracy: true // 是否使用高精度定位,默认:true
|
||||||
})
|
})
|
||||||
geolocation.getCurrentPosition(function (status, result) {
|
geolocation.getCurrentPosition(function (status, result) {
|
||||||
|
console.log('piniaIndex status', status)
|
||||||
|
console.log('piniaIndex result', result)
|
||||||
if (status === 'complete') {
|
if (status === 'complete') {
|
||||||
let { lat: latitude, lng: longitude } = result.position
|
let { lat: latitude, lng: longitude } = result.position
|
||||||
this.position = { latitude, longitude }
|
this.position = { latitude, longitude }
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ export default {
|
|||||||
// enableHighAccuracy: true // 是否使用高精度定位,默认:true
|
// enableHighAccuracy: true // 是否使用高精度定位,默认:true
|
||||||
})
|
})
|
||||||
geolocation.getCurrentPosition((status, result) => {
|
geolocation.getCurrentPosition((status, result) => {
|
||||||
|
console.log('status', status)
|
||||||
|
console.log('result', result)
|
||||||
if (status === 'complete') {
|
if (status === 'complete') {
|
||||||
let { lat: latitude, lng: longitude } = result.position
|
let { lat: latitude, lng: longitude } = result.position
|
||||||
this.position = { latitude, longitude }
|
this.position = { latitude, longitude }
|
||||||
|
|||||||
Reference in New Issue
Block a user