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

报警弹出

parent 0a9a7abc
Pipeline #69 canceled with stages
......@@ -80,8 +80,11 @@ class swooleMeTcp extends Command
});
//监听数据接收事件
$this->tcp->on('Receive', function ($serv, $fd, $from_id, $data) {
$swooletcp = new SwooleCommandMeTcpController();
$swooletcp->swooletcplist($data);
//验证数据格式
if($this->formatData($data)){
$swooletcp = new SwooleCommandMeTcpController();
$swooletcp->swooletcplist($data);
}
});
//监听连接关闭事件
......@@ -92,5 +95,16 @@ class swooleMeTcp extends Command
//启动服务器
$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 {
},
async logout() {
await this.$store.dispatch('user/logout');
this.$notify.closeAll();
this.webscoket.onclose();
this.$router.push(`/login?redirect=${this.$route.fullPath}`);
},
},
......
......@@ -71,6 +71,9 @@ export default {
}
},
},
created() {
window.addEventListener('beforeunload', e => this.beforeun(e));
},
mounted() {
this.initTags();
this.addTags();
......@@ -140,7 +143,6 @@ export default {
websocketonmessage(e){ // 数据接收
const redata = JSON.parse(e.data);
if (redata.code === 200) {
localStorage.removeItem('isalam');
if (localStorage.getItem('isalam') === null || localStorage.getItem('isalam') === undefined) { // 第一次没有的话
localStorage.setItem('isalam', JSON.stringify(redata.data));
for (let i = 0; i < redata.data.length; i++) {
......@@ -151,18 +153,16 @@ export default {
duration: 0,
message: redata.data[i].devicenumber + '正在报警请尽快处理',
onClose: function(){
console.log(redata.data[i].devicenumber);
},
});
}, 3);
}
} else {
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')))) {
setTimeout(() => {
this.$notify.error({
title: '报警提示!点击X可消警',
title: '报警提示!点击右侧x可消警',
dangerouslyUseHTMLString: true,
duration: 0,
message: redata.data[j].devicenumber + '正在报警请尽快处理',
......@@ -176,6 +176,9 @@ export default {
}
}
},
beforeun(e) {
localStorage.removeItem('isalam');
},
websocketsend(){ // 数据发送
this.websock.send(JSON.stringify(this.type));
},
......
......@@ -183,6 +183,7 @@ export default {
this.$store.dispatch('user/login', this.loginForm)
.then(() => {
this.$router.push({ path: this.redirect || '/' });
localStorage.removeItem('isalam');
this.loading = false;
})
.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