<{import file="member/reg_header.html" title="会员注册"}> 
<div class="regbox_bar"> 
	<div class="regbox"> 
		<form action="#" method="post"> 
			<div class="reg_con">
				<div id="error_msg" style="display:none;"></div>
				<div class="rbox_input"> 
					<span>手机号码</span> 
					<input type="text" name="username" class="input1" placeholder="手机不能为空" value="" autocomplete="off"/>
				</div> 
				<div class="rbox_input">
					<span>验证码</span>
					<input type="text" name="vcode" id="vcode" class="input2" size="10" maxlength="6" autocomplete="off"/> 
					<a href="javascript:;"><img id="vcode" src="<{$__URI__}>ajax/vcode"/></a> 
				</div>
				<{if $UQCMS.sms_status == '1'}>
					 <div class="rbox_input tbsms">
						<span>手机验证码</span>
						<input type="text" name="smscode" class="input2" id="smscode" placeholder="手机验证码" maxlength="6" autocomplete="off"/>
						<input id="zphone" type="button" value="获取手机验证码"> 
					</div>
				<{/if}>
				<div class="rbox_input">
					<span>登录密码</span>
					<input type="password" name="password" class="input1" placeholder="密码位数不能低于6位" autocomplete="off"/> 
				</div>
				<div class="rbox_input">
					<span>确认密码</span>
					<input type="password" name="repasswd" class="input1" placeholder="需要与上一步的密码一致" autocomplete="off"/> 
				</div> 
				<div class="rbox_sub"><input type="submit" name="submit" class="submit_reg" value="同意用户协议并注册"/></div>
			</div>
		</form>
		<div class="reg_other">
			<a href="<{$__URI__}>member/login">已有账号，立即登陆</a> 
			<a href="<{$__URI__}>member/forget">忘记密码</a> 
		</div> 
	</div> 
</div>
<div class="copyright_bar">
	<div class="copyright"><{$UQCMS.site_copyright}></div>
</div>
<{import file="bottom.html"}>
<script type="text/javascript">
$(function(){ 
	$("form").submit(function(){ 
		var username = $('input[name=username]').val();
		if(username == ''){
			$("#error_msg").show().html('电话号码不能为空'); return false;
		}
		var password = $('input[name=password]').val(); 
		var repasswd = $('input[name=repasswd]').val(); 
		if(password == ''){ 
			$.alert('密码不能为空');  return false;
		} 
		if(repasswd == ''){ 
			$.alert('重复密码不能为空'); return false;
		}
		if(password != repasswd){ 
			$.alert('两次密码输入不一致'); return false; 
		} 
		<{if $UQCMS.sms_status == '1'}>
			var smscode = $('input[name=smscode]').val(); 
			if(smscode == ''){
				$("#error_msg").show().html('手机验证码不能为空'); return false;
			}
		<{else}>
			var smscode = $('input[name=vcode]').val(); 
			if(smscode == ''){
				$("#error_msg").show().html('验证码不能为空'); return false;
			}
		<{/if}>
		$.ajax({
			type:'POST',
			url:URI+'member/do_register',
			data:{username:username, password:password, repasswd:repasswd, smscode:smscode}, 
			success:function(result){
				var data = jQuery.parseJSON(result); 
				if(data.error == '0'){
					$.alert('注册成功', function(){
						location.href = URI+"member/login"; 
					}); 
				}else{
					$("#error_msg").show().html(data.msg); 
					freshVcode();
					return false;
				}
			},
			error:function(){
				$.alert('系统繁忙');
			}
		}); 
		return false;
	});
	
	// 检测账号是否存在
	/*
	function checkMobileIsExist(){
		var username = jQuery("#username").val();
		var flag = true;
		$.ajax({ 
			url:URI+"member/check_mobile&t="+(new Date()).getTime(),
			data:{mobile:username},
			dataType:"json",
			type:"GET",
			async:false,
			success:function(data) {
				var status = data.status;
				if(status == "0"){
					flag = false;
				}
			}
		});
		return flag;
	}*/
	
	$("#zphone").click(function(){						// 获得验证码 
		var username = $('input[name=username]').val();  
		var vcode 	 = $('input[name=vcode]').val(); 
		send_sms(username, vcode, '#zphone', '2');
	});
}); 

</script>