<{import file="common.html" title="地址编辑"}>
<style type="text/css"> 
body{ background:#f8f8f8; } 
.addCon{ width:100%; background:#fff; float:left; }
table.etable{ margin:0; }
table.etable tr td{ border-bottom:1px solid #efefef; }
table.etable tr td:first-child{ text-align:left; padding-left:10px; font-size:14px; color:#333; }
table.etable tr td em{ font-style:inherit; padding:10px 0 0 10px; color:#FF0000; float:left;}
table.etable tr td input[type=text]{ width:100%; border:none; padding:10px 0; color:#888; float:left;} 
</style>
<body>
<div class="cnav">
	<a class="back">&nbsp;</a>编辑地址<a href="javascript:;" class="thome">主页</a>
</div>
<{uqcms m="address" v="row" c="get_one:smarty.get.id"}>
<div class="addCon">
	<table width="100%" class="etable">
		<tr>
			<td width="80">收货人 </td>
			<td><input type="text" name="name" id="recive_name" size="38" value="<{$row.name}>" placeholder="收件人姓名"/></td>
		</tr>
		<tr>
			<td>手机号码 </td> 
			<td><input type="text" name="mobile" id="recive_mobile" size="38" value="<{$row.mobile}>" placeholder="收件人联系电话"/></td>
		</tr>
		<tr>
			<td>选择地区 </td> 
			<td><div class="area_box"></div></td>
		</tr>
		<tr>
			<td>详细地址 </td>
			<td><input type="text" name=""  id="recive_address" size="38" value="<{$row.address}>" placeholder="收件人详细地址"/></td>
		</tr>
		<tr>
			<td>区域邮编 </td>
			<td><input type="text" name="" id="recive_zip" size="38" value="<{$row.zip}>" placeholder="收件人邮编（选填）"/></td>
		</tr>
	</table> 
</div>
<div class="sbutton"><p><input type="submit" id="submit"  name="is_default" class="submit" value="保存"/></p></div>
<{import file="footer.html"}>
<script type="text/javascript" src="<{$__APP__}>public/js/area.js"></script>
<script type="text/javascript">
$(function(){
	<{if $row.prov && $row.city && $row.dist}>
		$(".area_box").area({
			'title':'<{$row.area}>',
			'prov':<{$row.prov}>,
			'city':<{$row.city}>,
			'dist':<{$row.dist}>
		});
	<{else}>
		$(".area_box").area();
	<{/if}>
	
	$(".submit").click(function(){
		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(); 
		var is_default = $("#recive_is_default").is(':checked')?'1':'0'; 
		$.post('member.php?m=address&a=edit_save',{<{if $smarty.get.id}>id:<{$smarty.get.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.cart == '1'}>
					$.get('?m=address&a=address_ch&id='+data.id, function(data){ 
						if(data == '1'){
							$.alert('保存成功', function(){
								location.href="?m=cart&a=settle";
							}); 
						}else{
							$.alert('选中跳转失败');
						}
					}); 
				<{else}>
					$.alert('保存成功',function(){
						location.href="?m=address";
					});
					
				<{/if}>
			}else{
				$.alert(data.msg);
			} 
		});	
		
	});
}); 
</script>