//加载弹出层组件
layui.use('layer',function(){

    var layer = layui.layer;

    $("#sub").on("click",function(){
        var data={ username:$("input[name='username']").val(),password:$("input[name='password']").val()};
        $.ajax({
            url:"/access/sysLogin",
            type:"post",
            data:JSON.stringify(data),
            contentType:'application/json;charset=UTF-8',//关键是要加上这行
            traditional:true,//这使json格式的字符不会被转码
            dataType:"json",
            success:function (result) {
                if (result.code=='01'){
                    parent.location.href = '/sys/home.html';
                }else{
                    layer.alert(result.message, {
                        icon: 2,
                        skin: 'layer-ext-moon'
                    })
                }
            }

        })
    });

    $("body").keydown(function(){
        if(event.keyCode == "13"){
            Login();
        }
    });
});