<!--{assign var="menu_id" value="cp"}-->
<!--{include file="<!--{$oetplpath}-->block_header.tpl"}-->
<div class="oe_ntop">
  <i class="iconfont" onclick="goBack();">&#xe616;</i>
  <p>添加收货地址</p>
</div>
<div class="oe_address_add">
  <dl>
  	<dt>收 货 人</dt>
  	<dd><input type="text" name="contname" id="contname"  placeholder="请输入收货人姓名" /></dd>
  </dl>
  <dl>
  	<dt>联系电话</dt>
  	<dd><input type="text" name="contphone" id="contphone" placeholder="请输入联系电话" /></dd>
  </dl>
  <dl>
  	<dt>所在地区</dt>
  	<dd>
      <label>
		<!--{area type='select' name='area' depth='1' child='1' text='请选择'}-->
		<span id="json_area2">
		  <select name="area2" id="area2"><option value="">请选择</option></select>
		</span>
		<span id="json_area3">
		  <select name="area3" id="area3"><option value="">请选择</option></select>
		</span>
	  </label>
      <i class="iconfont">&#xe615;</i>
    </dd>
  </dl>
  <dl>
  	<dt>所在街道</dt>
  	<dd><input type="text" name="street" id="street" placeholder="街道详细地址" /></dd>
  </dl>
  <dl>
  	<dt>邮政编码</dt>
  	<dd><input type="text" name="zipcode" id="zipcode" placeholder="邮政编码" /></dd>
  </dl>

  <div class="ge"></div>
  <dl f="but_select_default">
  	<dt>设为默认地址</dt>
  	<dd><span class="iconfont">&#xe61b;</span></dd>
  </dl>

  <div class="oe_address_btn">
    <input type="hidden" name="isdefault" id="isdefault" value="0" />
    <span f="but_submit" style="cursor:pointer;">添加保存</span>
  </div>
  <p style="padding:10px;text-align:center;" id="tips_submit"></p>

</div>

<script type="text/javascript">
$(function(){
	
	//默认地址
	$("[f='but_select_default']").bind("click", function(){
		if ($(this).hasClass("current")) {
			$(this).removeClass("current");
			$("#isdefault").val(0);
		}
		else {
			$(this).addClass("current");
			$("#isdefault").val(1);
		}
	});

	//添加保存
	$(document).on("click", "[f='but_submit']", function(){
		$tips_obj = $("#tips_submit");

		$contname = $("#contname").val();
		$contphone = $("#contphone").val();
		$area1 = $("#area1").val();
		$area2 = $("#area2").val();
		$area3 = $("#area3").val();
		$street = $("#street").val();
		$zipcode = $("#zipcode").val();
		$isdefault = $("#isdefault").val();

		if ($contname.length == 0) {
			$tips_obj.html("<font color='red'>请填写收货人</font>");
			return false;
		}
		if ($contphone.length == 0) {
			$tips_obj.html("<font color='red'>请填写联系方式</font>");
			return false;
		}
		if ($area1 <= 0) {
			$tips_obj.html("<font color='red'>请选择所在地区</font>");
			return false;
		}
		if ($area2 <= 0) {
			$tips_obj.html("<font color='red'>请选择所在地区</font>");
			return false;
		}
		if ($street.length == 0) {
			$tips_obj.html("<font color='red'>请填写所在街道</font>");
			return false;
		}

		$_urlitems = "&contname="+encodeURIComponent($contname)+"&contphone="+encodeURIComponent($contphone)+"&area1="+encodeURIComponent($area1)+"&area2="+encodeURIComponent($area2)+"&area3="+encodeURIComponent($area3)+"&street="+encodeURIComponent($street)+"&zipcode="+encodeURIComponent($zipcode)+"&isdefault="+encodeURIComponent($isdefault)+"";

		$_url = WAP_APPFILE + "&c=<!--{$c}-->&a=saveadd"+$_urlitems;
		$post_json = {"url":$_url, "success_text":"添加成功", "fail_text":"添加失败", "tips_box":"tips_submit"};
		_oemarryAjaxPost($post_json);

	});


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