<{import file="index/reg_header.html" title="会员登陆"}>
<div class="main_bar">
	<div class="lunbo">
		<{ads alias="member_login" data="bg_ads"}>
		<{foreach item="i" from=$bg_ads}> 
			<{if $i.type == '2'}>
				<a href="<{$i.link}>" target="_blank" style="background: url(<{$__IMG__}><{$i.content|img_size:1920x500}>) center center;"></a>
			<{/if}> 
		<{/foreach}> 
	</div>
	<div class="main">
	<form action="#" method="post">
		<div class="reg_box">
			<div class="bname"><span>用户登录</span></div>
			<div class="bcon">
				<div id="error_msg" style="display:none;"></div>
				<div class="binput"><i class="i1"></i><input type="text" name="username" placeholder="用户名/邮箱/电话号码" id="text"/></div>
				<div class="binput"><i class="i2"></i><input type="password" name="password" id="password" placeholder="密码"/></div>
				<div class="binput">
					<i class="i3"></i><input type="text" name="vcode" size="10" id="vcode" placeholder="验证码" maxlength="4"/>
					<a href="javascript:;" onClick="change_img()"><img id="vcode_img" src="index.php?m=ajax&a=vcode"/></a>
				</div>
				<div class="binput" style="border:none;"><input type="submit" name="submit" class="submit_login" value="登录"/></div>
			</div>
			<div class="login_reg_box">
				<a href="?a=forget" style="padding-right:30px;">忘记密码</a>
				<a href="?a=register">立即注册</a> 
			</div>
			<{uqcms m="api" v="conn" c="login_list"}> 
			<{if $conn}>
				<div class="sub_frm">
					<label style="color:#999999;">快捷方式登录：</label>
					<div class="sub_con">
						<{foreach item=i from=$conn}> 
							<a href="member.php?a=connect&alias=<{$i.alias}>&state=<{math equation=rand(0,10000)}>" class="connect"><img src="<{$__PUBLIC__}>images/connect/32<{$i.alias}>.png"><span><{$i.name}></span></a>
						<{/foreach}> 
					</div>
				</div>  
			<{/if}>
		</div>
	</form>
	</div> 
</div>	
<{include file="index/footer.html"}>
<script type="text/javascript">
function GetQueryString(name){
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}
$(function(){ 
	$('form').submit(function(){ 
		var username = $('input[name=username]').val();
		var password = $('input[name=password]').val(); 
		var vcode = $('#vcode').val(); 
		if(username == ''){$("#error_msg").show().html('用户名不能为空'); return false;} 
		if(password == ''){$("#error_msg").show().html('密码不能为空'); return false;} 
		if(vcode == ''){$("#error_msg").show().html('验证码不能为空'); return false;}
		$('.submit_login').attr("disabled", true).val('正在登陆..');
		$.ajax({
			type:'POST',
			url:'member.php?a=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="member.php";
					<{/if}> 
				}else{
					$("#error_msg").show().html(data.msg);
					$('.submit_login').attr("disabled", false).val('登陆');
					change_img();
				}
			},
			error:function(){
				alert('错误');
				$('.submit_login').attr("disabled", false).val('登陆');
			}
		});
		return false; 
	}); 
});
function change_img(){ 
	var timestamp = (new Date()).valueOf();
	var src = 'index.php?m=ajax&a=vcode&time='+timestamp;
	$("#vcode_img").attr('src',src);
} 
</script>
