田源
2024-04-07 2ac55ce0edf4870a29691b56bfad59f4830a11a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
 * 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 =[
                '<div>'+ data.msg +'</div>'
            ].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);
});