更新
This commit is contained in:
@@ -22,6 +22,8 @@ import oilSiteApi from '@/api/oil-site.js'
|
||||
|
||||
import initAMap from '@/utils/amap.js'
|
||||
|
||||
import { Notify } from 'vant'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
homeNavBar,
|
||||
@@ -125,9 +127,27 @@ export default {
|
||||
return !position?.latitude && !position?.longitude ? true : false
|
||||
},
|
||||
getlist() {
|
||||
let position = { latitude: 36.636753, longitude: 119.11914 }
|
||||
|
||||
this.page.params = Object.assign(this.page.params, position)
|
||||
if (this.position) {
|
||||
this.obtainData()
|
||||
return
|
||||
}
|
||||
initAMap().then(() => {
|
||||
let AMap = this.$AMap
|
||||
let geolocation = new AMap.Geolocation({
|
||||
// enableHighAccuracy: true // 是否使用高精度定位,默认:true
|
||||
})
|
||||
geolocation.getCurrentPosition((status, result) => {
|
||||
if (status === 'complete') {
|
||||
let { lat: latitude, lng: longitude } = result.position
|
||||
this.position = { latitude, longitude }
|
||||
this.obtainData()
|
||||
} else {
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
obtainData() {
|
||||
this.page.params = Object.assign(this.page.params, this.position)
|
||||
this.loading = true
|
||||
oilSiteApi
|
||||
.getSiteList(this.page)
|
||||
@@ -148,45 +168,6 @@ export default {
|
||||
.catch(error => {
|
||||
this.finished = true
|
||||
})
|
||||
return
|
||||
initAMap().then(() => {
|
||||
let AMap = this.$AMap
|
||||
let geolocation = new AMap.Geolocation({
|
||||
// enableHighAccuracy: true // 是否使用高精度定位,默认:true
|
||||
})
|
||||
geolocation.getCurrentPosition((status, result) => {
|
||||
if (status === 'complete') {
|
||||
let { lat: latitude, lng: longitude } = result.position
|
||||
|
||||
// this.position = { latitude, longitude }
|
||||
// console.log('this.position', this.position)
|
||||
|
||||
let position = { latitude, longitude }
|
||||
|
||||
this.page.params = Object.assign(this.page.params, position)
|
||||
this.loading = true
|
||||
oilSiteApi
|
||||
.getSiteList(this.page)
|
||||
.then(res => {
|
||||
if (res.code == 20000) {
|
||||
if (res.data.list.length < 10) {
|
||||
this.finished = true
|
||||
}
|
||||
if (this.page.currentPage == 1) {
|
||||
this.list = res.data.list
|
||||
} else {
|
||||
this.list = this.list.concat(res.data.list)
|
||||
}
|
||||
this.loading = false
|
||||
this.refreshing = false
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.finished = true
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user