# reset devcieID if logout

This commit is contained in:
xianfuxing 2018-10-10 18:30:47 +08:00
parent 23ea18dcca
commit 84070498c6
3 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
const counter = { const counter = {
state: { state: {
deviceID: '868575028779793', deviceID: '',
mapClick: false mapClick: false
}, },
mutations: { mutations: {

View File

@ -100,11 +100,12 @@ const user = {
// }, // },
// 登出 // 登出
LogOut({ commit, state }) { LogOut({ commit, state, rootState }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logout(state.token).then(() => { logout(state.token).then(() => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', []) commit('SET_ROLES', [])
commit('CHANGE_DEVICE_ID', '', { root: true })
removeToken() removeToken()
resolve() resolve()
}).catch(error => { }).catch(error => {

View File

@ -114,10 +114,17 @@ export default {
}) })
}, },
getDevices(params) { getDevices(params) {
let device_id = params.device_id
fetchDeviceList(params).then(response => { fetchDeviceList(params).then(response => {
this.deviceList = response.data.results this.deviceList = response.data.results
this.lastItem = this.deviceList[0] this.lastItem = this.deviceList[0]
console.log(typeof (this.lastItem.count)) if (!device_id) {
device_id = this.lastItem.device_id
this.$store.dispatch('changeDeviceID', device_id)
console.log(device_id)
}
// console.log(this.lastItem)
this.getDeviceLogsHistory({ device_id })
if (typeof (this.lastItem.count) === 'number') { if (typeof (this.lastItem.count) === 'number') {
this.lastItem.count = this.lastItem.count.toString() this.lastItem.count = this.lastItem.count.toString()
} }
@ -143,7 +150,6 @@ export default {
}, },
created() { created() {
const device_id = this.$store.getters.deviceID const device_id = this.$store.getters.deviceID
this.getDeviceLogsHistory({ device_id })
this.getDevices({ device_id }) this.getDevices({ device_id })
} }
} }