自动化立体仓库 - WMS系统
#
luxiaotao1123
2020-07-09 27991963196d5d59fe2ccb73d28bb25faaa15177
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, target-densitydpi=high-dpi, initial-scale=1.0, user-scalable=no"/>
    <title>系统登录</title>
    <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
    <style>
        .login-form input {
            display: block;
        }
        .login-form button {
            display: block;
        }
    </style>
</head>
<body>
    <h1>中扬物流</h1>
    <div class="login-form">
        <div>
            <span>账号</span>
            <input type="text" id="mobile" value="super">
        </div>
        <div>
            <span>密码</span>
            <input type="password" id="password" value="xltys1995">
        </div>
        <div>
            <button onclick="login()">登录</button>
        </div>
 
    </div>
</body>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/js/tools/md5.js"></script>
<script type="text/javascript">
    document.onkeydown = function(e) {
        //捕捉回车事件
        var ev = (typeof event!= 'undefined') ? window.event : e;
        if(ev.keyCode === 13 && document.activeElement.id === "key") {
            login()
        }
    }
    document.onkeyup = function (e) {
        if (window.event)//如果window.event对象存在,就以此事件对象为准
            e = window.event;
        var code = e.charCode || e.keyCode;
        if (code === 13) {
            login()
        }
    }
    function login(){
        httpRequest({
            httpUrl: baseUrl+"/login.action",
            type: 'post',
            data: {
                mobile: document.getElementById('mobile').value,
                password: hex_md5(document.getElementById('password').value)
            }
        }, function (res) {
            if (res.code === 200) {
                window.location.href = "index.html";
            } else {
                alert(res.msg);
            }
 
        })
    }
 
    function httpRequest(paramObj,fun,errFun) {
        var xmlhttp = null;
        /*创建XMLHttpRequest对象,
         *老版本的 Internet Explorer(IE5 和 IE6)使用 ActiveX 对象:new ActiveXObject("Microsoft.XMLHTTP")
         * */
        if(window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        }else if(window.ActiveXObject) {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        /*判断是否支持请求*/
        if(xmlhttp == null) {
            alert('你的浏览器不支持XMLHttp');
            return;
        }
        /*请求方式,并且转换为大写*/
        var httpType = (paramObj.type || 'GET').toUpperCase();
        /*数据类型*/
        var dataType = paramObj.dataType || 'json';
        /*请求接口*/
        var httpUrl = paramObj.httpUrl || '';
        /*是否异步请求*/
        var async = paramObj.async || true;
        /*请求参数--post请求参数格式为:foo=bar&lorem=ipsum*/
        var paramData = paramObj.data || [];
        var requestData = '';
        for(var name in paramData) {
            requestData += name + '='+ paramData[name] + '&';
        }
        requestData = requestData === '' ? '' : requestData.substring(0,requestData.length - 1);
 
        /*请求接收*/
        xmlhttp.onreadystatechange = function() {
            if(xmlhttp.readyState === 4 && xmlhttp.status === 200) {
                /*成功回调函数*/
                fun(JSON.parse(xmlhttp.responseText));
            }else{
                /*失败回调函数*/
                errFun;
            }
        }
 
        /*接口连接,先判断连接类型是post还是get*/
        if(httpType === 'GET') {
            xmlhttp.open("GET",httpUrl,async);
            xmlhttp.send(null);
        }else if(httpType === 'POST'){
            xmlhttp.open("POST",httpUrl,async);
            //发送合适的请求头信息
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send(requestData);
        }
    }
</script>
</html>