/** * Created by dengbk on 2019/3/27. */ /* * 预警信息提示 * */ layui.define(['layer','vciWebSocket','util'],function(exports){ var Reminder = function(){ this.moduleKey = "vciWebReminder"; this.basePath = path; this.url = { }; this.getContent = function(){ return ''; }; this.init = function(){ var that = this; var socket = layui.vciWebSocket; var userOid = $webUtil.getSystemVar($webUtil.systemValueKey.userOid) socket.init({ wsUrl:"ws://"+that.url,//服务器地址 HeartBeat:'xxx',//发送的心跳数据 防止失活 timeout:300000,//发送心跳数据的间隔时间 onopen:function(){ //握手成功 //console.log("服务连接成功"); socket.send(userOid);//发送数据 }, onmessage:function(data){ //收到消息 that.showWarning(data.msg); that.showTask(data) } }); //socket.close();//断开连接 }; this.showWarning = function(msg){ var that = this; var alertHtmlId = $("#systemReminder_tips"); alertHtmlId.find("span").html(msg); alertHtmlId.show(); window.setTimeout(function(){ alertHtmlId.hide() },10000) }; this.showTask = function(data){ var that = this; var content =[ '
'+ data.msg +'
' ].join(""); var showTask = layer.open({ type:1, title:'任务提示', btn:['查看任务','取消'], skin:'layui-layer-lan', content:content, area:['400px','250px'], closeBtn:2, shade:true, shadeClose:true, success:function(layero){ }, yes:function(){ $webUtil.showConfirmMsg("确认查看[" + data.taskName + "]任务?",function () { var menuObject = { id:data.id, text:data.text, bsUrl:'USEJS:'+data.url, notAllowFav:true }; that.showTabByMenu(data.id,menuObject); }); }, btn2:function(){ layer.close(showTask); } }) } }; var rm = new Reminder(); exports("vciWebReminder",rm); });