<div class="oe_widget_center">
  <div class="oe_edit_address">
    <h3 class="oe_f_title">编辑收货地址<span> 带<font color="red">*</font>号必填</span></h3>
    <input type="hidden" name="id" id="id" value="<!--{$id}-->" />
    <table class="oe_table_info">
      <tr>
        <th align="right" width="25%">收货人姓名：<font color="red">*</font></th>
        <td><input type="text" name="contname" id="contname" class="input-250" value="<!--{$address.contname}-->" /></td>
      </tr>
      <tr>
        <th align="right"><font color="red">*</font>所在地区：</th>
        <td>
		  <!--{area type='select' name='area' depth='1' child='1' text='=请选择=' value=$address.area1}--> 
          <span id="json_area2"> 
          <!--{if $address.area1 > 0}--> 
          <!--{area type='select' name='area' depth='2' child='1' text='=请选择=' parentid=$address.area1 value=$address.area2}--> 
          <!--{else}-->
          <select name="area2" id="area2">
            <option value="">=请选择=</option>
          </select>
          <!--{/if}--> 
          </span> <span id="json_area3"> 
          <!--{if $address.area2 > 0}--> 
          <!--{area type='select' name='area' depth='3' child='1' text='=请选择=' parentid=$address.area2 value=$address.area3}--> 
          <!--{else}-->
          <select name="area3" id="area3">
            <option value="">=请选择=</option>
          </select>
          <!--{/if}--> 
          </span>
		</td>
      </tr>
      <tr>
        <th align="right"><font color="red">*</font>街道/地址：</th>
        <td>
		  <input type="text" name="street" id="street" class="input-250" value="<!--{$address.street}-->" />
          （不需要填写省/市）
		</td>
      </tr>
      <tr>
        <th align="right">邮政编码：</th>
        <td><input type="text" name="zipcode" id="zipcode" class="input-150" value="<!--{$address.zipcode}-->" /></td>
      </tr>
      <tr>
        <th align="right"><font color="red">*</font>联系电话：</th>
        <td>
		  <input type="text" name="contphone" id="contphone" class="input-150" value="<!--{$address.contphone}-->" />
          （手机或固定电话）
		</td>
      </tr>
      <tr>
        <th></th>
        <td><input type="button" id="btn_post" class="submit_btn1" value="编辑保存" /></td>
      </tr>
    </table>
  </div>
</div>
<script type="text/javascript">
	$(function(){
		$("#btn_post").bind("click", function(){
			if ($("#contname").val().length == 0) {
				ToastShow("请填写收货人姓名");
				return false;
			}
			if ($("#area1").find("option:selected").val() < 1) {
				ToastShow("请选择所在地区");
				return false;
			}
			if ($("#area2").find("option:selected").val() < 1) {
				ToastShow("请选择所在地区");
				return false;
			}
			if ($("#street").val().length == 0) {
				ToastShow("请填写街道/地址");
				return false;
			}
			if ($("#contphone").val().length == 0) {
				ToastShow("请填写联系电话");
				return false;
			}
			$id = $("#id").val();
			$contname = $("#contname").val();
			$contphone = $("#contphone").val();
			$area1 = $("#area1").find("option:selected").val();
			$area2 = $("#area2").find("option:selected").val();
			$area3 = $("#area3").find("option:selected").val();
			$street = $("#street").val();
			$zipcode = $("#zipcode").val();

			$data = {c:"order", a:"saveeditaddress", id:$id, contname:$contname, contphone:$contphone, area1:$area1, area2:$area2, area3:$area3, street:$street, zipcode:$zipcode };
			$.ajax({
				type: "POST",
				url: _ROOT_PATH + "index.php",
				cache: false,
				data: $data,
				dataType: "json",
				success: function($data) {
					$json = eval($data);
					$response = $json.response;
					$result = $json.result;
					if ($response == "1") {
						//ToastShow("保存成功");
						$("[f='data-consignee-"+$id+"']").html($contname +"  收  ("+$contphone+")");
						$("[f='data-address-"+$id+"']").html($result);
						$('#edit_address').remove();
					}
					else {
						if ($result.length > 0) {
							ToastShow($result);
						}
						else {
							ToastShow("保存失败");
						}

					}

				},
				error: function() {

					ToastShow("保存失败，请检查网络！");
				}
			});
		});
	});
</script> 