Commit dcba312d authored by 冯超鹏's avatar 冯超鹏

报警弹出

parent 0a9a7abc
Pipeline #69 canceled with stages
...@@ -80,8 +80,11 @@ class swooleMeTcp extends Command ...@@ -80,8 +80,11 @@ class swooleMeTcp extends Command
}); });
//监听数据接收事件 //监听数据接收事件
$this->tcp->on('Receive', function ($serv, $fd, $from_id, $data) { $this->tcp->on('Receive', function ($serv, $fd, $from_id, $data) {
//验证数据格式
if($this->formatData($data)){
$swooletcp = new SwooleCommandMeTcpController(); $swooletcp = new SwooleCommandMeTcpController();
$swooletcp->swooletcplist($data); $swooletcp->swooletcplist($data);
}
}); });
//监听连接关闭事件 //监听连接关闭事件
...@@ -92,5 +95,16 @@ class swooleMeTcp extends Command ...@@ -92,5 +95,16 @@ class swooleMeTcp extends Command
//启动服务器 //启动服务器
$this->tcp->start(); $this->tcp->start();
} }
public function formatData($str){
$str = preg_replace("/[^a-z,A-Z,0-9,\/,\.,-]/",'', $str);
$str = rtrim(trim($str),'/');
$str = str_replace('null', -1, $str);
preg_match("/^[a-z,A-Z,0-9,\-]{6,32}\/(\d{1,2})\/(\-?)([0-9,\.]{1,8})$/", $str, $out);
if(count($out) > 0){
return $str;
}else{
return false;
}
}
} }
\ No newline at end of file
...@@ -80,6 +80,8 @@ export default { ...@@ -80,6 +80,8 @@ export default {
}, },
async logout() { async logout() {
await this.$store.dispatch('user/logout'); await this.$store.dispatch('user/logout');
this.$notify.closeAll();
this.webscoket.onclose();
this.$router.push(`/login?redirect=${this.$route.fullPath}`); this.$router.push(`/login?redirect=${this.$route.fullPath}`);
}, },
}, },
......
...@@ -71,6 +71,9 @@ export default { ...@@ -71,6 +71,9 @@ export default {
} }
}, },
}, },
created() {
window.addEventListener('beforeunload', e => this.beforeun(e));
},
mounted() { mounted() {
this.initTags(); this.initTags();
this.addTags(); this.addTags();
...@@ -140,7 +143,6 @@ export default { ...@@ -140,7 +143,6 @@ export default {
websocketonmessage(e){ // 数据接收 websocketonmessage(e){ // 数据接收
const redata = JSON.parse(e.data); const redata = JSON.parse(e.data);
if (redata.code === 200) { if (redata.code === 200) {
localStorage.removeItem('isalam');
if (localStorage.getItem('isalam') === null || localStorage.getItem('isalam') === undefined) { // 第一次没有的话 if (localStorage.getItem('isalam') === null || localStorage.getItem('isalam') === undefined) { // 第一次没有的话
localStorage.setItem('isalam', JSON.stringify(redata.data)); localStorage.setItem('isalam', JSON.stringify(redata.data));
for (let i = 0; i < redata.data.length; i++) { for (let i = 0; i < redata.data.length; i++) {
...@@ -151,18 +153,16 @@ export default { ...@@ -151,18 +153,16 @@ export default {
duration: 0, duration: 0,
message: redata.data[i].devicenumber + '正在报警请尽快处理', message: redata.data[i].devicenumber + '正在报警请尽快处理',
onClose: function(){ onClose: function(){
console.log(redata.data[i].devicenumber);
}, },
}); });
}, 3); }, 3);
} }
} else { } else {
for (let j = 0; j < redata.data.length; j++) { for (let j = 0; j < redata.data.length; j++) {
console.log(redata.data[j].devicenumber, JSON.parse(localStorage.getItem('isalam')));
if (!this.isarray(redata.data[j].devicenumber, JSON.parse(localStorage.getItem('isalam')))) { if (!this.isarray(redata.data[j].devicenumber, JSON.parse(localStorage.getItem('isalam')))) {
setTimeout(() => { setTimeout(() => {
this.$notify.error({ this.$notify.error({
title: '报警提示!点击X可消警', title: '报警提示!点击右侧x可消警',
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
duration: 0, duration: 0,
message: redata.data[j].devicenumber + '正在报警请尽快处理', message: redata.data[j].devicenumber + '正在报警请尽快处理',
...@@ -176,6 +176,9 @@ export default { ...@@ -176,6 +176,9 @@ export default {
} }
} }
}, },
beforeun(e) {
localStorage.removeItem('isalam');
},
websocketsend(){ // 数据发送 websocketsend(){ // 数据发送
this.websock.send(JSON.stringify(this.type)); this.websock.send(JSON.stringify(this.type));
}, },
......
...@@ -183,6 +183,7 @@ export default { ...@@ -183,6 +183,7 @@ export default {
this.$store.dispatch('user/login', this.loginForm) this.$store.dispatch('user/login', this.loginForm)
.then(() => { .then(() => {
this.$router.push({ path: this.redirect || '/' }); this.$router.push({ path: this.redirect || '/' });
localStorage.removeItem('isalam');
this.loading = false; this.loading = false;
}) })
.catch(() => { .catch(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment