登录

功能:

登录

资料:

/login/Authnum?a=0.4848300017503864

 

文件:/templates/login.php

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>登录</title>
<meta charset="UTF-8" />
<script src="/Scripts/Common/jquery-1.11.3.min.js?08c0cfebb0"></script>
<script>
		
function replaceSpecialAgentCode() {
	var url =  "/login/Authnum?a="+Math.random() ;
	$('#verifycodeImg').attr('src',url);
}

$(document).ready(function(){
	
$("#login").click(function(){
	var loginData = {
		"username": $('#username').val(),
		"password": $('#password').val(),
		"verifycode": $('#verifycode').val()
	}
	$.ajax({
	  type: "POST",
	  url: "/Login/login",
	  data: loginData,
	  cache:false,
	  dataType:"json",
	  async:false,
	  beforeSend: function () {
		  // 禁用按钮防止重复提交,发送前响应
		$('#login').attr({ disabled: "disabled" });
	  },
	  success: function(data){
		console.log('data', data);
				if (data.tips=="") {
					$(location).attr('href', '/LobbyOp');
					alert("登录成功,即将跳转");
				} 
				else {
				  alert(data.tips);
				  replaceSpecialAgentCode();
		}
	  }
	});
});

});  
</script>
</head>
<body>

	<form method="post" onsubmit="specialAgentLogin()">
		<input type="text" name="username" id="username" class="lg" placeholder="用户名">
		<input type="password" name="password" id="password" placeholder="密 码">
		<input type="text" name="verifycode" id="verify_code" placeholder="验证码">
		<img src="/login/Authnum?a=0.4848300017503864" id="verify_codeImg" class="codeimg" onclick="replaceSpecialAgentCode()">
		<input type="submit" id="login" value="login">
	</form>
</body>
</html>

 

posted @ 2017-05-14 01:56  百草之家  阅读(622)  评论(0编辑  收藏  举报