$("#login_submit").on("click", function(){
  var username = $("#login_form").find("input[name='username']");
  var password = $("#login_form").find("input[name='password']");
  var verifycode = $("#login_form").find("input[name='verifycode']");
  if($(username).val()==""){
    layer.tips('请填写用户名', $(username), {tips: [1, '#FF5722']});
    return false;
  }
  if($(password).val()==""){
    layer.tips('请填写密码', $(password), {tips: [1, '#FF5722']});
    return false;
  }
  if($(verifycode).val()==""){
    layer.tips('请填写验证码', $(verifycode), {tips: [1, '#FF5722']});
    return false;
  }
  $("#login_form").ajaxSubmit({
    url: '/login/loginok', 
    type: 'POST',
    dataType: "json", 
    beforeSend: function(){
      layer.load(0, {shade: [0.2, '#393D49']});
    },
    success: function(data){
      if(data.code=="success"){
        layer.msg('登录成功', {icon: 1}, function(){top.location = data.url;});
      }else{
        layer.msg(data.msg, {icon: 2});
      }
    },
    error: function(){
      layer.msg("系统错误，请联系管理员", {icon: 2});
    },
    complete: function(){
      layer.closeAll('loading');
    }
  });
  return false;
});