/**
 * Created by ljx on 2019/4/25.
 */
$(function(){
    //cookie数据保存格式是key=value;key=value;形式，loginInfo为保存在cookie中的key值，具体看controller代码
    /*if(str != ""){
        var userName = str.split("#")[0];
        var userPwd = str.split("#")[1];
        //自动填充用户名和密码
        $("#userName").val(userName);
        $("#userPwd").val(userPwd);
        //并且选中复选框
        $("#rememberMe").attr("checked", true);
    }*/
    
    //获取cookie
    /*function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1);
            if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
        }
        return "";
    }*/

    $("#forgetPwd").on("click",function(){
        alert("请联系管理员进行修改密码！");
    });


});

$('body').keydown(function () {
    if(event.keyCode == '13'){
        var userName = $("#userName").val();
        var userPwd = $("#userPwd").val();
        var rememberMeChecked = $("input[type='checkbox']").is(':checked');
        var rememberMe = '';
        if(rememberMeChecked){
            rememberMe = 'yes';
        }
        if(userName == ''){
            toastr.warning("用户名不能为空!");
        }else{
            if(userPwd == ''){
                toastr.warning("密码不能为空!");
            }else{
                $.ajax({
                    type : "POST",
                    url : path+"/login",
                    data: {userName:userName, userPwd:userPwd,rememberMe:rememberMe},
                    success : function(data) {
                        //window.location.href =  'gatewayPage';
                    },
                })
            }
        }
    }
})



