<!--{assign var="menu_id" value="index"}-->
<!--{include file="<!--{$oetplpath}-->block_header.tpl"}-->
<div class="oe_ntop">
  <i class="iconfont" onclick="goBack();">&#xe616;</i>
  <p>会员注册</p>
</div>
<div class="oe_reg">
  <h2>填写会员注册信息</h2>
  <div class="oe_input">

    <dl>
      <dt>手机号码</dt>
      <dd>
        <input type="text" id="mobile" name="mobile" placeholder="输入有效手机号" class="input" f="data-post" data-flag="1" data-prompt="请输入有效手机号码" data-box="tips_submit" data-color="red" />
        <label id="tips_mobile"></label>
      </dd>
    </dl>

    <dl>
      <dt>用 户 名</dt>
      <dd>
        <input type="text" id="username" name="username" placeholder="输入用户名" class="input" f="data-post" data-flag="1" data-prompt="输入用户名" data-box="tips_submit" data-color="red" />
        <label id="tips_username"></label>
      </dd>
    </dl>

    <dl>
      <dt>登录密码</dt>
      <dd>
        <input type="password" id="password" name="password" placeholder="输入6~16位密码" class="input" maxlength="16" f="data-post" data-flag="1" data-prompt="请输入登录密码" data-box="tips_submit" data-color="red" />
        <label id="tips_password"></label>
      </dd>
    </dl>

	<dl>
      <dt>确认密码</dt>
      <dd>
        <input type="password" id="confirmpassword" name="confirmpassword" placeholder="再次输入密码" class="input" maxlength="16" f="data-post" data-flag="1" data-prompt="请再次输入密码" data-box="tips_submit" data-color="red" />
        <label id="tips_confirmpassword"></label>
      </dd>
    </dl>

    <dl>
      <dt>性别</dt>
      <dd>
	    <select name="gender" id="gender" f="data-post">
		  <option value="">点击选择</option>
		  <option value="2">女</option>
		  <option value="1">男</option>
		</select>
        <label id="tips_gender"></label>
      </dd>
    </dl>
  </div>

  <div class="oe_button">
    <p id="tips_submit"></p>
    <span f="but_regpost" style="cursor:pointer;">提交注册</span>
  </div>

</div>
<script type="text/javascript">
$(function(){
	$max_width = (WIN_WIDTH-120);
	$(".oe_input dl dd input").css({"width":$max_width});
	$(".oe_reg dl dd input.checkcode").css({"width":$max_width-120});
	
	//手机号码
	$("#mobile").bind("blur", function(){
		$tips_obj = $("#tips_mobile");
		$tips_obj.html("");
		$tips_obj.hide();
		$val = $(this).val();

		if ($val.length == 0) {
			$tips_obj.html("请输入手机号码");
			$tips_obj.show();
			return false;
		}
		if (!isMobile($val)) {
			$tips_obj.html("请输入正确的手机号码");
			$tips_obj.show();
			return false;
		}

		if ($val.length > 0) {
			$.ajax({
				type: "POST",
				url: WAP_APPFILE + "&c=passport&a=checkmobile",
				cache: false,
				data: {mobile:$val, r:get_rndnum(8)},
				dataType: "json",
				success: function($data) {
					$json = eval($data);
					$response = $json.response;
					$result = $json.result;
					if ($response == "1") {
						$tips_obj.html("");
						$tips_obj.hide();
					}
					else {
						if ($result.length > 0) {
							$tips_obj.html("<font color='red'>"+$result+"</font>");
						}
						else {
							$tips_obj.html("<font color='red'>手机号码已被注册</font>");
						}
						$tips_obj.show();
					}

				},
				error: function() {

				}
			});
		}
	});
	
	//会员名
	$("#username").bind("blur", function(){
		$tips_obj = $("#tips_username");
		$tips_obj.html("");
		$tips_obj.hide();
		$val = $(this).val();
		if ($val.length == 0) {
			$tips_obj.html("请输入用户名");
			$tips_obj.show();
			return false;
		}

		if ($val.length > 0) {
			$.ajax({
				type: "POST",
				url: WAP_APPFILE + "&c=passport&a=checkusername",
				cache: false,
				data: {username:$val, r:get_rndnum(8)},
				dataType: "json",
				success: function($data) {
					$json = eval($data);
					$response = $json.response;
					$result = $json.result;
					if ($response == "1") {
						$tips_obj.html("");
						$tips_obj.hide();
					}
					else {
						if ($result.length > 0) {
							$tips_obj.html("<font color='red'>"+$result+"</font>");
						}
						else {
							$tips_obj.html("<font color='red'>用户名已被注册</font>");
						}
						$tips_obj.show();
					}

				},
				error: function() {

				}
			});
		}
	});

	//登录密码
	$("#password").bind("blur", function(){
		$tips_obj = $("#tips_password");
		$tips_obj.html("");
		$tips_obj.hide();
		$_val = $(this).val();
		if ($_val.length < 6 || $_val.length > 16) {
			$tips_obj.html("请输入6-16个字符的登录密码");
			$tips_obj.show();
		}
	});

	//确认密码
	$("#confirmpassword").bind("blur", function(){
		$tips_obj = $("#tips_confirmpassword");
		$tips_obj.html("");
		$tips_obj.hide();
		$_val = $(this).val();
		if ($_val.length < 6 || $_val.length > 16) {
			$tips_obj.html("请再次输入密码");
			$tips_obj.show();
			return false;
		}
		
		if ($_val != $("#password").val()) {
			$tips_obj.html("确认密码不正确");
			$tips_obj.show();
		}

	});

	//提交
	$(document).on("click", "[f='but_regpost']", function(){
		$_urlitems = _oemarryGetField();
		if ($_urlitems != false) {
			$_url = WAP_APPFILE + "&c=<!--{$c}-->&a=userpost"+$_urlitems;
			$post_json = {"url":$_url, "type":"jump", "success_text":"注册成功", "fail_text":"注册失败", "tips_box":"tips_submit", "jumpurl":"<!--{$oefile}-->&c=cp"};
			_oemarryAjaxPost($post_json);
		}
	});

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