自动化立体仓库 - WMS系统
#
luxiaotao1123
2020-07-10 a67ef1ea9215d52bbdef49061639f91cae5a972b
src/main/webapp/views/pdaCe/login.html
@@ -26,7 +26,7 @@
            <input type="password" id="password" value="xltys1995">
        </div>
        <div>
            <button onclick="login()">登录</button>
            <button id="login" onclick="login()">登录</button>
        </div>
    </div>
@@ -34,7 +34,14 @@
<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) {
        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",
@@ -44,10 +51,31 @@
                password: hex_md5(document.getElementById('password').value)
            }
        }, function (res) {
            window.location.href = "index.html";
            if (res.code === 200) {
                // localStorage.setItem("token", res.data.token);
                // localStorage.setItem("username", res.data.username);
                setCookie("token", res.data.token);
                window.location.href = "index.html";
            } else {
                alert(res.msg);
            }
        })
    }
    // 设置cookie
    function setCookie(objName, objValue){//添加cookie
        var str = objName + "=" + encodeURIComponent(objValue);
        // if (objHours > 0) {//为0时不设定过期时间,浏览器关闭时cookie自动消失
        //     var date = new Date();
        //     var ms = objHours * 3600 * 1000;
        //     date.setTime(date.getTime() + ms);
        //     str += "; expires=" + date.toUTCString();
        // }
        str += "; path=/";
        document.cookie = str;
    }
    function httpRequest(paramObj,fun,errFun) {
        var xmlhttp = null;
        /*创建XMLHttpRequest对象,