# up map 判断跳转来源

This commit is contained in:
xianfuxing 2018-08-27 22:25:17 +08:00
parent 08d1712ad0
commit db00d3e054
4 changed files with 45 additions and 15 deletions

View File

@ -14,6 +14,7 @@ const getters = {
permission_routers: state => state.permission.routers, permission_routers: state => state.permission.routers,
addRouters: state => state.permission.addRouters, addRouters: state => state.permission.addRouters,
errorLogs: state => state.errorLog.logs, errorLogs: state => state.errorLog.logs,
deviceID: state => state.counter.deviceID deviceID: state => state.counter.deviceID,
mapClick: state => state.counter.mapClick
} }
export default getters export default getters

View File

@ -1,16 +1,23 @@
const counter = { const counter = {
state: { state: {
deviceID: '868575028779793' deviceID: '868575028779793',
mapClick: false
}, },
mutations: { mutations: {
CHANGE_DEVICE_ID: (state, deviceID) => { CHANGE_DEVICE_ID: (state, deviceID) => {
state.deviceID = deviceID state.deviceID = deviceID
localStorage.deviceID = deviceID localStorage.deviceID = deviceID
},
CHANGE_MAP_CLICK: (state, mapClick) => {
state.mapClick = mapClick
} }
}, },
actions: { actions: {
chnageDeviceID({ commit }, deviceID) { changeDeviceID({ commit }, deviceID) {
commit('CHANGE_DEVICE_ID', deviceID) commit('CHANGE_DEVICE_ID', deviceID)
},
changeMapClick({ commit }, mapClick) {
commit('CHANGE_MAP_CLICK', mapClick)
} }
} }
} }

View File

@ -142,7 +142,7 @@ export default {
}, },
handleDetailClick(deviceID) { handleDetailClick(deviceID) {
// console.log(deviceID) // console.log(deviceID)
this.$store.dispatch('chnageDeviceID', deviceID).then(() => { this.$store.dispatch('changeDeviceID', deviceID).then(() => {
this.$router.push('/counter/detail') this.$router.push('/counter/detail')
}).catch(() => { }).catch(() => {
console.log('Err: get device_id failed in device page') console.log('Err: get device_id failed in device page')
@ -150,7 +150,12 @@ export default {
}, },
handleMapClick(deviceID) { handleMapClick(deviceID) {
// console.log(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') this.$router.push('/counter/map')
}).catch(() => { }).catch(() => {
console.log('Err: get device_id failed in device page') console.log('Err: get device_id failed in device page')

View File

@ -54,6 +54,12 @@ export default {
}] }]
} }
}, },
// beforeRouteEnter(to, from, next) {
// next(vm => {
// vm.url = from.path
// console.log(from.path)
// })
// },
methods: { methods: {
getDevices(params) { getDevices(params) {
fetchDeviceList(params).then(response => { fetchDeviceList(params).then(response => {
@ -68,17 +74,28 @@ export default {
}) })
} }
}, },
watch: {
'$route'(to, from) {
console.log(from)
}
},
created() { created() {
const device_id = this.$store.getters.deviceID const mapClick = this.$store.getters.mapClick
this.getDevices({ device_id }) if (mapClick) {
this.defaultPositions.forEach((item, index) => { const device_id = this.$store.getters.deviceID
const entry = {} console.log(device_id)
entry.position = item.position this.getDevices({ device_id })
entry.events = defaultEvents } else {
entry.visible = true this.defaultPositions.forEach((item, index) => {
entry.draggable = false const entry = {}
this.markers.push(entry) entry.position = item.position
}) entry.events = defaultEvents
entry.visible = true
entry.draggable = false
this.markers.push(entry)
})
this.flag = true
}
} }
} }
</script> </script>