diff --git a/src/App.vue b/src/App.vue index 02f0ad5..223a7d4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -121,23 +121,20 @@ export default { console.log(data.deviceParam.monitorId) - if (data.monitorId && data.monitorId.toString().length === 9 && (data.monitorId.toString()[0] === '9' )) { - let str1 = data.monitorId.toString() - let str2 = str1.slice(1) - let startStr = str2.slice(0, 4); - let endStr = str2.slice(4); - let key = 'E' + startStr + '_' + endStr; - this.isOnline[key] = new Date().getTime() - this.selectOffLineDevice() - } - if (data.monitorId && data.monitorId.toString().length === 9 && ( data.monitorId.toString()[0] === 'E')) { - let str1 = data.monitorId.toString() - let str2 = str1.slice(1) - let startStr = str2.slice(0, 4); - let endStr = str2.slice(5); - let key = 'E' + startStr + '_' + endStr; - this.isOnline[key] = new Date().getTime() - this.selectOffLineDevice() + if (typeof data.monitorId === 'number' && !Number.isNaN(data.monitorId)) { + if (data.monitorId && data.monitorId.toString().length === 9 && (data.monitorId.toString()[0] === '9')) { + let str1 = data.monitorId.toString() + let str2 = str1.slice(1) + let startStr = str2.slice(0, 4); + let endStr = str2.slice(4); + let key = 'E' + startStr + '_' + endStr; + this.isOnline[key] = new Date().getTime() + this.selectOffLineDevice() + } + } else { + let str1 = data.monitorId.slice(-10) + this.isOnline[str1] = new Date().getTime() + this.selectOffLineDevice() } if (data.isFlag === 1 && data.alarmRules && data.alarmContents) { @@ -398,7 +395,6 @@ export default { Object.keys(this.isOnline).forEach(key => { // console.log(key, new Date().getTime() - this.isOnline[key]) if (new Date().getTime() - this.isOnline[key] > (1000 * 60 * 60)) { - console.log('error', key, parseTime(new Date().getTime())) this.saveLo(key) this.$confirm(`设备${key}已离线`, '设备离线', { cancelButtonText: '关闭',