diff --git a/public/config/project.config.json b/public/config/project.config.json index 267ead3..c91bd64 100644 --- a/public/config/project.config.json +++ b/public/config/project.config.json @@ -3,7 +3,7 @@ "subtitle": "", "theme":"blue", "baseUrl": "http://111.198.10.15:11314/", - "wsUrl": "ws://111.198.10.15:11415/websocket/", + "wsUrl": "ws://111.198.10.15:11314/websocket/", "page": "http://10.80.106.217:9527/", "mainPage": "http://111.198.10.15:11404/dcms/#", "amapSecurityCode": "182a2c5889f7fe6d90546d9b8f4781ad", diff --git a/public/config/project.config.json b/public/config/project.config.json index 267ead3..c91bd64 100644 --- a/public/config/project.config.json +++ b/public/config/project.config.json @@ -3,7 +3,7 @@ "subtitle": "", "theme":"blue", "baseUrl": "http://111.198.10.15:11314/", - "wsUrl": "ws://111.198.10.15:11415/websocket/", + "wsUrl": "ws://111.198.10.15:11314/websocket/", "page": "http://10.80.106.217:9527/", "mainPage": "http://111.198.10.15:11404/dcms/#", "amapSecurityCode": "182a2c5889f7fe6d90546d9b8f4781ad", diff --git a/src/components/alarmDialog.vue b/src/components/alarmDialog.vue index e059579..ea30b1a 100644 --- a/src/components/alarmDialog.vue +++ b/src/components/alarmDialog.vue @@ -43,6 +43,7 @@ alarmTime: '--', cancelTime: '--' }, + isHidden: false, // 页面是否被切走 } }, methods: { @@ -52,8 +53,12 @@ this.alarm = alarm alarm.alarmTime = getSearchLastDayTime()[1] || '' // 播放音效 - this.playAudio() - + if (!this.isHidden) { + this.playAudio() + } + else { + this.pauseAudio() + } setTimeout(() => { this.cancel() }, 1000 * 5) @@ -70,7 +75,20 @@ console.log('关闭报警弹窗') this.pauseAudio() this.dialogFormVisible = false + }, + handleTabVisibility() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,alarmDialog') + this.isHidden = false + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,alarmDialog') + this.isHidden = true + } } + }, + mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibility) } } diff --git a/public/config/project.config.json b/public/config/project.config.json index 267ead3..c91bd64 100644 --- a/public/config/project.config.json +++ b/public/config/project.config.json @@ -3,7 +3,7 @@ "subtitle": "", "theme":"blue", "baseUrl": "http://111.198.10.15:11314/", - "wsUrl": "ws://111.198.10.15:11415/websocket/", + "wsUrl": "ws://111.198.10.15:11314/websocket/", "page": "http://10.80.106.217:9527/", "mainPage": "http://111.198.10.15:11404/dcms/#", "amapSecurityCode": "182a2c5889f7fe6d90546d9b8f4781ad", diff --git a/src/components/alarmDialog.vue b/src/components/alarmDialog.vue index e059579..ea30b1a 100644 --- a/src/components/alarmDialog.vue +++ b/src/components/alarmDialog.vue @@ -43,6 +43,7 @@ alarmTime: '--', cancelTime: '--' }, + isHidden: false, // 页面是否被切走 } }, methods: { @@ -52,8 +53,12 @@ this.alarm = alarm alarm.alarmTime = getSearchLastDayTime()[1] || '' // 播放音效 - this.playAudio() - + if (!this.isHidden) { + this.playAudio() + } + else { + this.pauseAudio() + } setTimeout(() => { this.cancel() }, 1000 * 5) @@ -70,7 +75,20 @@ console.log('关闭报警弹窗') this.pauseAudio() this.dialogFormVisible = false + }, + handleTabVisibility() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,alarmDialog') + this.isHidden = false + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,alarmDialog') + this.isHidden = true + } } + }, + mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibility) } } diff --git a/src/layout/components/AppHeader.vue b/src/layout/components/AppHeader.vue index 4dee5e7..4d79cde 100644 --- a/src/layout/components/AppHeader.vue +++ b/src/layout/components/AppHeader.vue @@ -11,9 +11,9 @@
暂无报警信息
@@ -83,6 +83,7 @@ } }, mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibilityChange) this.initWebSocket() // this.$refs.alarmRef.initDialog({ // message: '浓度超限', @@ -92,7 +93,7 @@ // }) setInterval(() => { this.fetchAlarmList() - }, 1000*30) + }, 1000 * 30) }, methods: { initWebSocket() { @@ -108,7 +109,10 @@ }, logout() { this.$store.dispatch('LogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + this.$router.push({ + path: '/login' + }) + // location.reload() // 为了重新实例化vue-router对象 避免bug }) }, resetPwd() { @@ -148,8 +152,8 @@ }) }, fetchAlarmList() { - getAlarmList({offset:1, limit:99, status: '1'}).then((res) => { - console.log(res.data) + getAlarmList({ offset: 1, limit: 99, status: '1' }).then((res) => { + // console.log(res.data) this.alarmList = res.data.rows }) }, @@ -157,6 +161,14 @@ this.$router.push({ path: '/alarmNow' }) + }, + handleTabVisibilityChange() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,appheader') + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,appheader') + } } }, watch: { @@ -200,9 +212,11 @@ } } } + .alarm-icon { color: #F56C6C; } + .dropdown-container { /*height: 50px;*/ display: inline-block; diff --git a/public/config/project.config.json b/public/config/project.config.json index 267ead3..c91bd64 100644 --- a/public/config/project.config.json +++ b/public/config/project.config.json @@ -3,7 +3,7 @@ "subtitle": "", "theme":"blue", "baseUrl": "http://111.198.10.15:11314/", - "wsUrl": "ws://111.198.10.15:11415/websocket/", + "wsUrl": "ws://111.198.10.15:11314/websocket/", "page": "http://10.80.106.217:9527/", "mainPage": "http://111.198.10.15:11404/dcms/#", "amapSecurityCode": "182a2c5889f7fe6d90546d9b8f4781ad", diff --git a/src/components/alarmDialog.vue b/src/components/alarmDialog.vue index e059579..ea30b1a 100644 --- a/src/components/alarmDialog.vue +++ b/src/components/alarmDialog.vue @@ -43,6 +43,7 @@ alarmTime: '--', cancelTime: '--' }, + isHidden: false, // 页面是否被切走 } }, methods: { @@ -52,8 +53,12 @@ this.alarm = alarm alarm.alarmTime = getSearchLastDayTime()[1] || '' // 播放音效 - this.playAudio() - + if (!this.isHidden) { + this.playAudio() + } + else { + this.pauseAudio() + } setTimeout(() => { this.cancel() }, 1000 * 5) @@ -70,7 +75,20 @@ console.log('关闭报警弹窗') this.pauseAudio() this.dialogFormVisible = false + }, + handleTabVisibility() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,alarmDialog') + this.isHidden = false + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,alarmDialog') + this.isHidden = true + } } + }, + mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibility) } } diff --git a/src/layout/components/AppHeader.vue b/src/layout/components/AppHeader.vue index 4dee5e7..4d79cde 100644 --- a/src/layout/components/AppHeader.vue +++ b/src/layout/components/AppHeader.vue @@ -11,9 +11,9 @@
暂无报警信息
@@ -83,6 +83,7 @@ } }, mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibilityChange) this.initWebSocket() // this.$refs.alarmRef.initDialog({ // message: '浓度超限', @@ -92,7 +93,7 @@ // }) setInterval(() => { this.fetchAlarmList() - }, 1000*30) + }, 1000 * 30) }, methods: { initWebSocket() { @@ -108,7 +109,10 @@ }, logout() { this.$store.dispatch('LogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + this.$router.push({ + path: '/login' + }) + // location.reload() // 为了重新实例化vue-router对象 避免bug }) }, resetPwd() { @@ -148,8 +152,8 @@ }) }, fetchAlarmList() { - getAlarmList({offset:1, limit:99, status: '1'}).then((res) => { - console.log(res.data) + getAlarmList({ offset: 1, limit: 99, status: '1' }).then((res) => { + // console.log(res.data) this.alarmList = res.data.rows }) }, @@ -157,6 +161,14 @@ this.$router.push({ path: '/alarmNow' }) + }, + handleTabVisibilityChange() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,appheader') + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,appheader') + } } }, watch: { @@ -200,9 +212,11 @@ } } } + .alarm-icon { color: #F56C6C; } + .dropdown-container { /*height: 50px;*/ display: inline-block; diff --git a/src/utils/request.js b/src/utils/request.js index 7873e18..508ac28 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,7 +2,7 @@ import { Message, MessageBox } from 'element-ui' import store from '../store' import { getToken } from '@/utils/auth' - +// import router from '' // 创建axios实例 const service = axios.create({ baseURL: process.env.BASE_API, // api 的 base_url @@ -50,7 +50,10 @@ } ).then(() => { store.dispatch('FedLogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + location.reload(true) // 为了重新实例化vue-router对象 避免bug + // this.$router.push({ + // path: '/login' + // }) }) }) } diff --git a/public/config/project.config.json b/public/config/project.config.json index 267ead3..c91bd64 100644 --- a/public/config/project.config.json +++ b/public/config/project.config.json @@ -3,7 +3,7 @@ "subtitle": "", "theme":"blue", "baseUrl": "http://111.198.10.15:11314/", - "wsUrl": "ws://111.198.10.15:11415/websocket/", + "wsUrl": "ws://111.198.10.15:11314/websocket/", "page": "http://10.80.106.217:9527/", "mainPage": "http://111.198.10.15:11404/dcms/#", "amapSecurityCode": "182a2c5889f7fe6d90546d9b8f4781ad", diff --git a/src/components/alarmDialog.vue b/src/components/alarmDialog.vue index e059579..ea30b1a 100644 --- a/src/components/alarmDialog.vue +++ b/src/components/alarmDialog.vue @@ -43,6 +43,7 @@ alarmTime: '--', cancelTime: '--' }, + isHidden: false, // 页面是否被切走 } }, methods: { @@ -52,8 +53,12 @@ this.alarm = alarm alarm.alarmTime = getSearchLastDayTime()[1] || '' // 播放音效 - this.playAudio() - + if (!this.isHidden) { + this.playAudio() + } + else { + this.pauseAudio() + } setTimeout(() => { this.cancel() }, 1000 * 5) @@ -70,7 +75,20 @@ console.log('关闭报警弹窗') this.pauseAudio() this.dialogFormVisible = false + }, + handleTabVisibility() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,alarmDialog') + this.isHidden = false + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,alarmDialog') + this.isHidden = true + } } + }, + mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibility) } } diff --git a/src/layout/components/AppHeader.vue b/src/layout/components/AppHeader.vue index 4dee5e7..4d79cde 100644 --- a/src/layout/components/AppHeader.vue +++ b/src/layout/components/AppHeader.vue @@ -11,9 +11,9 @@
暂无报警信息
@@ -83,6 +83,7 @@ } }, mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibilityChange) this.initWebSocket() // this.$refs.alarmRef.initDialog({ // message: '浓度超限', @@ -92,7 +93,7 @@ // }) setInterval(() => { this.fetchAlarmList() - }, 1000*30) + }, 1000 * 30) }, methods: { initWebSocket() { @@ -108,7 +109,10 @@ }, logout() { this.$store.dispatch('LogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + this.$router.push({ + path: '/login' + }) + // location.reload() // 为了重新实例化vue-router对象 避免bug }) }, resetPwd() { @@ -148,8 +152,8 @@ }) }, fetchAlarmList() { - getAlarmList({offset:1, limit:99, status: '1'}).then((res) => { - console.log(res.data) + getAlarmList({ offset: 1, limit: 99, status: '1' }).then((res) => { + // console.log(res.data) this.alarmList = res.data.rows }) }, @@ -157,6 +161,14 @@ this.$router.push({ path: '/alarmNow' }) + }, + handleTabVisibilityChange() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,appheader') + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,appheader') + } } }, watch: { @@ -200,9 +212,11 @@ } } } + .alarm-icon { color: #F56C6C; } + .dropdown-container { /*height: 50px;*/ display: inline-block; diff --git a/src/utils/request.js b/src/utils/request.js index 7873e18..508ac28 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,7 +2,7 @@ import { Message, MessageBox } from 'element-ui' import store from '../store' import { getToken } from '@/utils/auth' - +// import router from '' // 创建axios实例 const service = axios.create({ baseURL: process.env.BASE_API, // api 的 base_url @@ -50,7 +50,10 @@ } ).then(() => { store.dispatch('FedLogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + location.reload(true) // 为了重新实例化vue-router对象 避免bug + // this.$router.push({ + // path: '/login' + // }) }) }) } diff --git a/src/utils/validate.js b/src/utils/validate.js index 223c280..d6d56eb 100644 --- a/src/utils/validate.js +++ b/src/utils/validate.js @@ -57,6 +57,15 @@ const re = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/ return re.test(phone) } +/** +* @description 验证手机号码 +* @param phone 被验证手机号 +* @return Boolean +*/ +export function validateisPhone(phone) { + const reg = /^[1][3-9]\d{9}$/ + return reg.test(phone); +} /** * 验证一定范围内的非负整数 diff --git a/public/config/project.config.json b/public/config/project.config.json index 267ead3..c91bd64 100644 --- a/public/config/project.config.json +++ b/public/config/project.config.json @@ -3,7 +3,7 @@ "subtitle": "", "theme":"blue", "baseUrl": "http://111.198.10.15:11314/", - "wsUrl": "ws://111.198.10.15:11415/websocket/", + "wsUrl": "ws://111.198.10.15:11314/websocket/", "page": "http://10.80.106.217:9527/", "mainPage": "http://111.198.10.15:11404/dcms/#", "amapSecurityCode": "182a2c5889f7fe6d90546d9b8f4781ad", diff --git a/src/components/alarmDialog.vue b/src/components/alarmDialog.vue index e059579..ea30b1a 100644 --- a/src/components/alarmDialog.vue +++ b/src/components/alarmDialog.vue @@ -43,6 +43,7 @@ alarmTime: '--', cancelTime: '--' }, + isHidden: false, // 页面是否被切走 } }, methods: { @@ -52,8 +53,12 @@ this.alarm = alarm alarm.alarmTime = getSearchLastDayTime()[1] || '' // 播放音效 - this.playAudio() - + if (!this.isHidden) { + this.playAudio() + } + else { + this.pauseAudio() + } setTimeout(() => { this.cancel() }, 1000 * 5) @@ -70,7 +75,20 @@ console.log('关闭报警弹窗') this.pauseAudio() this.dialogFormVisible = false + }, + handleTabVisibility() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,alarmDialog') + this.isHidden = false + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,alarmDialog') + this.isHidden = true + } } + }, + mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibility) } } diff --git a/src/layout/components/AppHeader.vue b/src/layout/components/AppHeader.vue index 4dee5e7..4d79cde 100644 --- a/src/layout/components/AppHeader.vue +++ b/src/layout/components/AppHeader.vue @@ -11,9 +11,9 @@
暂无报警信息
@@ -83,6 +83,7 @@ } }, mounted() { + document.addEventListener('visibilitychange', this.handleTabVisibilityChange) this.initWebSocket() // this.$refs.alarmRef.initDialog({ // message: '浓度超限', @@ -92,7 +93,7 @@ // }) setInterval(() => { this.fetchAlarmList() - }, 1000*30) + }, 1000 * 30) }, methods: { initWebSocket() { @@ -108,7 +109,10 @@ }, logout() { this.$store.dispatch('LogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + this.$router.push({ + path: '/login' + }) + // location.reload() // 为了重新实例化vue-router对象 避免bug }) }, resetPwd() { @@ -148,8 +152,8 @@ }) }, fetchAlarmList() { - getAlarmList({offset:1, limit:99, status: '1'}).then((res) => { - console.log(res.data) + getAlarmList({ offset: 1, limit: 99, status: '1' }).then((res) => { + // console.log(res.data) this.alarmList = res.data.rows }) }, @@ -157,6 +161,14 @@ this.$router.push({ path: '/alarmNow' }) + }, + handleTabVisibilityChange() { + if (document.visibilityState === 'visible') { + console.log('页面被切回来,appheader') + // 执行当Tab回到前台时的逻辑 + } else if (document.visibilityState === 'hidden') { + console.log('页面被切走,appheader') + } } }, watch: { @@ -200,9 +212,11 @@ } } } + .alarm-icon { color: #F56C6C; } + .dropdown-container { /*height: 50px;*/ display: inline-block; diff --git a/src/utils/request.js b/src/utils/request.js index 7873e18..508ac28 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -2,7 +2,7 @@ import { Message, MessageBox } from 'element-ui' import store from '../store' import { getToken } from '@/utils/auth' - +// import router from '' // 创建axios实例 const service = axios.create({ baseURL: process.env.BASE_API, // api 的 base_url @@ -50,7 +50,10 @@ } ).then(() => { store.dispatch('FedLogOut').then(() => { - location.reload() // 为了重新实例化vue-router对象 避免bug + location.reload(true) // 为了重新实例化vue-router对象 避免bug + // this.$router.push({ + // path: '/login' + // }) }) }) } diff --git a/src/utils/validate.js b/src/utils/validate.js index 223c280..d6d56eb 100644 --- a/src/utils/validate.js +++ b/src/utils/validate.js @@ -57,6 +57,15 @@ const re = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/ return re.test(phone) } +/** +* @description 验证手机号码 +* @param phone 被验证手机号 +* @return Boolean +*/ +export function validateisPhone(phone) { + const reg = /^[1][3-9]\d{9}$/ + return reg.test(phone); +} /** * 验证一定范围内的非负整数 diff --git a/src/views/alarmManage/components/HandlePrompt.vue b/src/views/alarmManage/components/HandlePrompt.vue index b2c482e..8624e56 100644 --- a/src/views/alarmManage/components/HandlePrompt.vue +++ b/src/views/alarmManage/components/HandlePrompt.vue @@ -1,28 +1,13 @@