<style type="text/css">
@media screen and (min-width: 721px){
.main{ padding: 1in }
.main .form{ width: 5in; margin: 0mm auto }
.main .form span.fl{ width: 1in; border-right: var(--bd); background-color: var(--bg); line-height: 1cm; text-align: right; padding-right: 2mm }
.main .form p{ margin: 0mm 0mm 0mm 3cm; padding: 2mm }
}
@media screen and (max-width: 720px){
.main .bd{ border-left: none; border-right: none }
.form .fl{ padding: 1vw 2vw; border-right: var(--bd); background-color: #eee; width: 20vw; height: 6vw }
.form p{ border-left: var(--bd); padding: 1vw 2vw; margin: 0mm 0mm 0mm 24vw; height: 6vw }
.form p *{ border: none; width: 100%; vertical-align: middle; outline: none; font: 4vw/6vw arial }
.form p textarea{ height: 20vw }
.main .tc input{ font: 4vw/6vw arial; padding: 1vw 4vw }
}
</style>
<div class="pos mt bd"><a href="/"><%= sys.name %></a> → 用户登录</div>
<div class="mt bd">
	<div class="cap tc">请输入您的用户名、密码登录</div>
	<div class="main">
		<div class="form bd">
			<div>
				<span class="fl">用户名：</span>
				<p><input name="user" placeholder="请输入用户名" /> <a href="<%= sys.routepath %>register" class="for-web">您没有注册？</a></p>
			</div>
			<div style="border-top: var(--bd)">
				<span class="fl">密码：</span>
				<p><input name="pass" type="password" placeholder="请输入密码" /> <span class="for-web">忘记密码？</span></p>
			</div>
		</div>
		<p class="tc"><input type="button" value=" 登  录 " /></p>
	</div>
</div>
<script type="text/javascript">
var ipt = document.querySelectorAll(".main input");
ipt[0].onkeypress = ipt[1].onkeypress = function(e) {
	if(e.keyCode != 13) return;
	doLogin();
};
ipt[2].onclick = doLogin;

function doLogin() {
	if(!ipt[0].value) return alert("请输入用户名"), ipt[0].focus();
	if(!ipt[1].value) return alert("请输入密码"), ipt[1].focus();
	post("<%= sys.routepath %>api/login", {
		user: ipt[0].value, pass: ipt[1].value
	}, function(res) {
		if(res.err) return alert(res.err);
		alert(res.msg);
		location.assign("/");
	});
};
</script>