星伟
2018-09-21 482825da5c78b3d4daa7d8804570da85d12e0758
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>蓄电池智能远程运维系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="mobilCss/jquery.mobile-1.4.5.min.css" />
<script type="text/javascript" src="mobilJs/jquery-1.8.2.js"></script>
<script type="text/javascript" src="mobilJs/jquery.mobile-1.4.5.min.js"></script>
<style type="text/css">
    .icon-user{
      position: absolute;
      margin-left:6px;
      margin-top: 19px;
      background-image: url(../image/user_ac_bg.gif); /*引入图片图片*/
      background-repeat: no-repeat; /*设置图片不重复*/
      background-position: 0px 0px; /*图片显示的位置*/
      width: 40px; /*设置图片显示的宽*/
      height: 40px; /*图片显示的高*/
      min-height: 3em;
    }
    
    .icon-pass{
      position: absolute;
      margin-left:6px;
      margin-top: 19px;
      background-image: url(../image/psd_ac_bg.gif); /*引入图片图片*/
      background-repeat: no-repeat; /*设置图片不重复*/
      background-position: 0px 0px; /*图片显示的位置*/
      width: 40px; /*设置图片显示的宽*/
      height: 40px; /*图片显示的高*/
      min-height: 3em;
    }
    
    input:-webkit-autofill {
        -webkit-box-shadow: 0 0 0px 1000px white inset;
    }
    
</style>
</head>
 
<body>
    <div  id="main">
        <div data-role="page" id="main_cont"  style="background:url(image/tieta.jpg);background-size:100% 100%;">
            <div data-role="content" class="ui-content">
                <h3 style="text-align:center;color: #E2DAE2;text-shadow:none;">蓄电池智能远程运维系统</h3>
                <form method="post" id="register">
                    <label for="user" style="color:#E2DAE2">用户名:</label>
                    <i class="icon-user"></i>
                    <input id="user" data-icon="star" name="user" type="text"placeholder="请输入用户名"  autofocus style="min-height:3.2em;text-indent: 1.5em;" />
                    <label for="password" style="color:#E2DAE2">密&nbsp;码:</label>
                        <i class="icon-pass"></i>
                    <input id="password" name="password" type="password" placeholder="请输入密码"  style="min-height:3.2em;text-indent:1.5em;" />
                    <p></p>
                    <div data-role="controlgroup">
                        <label for="check" style="color:#E2DAE2">记住密码</label>
                        <input id="check" name="check" type="checkbox" checked="checked" data-role="none" alt=""/>
                        <div style="display:inline-block;color:#E2DAE2">记住密码</div>
                        <span id="msg" style="float:right;color:red;text-shadow:none;"></span>
                    </div>
                    <input  id="sub" type="button" data-role="button" value="登录" />
                </form>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../js/base64.js"></script>
<script type="text/javascript" src="../js/MD5.js"></script>
<script type="text/javascript">
    //按钮触发事件
    document.getElementById("sub").onclick = function() {
        var user = document.getElementById("user").value.trim();
        var password = document.getElementById("password").value.trim();
        
        if (user=null||user == "" || user.length < 1) {
            document.getElementById("msg").innerHTML = "请输入用户名";
        } else if (password=null||password == "" || password.length < 1) {
            document.getElementById("msg").innerHTML = "请输入密码";
        } else {
            checkuser();
        }
        
    };
 
    //校验用户名密码是否正确
    function checkuser() {
        var user = document.getElementById("user").value;
        var password = document.getElementById("password").value;
        var num = $('#check').attr('checked')?1:0;
        password = hex_md5(password);
        $.post(
            "../LoginAction_login",
            "uinf.UName="+user+"&uinf.Upassword="+password+"&uinf.UId="+num,
            function(data) {
                console.info(data);
                data = eval("(" + data.result + ")");
                console.info(data);
                if (data.code == 0) {
                    document.getElementById("msg").innerHTML = data.msg;
                } else {
                    window.location.href = "index.html";
                }
            }).error(function(){
                document.getElementById("msg").innerHTML = "登录异常,请检查网络连接!!";
            });
    }
 
    //页面加载时检查cookie
    window.load = checkCookie();
 
    function getCookie(c_name){ //根据分隔符取每个变量的值
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf("^", c_start);
                if (c_end == -1)
                    c_end = document.cookie.length;
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return "";
    }
 
    //设置cookie中的用户名以及密码
    function setCookie(c_name, n_value, p_name, p_value, expiredays) //设置cookie
    {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name
                + "="
                + escape(n_value)
                + "^"
                + p_name
                + "="
                + escape(p_value)
                + ((expiredays == null) ? "" : "^;expires="
                        + exdate.toGMTString());
        //console.log(document.cookie);
    }
 
    function checkCookie() //检测cookie是否存在,如果存在则直接读取,否则创建新的cookie
    {
        var temp = getCookie("user").split(';')[0];
        var decodeStr=Base64.decode(temp);
        //console.info(decodeStr);
        if(decodeStr.length>0){
            var obj = eval("("+decodeStr+")");
            $('#user').val(obj.UName);
            $('#password').val(obj.USnId);
        }
    }
 
    function cleanCookie(c_name, p_name) { //使cookie过期
        document.cookie = c_name + "=" + ";" + p_name + "="
                + ";expires=Thu, 01-Jan-70 00:00:01 GMT";
        //console.info("删除成功");
    }
</script>
</html>