增加vuex 禁飞区数据 缓存
This commit is contained in:
parent
9d240362ab
commit
c6764c9e2e
@ -17,6 +17,7 @@ const store = new Vuex.Store({
|
||||
airList: [], // 所有飞机列表
|
||||
siteList: [], // 站点列表
|
||||
routeList: [], // 航线列表
|
||||
noflyData: [], // 禁飞区数据
|
||||
categoryList: [], // 分类列表(小程序)
|
||||
spuList: [], // 商品spu列表
|
||||
skuList: [], // 商品sku列表
|
||||
@ -64,6 +65,12 @@ const store = new Vuex.Store({
|
||||
setRouteList (state, list) {
|
||||
state.routeList = list
|
||||
},
|
||||
/**
|
||||
* @description: 设置禁飞区列表
|
||||
*/
|
||||
setNoflyData (state, data) {
|
||||
state.noflyData = data
|
||||
},
|
||||
/**
|
||||
* @description: 设置分类列表
|
||||
*/
|
||||
@ -582,6 +589,19 @@ const store = new Vuex.Store({
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 获取禁飞区数据
|
||||
*/
|
||||
async fetchNoflyData ({ commit }) {
|
||||
const res = await api.get('getNoflyData')
|
||||
if (res.data.status === 1) {
|
||||
commit('setNoflyData', res.data.noflyData)
|
||||
} else {
|
||||
commit('setNoflyData', {})
|
||||
Message.warning(res.data.msg)
|
||||
}
|
||||
return res.data.routeData
|
||||
},
|
||||
/**
|
||||
* @description: 获取分类列表
|
||||
* @return {*} 列表
|
||||
|
@ -17,9 +17,6 @@ export default {
|
||||
MapBox
|
||||
},
|
||||
computed: {
|
||||
airList () {
|
||||
return this.$store.state.airList
|
||||
},
|
||||
/**
|
||||
* @description: 侧边栏显隐
|
||||
*/
|
||||
@ -28,39 +25,11 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* @description: 创建飞机图标
|
||||
*/
|
||||
makePlanes (planes) {
|
||||
this.$refs.mapbox.removePlanes()// 先清除画布上现有的飞机
|
||||
planes.forEach((plane, index) => { // 创建所有飞机
|
||||
let planeDefaultLonLat
|
||||
if (localStorage.getItem(plane.name) !== null) { // 从本地缓存 拿飞机得初始位置
|
||||
planeDefaultLonLat = JSON.parse(localStorage.getItem(plane.name))
|
||||
plane.lon = planeDefaultLonLat.lon
|
||||
plane.lat = planeDefaultLonLat.lat
|
||||
} else {
|
||||
plane.lon = 0
|
||||
plane.lat = 0
|
||||
}
|
||||
this.$refs.mapbox.makePlane(plane, index)
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
mounted () {
|
||||
if (this.airList.length > 0) {
|
||||
this.makePlanes(this.airList)// 创建飞机图标
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
/**
|
||||
* @description: 飞机列表更新时候 更新地图
|
||||
*/
|
||||
airList: {
|
||||
handler (val) {
|
||||
this.makePlanes(val)
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 侧边栏缩进有变化时 地图重新自适应
|
||||
*/
|
||||
|
@ -64,6 +64,7 @@ export default {
|
||||
this.$store.dispatch('fetchAdminList')// 获取管理员列表
|
||||
this.$store.dispatch('fetchSiteList')// 获取站点列表
|
||||
this.$store.dispatch('fetchRouteList')// 获取航线列表
|
||||
this.$store.dispatch('fetchNoflyData')// 获取禁飞区数据
|
||||
this.$store.dispatch('fetchCategoryList')// 获取分类列表(小程序)
|
||||
this.$store.dispatch('fetchSpuList')// 获取商品spu列表
|
||||
this.$store.dispatch('fetchSkuList')// 获取商品sku列表
|
||||
|
Loading…
Reference in New Issue
Block a user