$(document).ready(function(){
	var userPhone = localStorage.getItem('keyNames');
	if(userPhone){
	    $('#userPhone').val(userPhone);
    }

    $(document).keypress(function(e) {
        // 回车键事件
        if(e.which == 13) {
            KeyDown();
        }
    });
});
function login() {
	/*$("#userPwd").val(hex_md5($("#password").val()));
	var data = formToJson($("#user-login"));*/
	var userPhone = $("#userPhone").val();
	var userPwd =  hex_md5($("#password").val()); 
	
    if($('#rmbuser').is(':checked')){
        localStorage.setItem('keyNames',userPhone);
    }else{
        localStorage.removeItem('keyNames');
    }
	
	$.ajax({
		url : url+'/referees/authorization',//117
		type : 'post',
		dataType : 'json',
		async:false, 
		data :{
			"refereeNo":userPhone,
			"refereePwd":userPwd,
		},
		success : function(data) {
			if(data['code']!=1){
				toastr['error'](data.description, '提示');
			}else{
				toastr['success'](data.description, '提示');
				var storage=window.localStorage;
	            storage.setItem("parallelId",data.result.id);
	            storage.setItem("parallelToken",data.result.accessToken);
	            storage.setItem("userType",data.result.userType);
	            setTimeout(function(){window.location.href = 'fleet.html';},2000);
				
			}
		},
		error: function(data) { 
			$("#myAlerta").modal("toggle");
		} 
	});
}
function KeyDown(){
  if (event.keyCode == 13){
    event.returnValue=false;
    event.cancel = true;
    Form1.btnsubmit.click();
    $("#userPwd").val(hex_md5($("#password").val()));
  //debugger;
  }
}
