# up map 判断跳转来源
This commit is contained in:
parent
08d1712ad0
commit
db00d3e054
|
@ -14,6 +14,7 @@ const getters = {
|
|||
permission_routers: state => state.permission.routers,
|
||||
addRouters: state => state.permission.addRouters,
|
||||
errorLogs: state => state.errorLog.logs,
|
||||
deviceID: state => state.counter.deviceID
|
||||
deviceID: state => state.counter.deviceID,
|
||||
mapClick: state => state.counter.mapClick
|
||||
}
|
||||
export default getters
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
const counter = {
|
||||
state: {
|
||||
deviceID: '868575028779793'
|
||||
deviceID: '868575028779793',
|
||||
mapClick: false
|
||||
},
|
||||
mutations: {
|
||||
CHANGE_DEVICE_ID: (state, deviceID) => {
|
||||
state.deviceID = deviceID
|
||||
localStorage.deviceID = deviceID
|
||||
},
|
||||
CHANGE_MAP_CLICK: (state, mapClick) => {
|
||||
state.mapClick = mapClick
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
chnageDeviceID({ commit }, deviceID) {
|
||||
changeDeviceID({ commit }, deviceID) {
|
||||
commit('CHANGE_DEVICE_ID', deviceID)
|
||||
},
|
||||
changeMapClick({ commit }, mapClick) {
|
||||
commit('CHANGE_MAP_CLICK', mapClick)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ export default {
|
|||
},
|
||||
handleDetailClick(deviceID) {
|
||||
// console.log(deviceID)
|
||||
this.$store.dispatch('chnageDeviceID', deviceID).then(() => {
|
||||
this.$store.dispatch('changeDeviceID', deviceID).then(() => {
|
||||
this.$router.push('/counter/detail')
|
||||
}).catch(() => {
|
||||
console.log('Err: get device_id failed in device page')
|
||||
|
@ -150,7 +150,12 @@ export default {
|
|||
},
|
||||
handleMapClick(deviceID) {
|
||||
// console.log(deviceID)
|
||||
this.$store.dispatch('chnageDeviceID', deviceID).then(() => {
|
||||
this.$store.dispatch('changeMapClick', true).then(() => {
|
||||
console.log('go to map')
|
||||
}).catch(() => {
|
||||
console.log('Err: click map failed')
|
||||
})
|
||||
this.$store.dispatch('changeDeviceID', deviceID).then(() => {
|
||||
this.$router.push('/counter/map')
|
||||
}).catch(() => {
|
||||
console.log('Err: get device_id failed in device page')
|
||||
|
|
|
@ -54,6 +54,12 @@ export default {
|
|||
}]
|
||||
}
|
||||
},
|
||||
// beforeRouteEnter(to, from, next) {
|
||||
// next(vm => {
|
||||
// vm.url = from.path
|
||||
// console.log(from.path)
|
||||
// })
|
||||
// },
|
||||
methods: {
|
||||
getDevices(params) {
|
||||
fetchDeviceList(params).then(response => {
|
||||
|
@ -68,17 +74,28 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
console.log(from)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const device_id = this.$store.getters.deviceID
|
||||
this.getDevices({ device_id })
|
||||
this.defaultPositions.forEach((item, index) => {
|
||||
const entry = {}
|
||||
entry.position = item.position
|
||||
entry.events = defaultEvents
|
||||
entry.visible = true
|
||||
entry.draggable = false
|
||||
this.markers.push(entry)
|
||||
})
|
||||
const mapClick = this.$store.getters.mapClick
|
||||
if (mapClick) {
|
||||
const device_id = this.$store.getters.deviceID
|
||||
console.log(device_id)
|
||||
this.getDevices({ device_id })
|
||||
} else {
|
||||
this.defaultPositions.forEach((item, index) => {
|
||||
const entry = {}
|
||||
entry.position = item.position
|
||||
entry.events = defaultEvents
|
||||
entry.visible = true
|
||||
entry.draggable = false
|
||||
this.markers.push(entry)
|
||||
})
|
||||
this.flag = true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue