pull/2/head
xiaozhiyong 2 years ago
parent c6c1af91a9
commit 1eab02047e
  1. 2
      .env.development
  2. 35
      src/store/piniaIndex.js
  3. 65
      src/views/HomeView.vue
  4. 4
      vue.config.js

@ -12,7 +12,7 @@ VUE_APP_UPLOAD_PRIVATE_URL = '/api/oil-dict/imageHandler/uploadProtectedImg'
VUE_APP_DOMAIN = '192.168.0.150:38080' VUE_APP_DOMAIN = '192.168.0.150:38080'
# 开发环境,不会进行加密,会打印出数据 # 开发环境,不会进行加密,会打印出数据
VUE_APP_ENV = 'production' VUE_APP_ENV = 'development'
#production #production

@ -27,37 +27,20 @@ const instance = defineStore('user', {
actions: { actions: {
getPosition() { getPosition() {
this.position = { latitude: 36.636753, longitude: 119.11914 }
if (navigator?.geolocation?.getCurrentPosition) {
console.log('存在原生定位')
navigator.geolocation.getCurrentPosition(position => {
console.log('原生定位', position)
})
} else {
console.log('原生定位不可用')
}
// return
initAMap().then(() => { initAMap().then(() => {
// console.log(3)
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('geolocation.getCurrentPosition') if (status === 'complete') {
console.log('status', status) let { lat: latitude, lng: longitude } = result.position
console.log('result', result) this.position = { latitude, longitude }
// if (status === 'complete') { } else {
// let { lat: latitude, lng: longitude } = result.position }
// this.position = { latitude, longitude }
// console.log('this.position', this.position)
// }
}) })
}) })
return return
if (navigator?.geolocation?.getCurrentPosition) { if (navigator?.geolocation?.getCurrentPosition) {
navigator.geolocation.getCurrentPosition( navigator.geolocation.getCurrentPosition(
position => { position => {
@ -65,14 +48,6 @@ const instance = defineStore('user', {
let { latitude, longitude } = position.coords let { latitude, longitude } = position.coords
this.position = { latitude, longitude } this.position = { latitude, longitude }
}, },
// function (position) {
// console.log('position', position)
// // that.$patch(state => {
// // ;({ latitude: state.position.latitude, longitude: state.position.longitude } = position.coords)
// // localStorage.setItem('position', JSON.stringify(state.position))
// // console.log(state.position, position.coords, '检测到地理位置授权')
// // })
// },
error => { error => {
console.log('error', error) console.log('error', error)
switch (error.code) { switch (error.code) {

@ -22,6 +22,8 @@ import oilSiteApi from '@/api/oil-site.js'
import initAMap from '@/utils/amap.js' import initAMap from '@/utils/amap.js'
import { Notify } from 'vant'
export default { export default {
components: { components: {
homeNavBar, homeNavBar,
@ -125,9 +127,27 @@ export default {
return !position?.latitude && !position?.longitude ? true : false return !position?.latitude && !position?.longitude ? true : false
}, },
getlist() { getlist() {
let position = { latitude: 36.636753, longitude: 119.11914 } if (this.position) {
this.obtainData()
this.page.params = Object.assign(this.page.params, position) 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 this.loading = true
oilSiteApi oilSiteApi
.getSiteList(this.page) .getSiteList(this.page)
@ -148,45 +168,6 @@ export default {
.catch(error => { .catch(error => {
this.finished = true 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
})
}
})
})
} }
} }
} }

@ -17,8 +17,8 @@ module.exports = defineConfig({
proxy: { proxy: {
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// target: `http://192.168.1.83:38080`, // target: `http://192.168.1.83:38080`,
target: `https://www.xingoil.com/adminapi`, // target: `https://www.xingoil.com/adminapi`,
// target: `http://uat.xingoil.com/adminapi`, target: `http://uat.xingoil.com/adminapi`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save