<{uqcms m="address" v="row" c="get_one:id=smarty.get.id"}>
<style type="text/css">
span.area_name{ width:260px; padding-top:8px; padding-bottom:8px; float:left; }
</style>
<table class="etable">
	<tr>
		<td width="140"><span>所在地区：</span></td>
		<td><div class="area_box"></div></td>
	</tr>
	<tr>
		<td><span>详细地址：</span></td>
		<td><input type="text" name="address"  id="recive_address" size="44" value="<{$row.address}>" placeholder="收件人详细地址"/></td>
	</tr>
	<tr>
		<td width="90"><span>收货人姓名：</span></td>
		<td><input type="text" name="name" id="recive_name" size="44" value="<{$row.name}>" placeholder="收件人姓名"/></td>
	</tr>
	<tr>
		<td><span>手机号码：</span></td> 
		<td><input type="text" name="mobile" id="recive_mobile" size="44" value="<{$row.mobile}>" placeholder="收件人联系电话"/></td>
	</tr>
	<tr>
		<td><span>邮政编码：</span></td>
		<td><input type="text" name="zip" id="recive_zip" size="44" value="<{$row.zip}>" placeholder="收件人邮编"/></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<label>
				<input type="checkbox" id="recive_is_default" <{if $row.is_default == '1'}>checked="checked"<{/if}> name="is_default" value="1"/>
				<span>设置为默认收货地址</span>
			</label>
		</td>
	</tr> 
</table>
<script type="text/javascript" src="<{$__PUBLIC__}>js/area.js"></script>
<script type="text/javascript"> 
	$(".area_box").area(<{if $row.prov != ''}>{'prov':'<{$row.prov}>', 'city':'<{$row.city}>', 'dist':'<{$row.dist}>'}<{/if}>); 
	function ajax_submit(){ 
		var name = $("#recive_name").val(); 		
		if(name == ''){
			$.alert('姓名不能为空！'); return false; 
		}
		var mobile = $("#recive_mobile").val();		
		if(mobile == ''){ 	
			$.alert('电话不能为空！'); return false; 
		}
		var prov = $("#prov").val();		
		if(dist == '0')	{ 	
			$.alert('选择省份！'); return false; 
		} 
		var city = $("#city").val();
		if(city == '0')	{ 	
			$.alert('选择市区！'); return false; 
		} 
		var dist = $("#dist").val();
		if(dist == '0')	{ 	
			$.alert('选择县级！'); return false; 
		} 
		var address = $("#recive_address").val();
		if(address == ''){ 	
			$.alert('地址不能为空！'); return false; 
		} 
		var zip = $("#recive_zip").val(); 
		if(zip){
			if(!/^[0-9][0-9]{5}$/.test(zip)){ 
				$.alert('邮编格式不正确！'); return false; 
			}
		} 
		var is_default = $("#recive_is_default").is(':checked')?'1':'0'; 
		$.post(URI+'address/edit_save',{<{if $row.id}>id:<{$row.id}>,<{/if}>name:name, mobile:mobile, prov:prov, city:city, dist:dist, address:address, zip:zip, is_default:is_default}, function(result){ 
			var data = jQuery.parseJSON(result); 
			if(data.error =='0'){
				<{if $smarty.get.type == '1'}>
					settle_edit_address(data, <{if $smarty.get.id}>1<{else}>0<{/if}>);			// 执行完关闭
					ajax_close();
				<{else}> 
					$.alert('保存成功', function(){
						location.reload(); 
					});
				<{/if}>
			}else{
				$.alert(data.msg);
			} 
		}); 
	}
</script>