<{import file="common.html" title="会员登陆"}>
<link rel="stylesheet" type="text/css" href="<{$__APP__}>public/css/login.css?<{$js_version}>"/>
<div class="cnav"><a class="back">&nbsp;</a>账户登陆<a href="javascript:;" class="thome">主页</a></div> 
<style type="text/css">
#vcodebox{ display:none; }
</style>
<div class="main"> 
	<div class="loginBox"> 
		<form id="form" action="#" method="post">
			<div id="error_msg" style="display:none;"></div>
			<div class="tbtr">
				<i class="mobile">手机号码</i>
				<p><input type="text" name="username" class="input_text" placeholder="请输入手机号码"/></p>
			</div>
			<div class="tbtr">
				<i class="pass">密码</i>
				<p><input type="password" name="password" class="input_pass" placeholder="请输入登陆密码"/></p>
			</div>
			<div class="tbtr" id="vcodebox">
				<i class="vcode">验证码</i>
				<p><input type="text" name="vcode" class="input_vcode" placeholder="请输入验证码" size="15"/>
				<a href="javascript:;"><img id="vcode" src="<{$__URI__}>ajax/vcode"></a>
			</div>
			<div class="tbtr" style=" border-bottom:none; padding:0.2rem 0 0 0;">
				<input type="submit" name="vcode" class="login_submit" value="登陆"/>
			</div>
		</form>
		<div class="find_pass">
			<a href="<{$__WAP__}>member/forget" class="l">找回密码</a>
			<a href="<{$__WAP__}>member/register" class="r">立即注册</a>
		</div>
		<{if $UQCMS.browser != 'wchat'}>
			<{uqcms m="api" v="conn" c="alist:type=login"}> 
			<{if $conn}>
				<div class="conn_name">第三方账号登陆</div>
				<div class="conn_box">
					<{foreach item=i from=$conn}>
						<a href="<{$__URI__}>member/connect?alias=<{$i.alias}>&state=<{math equation=rand(0,10000)}>"><img src="<{$__PUBLIC__}>images/connect/32<{$i.alias}>.png"></a>
					<{/foreach}>
				</div>
			<{/if}> 
		<{/if}> 
	</div>
</div> 
<{import file="footer.html"}>
<script type="text/javascript">
$(function(){
	$("form#form").submit(function(){ 
		var username = $('input[name=username]').val();
		var password = $('input[name=password]').val(); 
		if(username == ''){ $.alert('用户名不能为空'); return false;} 
		if(password == ''){ $.alert('密码不能为空'); return false;}  
		var vcode = $('input[name=vcode]').val(); 
		$('.submit_login').attr("disabled", true).val('正在登陆..'); 
		$.ajax({
			type:'POST',
			url: URI+'member/login_do',
			data:{username:username, password:password, vcode:vcode}, 
			success:function(result){
				var data = jQuery.parseJSON(result); 
				if(data.error == '0'){
					<{if $smarty.get.returnUrl}>
						window.location.href=GetQueryString('returnUrl'); 
					<{else}>
						window.location.href=WAP+"member/index";
					<{/if}> 
				}else{
					// 登录错误
					ckVcode();
					$.alert(data.msg);
					$('.submit_login').attr("disabled", false).val('登陆');
					$('input.input_vcode').val('');
					freshVcode();
				}  
			},
			error:function(){
				alert('错误');
				$('.submit_login').attr("disabled", false).val('登陆');
			}
		});
		return false; 
	}); 
	
	$("input[name='username'],input[name='password']").blur(function(){
		ckVcode();
	});
	function ckVcode(){
		var username = $("input[name='username']").val();
		if(username == '' || username == undefined){
			$("#vcodebox").hide();
		}else{
			$.post('<{$__URI__}>member/is_vcode',{username:username},function(result){
				data = jQuery.parseJSON(result); 
				if(data.error == '1'){
					$("#vcodebox").show();
				}else{
					$("#vcodebox").hide();
				}
			});
			return false;
		}
	}
});
</script>
