<{import file="common.html" title="收货地址"}>  
<style type="text/css">
body{ background:#f8f8f8; } 
.addBox{ width:100%; margin:0; float:left;}  
.addConC{ width:100%; padding:0; float:left;}
.addCon{ background:#fff; margin-bottom:10px; float:left;} 
.addCon:last-child{ margin-bottom:0; }
.addr_info{ width:100%; float:left; }
.addCon .name{ width:100%; padding:15px 0 5px 0; float:left;}
.addCon .name span.left{ width:80px; padding:0 0 0 10px; font-size:16px; color:#333; float:left; }
.addCon .name span.right{ font-size:16px; color:#333; float:left; }
.addCon .mobile{ width:100%; font-size:0.95rem; color:#333; padding:10px 0 5px; line-height:22px; float:left;}
.addCon .con{width:100%; color:#888; padding:2px 0 12px 0; float:left;} 
.addCon .con p{ padding:0 10px; font-size:0.9rem; color:#666; line-height:22px; }

.addCon .edit{ width:100%; border-top:1px solid #eee; padding:10px 0; float:left;}
.addCon .edit .set_default{ padding:0 0 0 10px; float:left; } 
.addCon .edit .set_default label{ color:#888;}
.addCon .edit .set_default label input{ margin:0 0.7rem 0 0; float:left; }
.addCon .edit .set_default label em{ margin-top:0.2rem; font-size:0.9rem; float:left; }
.addCon .edit .set_addr{ padding:0 5px 0 0; float:right; }
.addCon .edit .set_addr a{ margin:0 5px; color:#666; font-size:0.9rem; } 
.addCon .edit .set_addr span{ padding:0 5px; color:#999999; } 
</style>
<body>
<div class="cnav">
	<a class="back" <{if $smarty.get.cart}>href="?m=cart&a=settle"<{/if}>></a>地址列表<a href="javascript:;" class="thome">主页</a>
</div>
<div class="addConC">
	<{uqcms m="address" v="addr" c="get_all"}>
	<{if $addr}> 
		<{foreach item=i from=$addr}> 
			<div class="addCon">
				<div class="addr_info" data-id="<{$i.id}>">
					<div class="name">
						<span class="left"><{$i.name}></span>
						<span class="right"><{$i.mobile}></span>
					</div> 
					<div class="con"><p><{$i.area}>, <{$i.address}> </p></div> 
				</div>
				<div class="edit">
					<div class="set_default">
						<{if $i.is_default}>
							<label>
								<input type="radio" name="default" checked="checked" data-id="<{$i.id}>"/>
								<em>默认地址</em>
							</label>
						<{else}>
							<label>
								<input type="radio" name="default" data-id="<{$i.id}>"/>
								<em>设为默认</em>
							</label>
						<{/if}>
					</div>
					<div class="set_addr">
						<a href="?m=address&a=update<{if $smarty.get.cart == '1'}>&cart=1<{/if}>&id=<{$i.id}>">编辑</a> 
						<a href="javascript:;" class="addr_del" data-id="<{$i.id}>">删除</a>
					</div>
				</div> 
			</div> 
		<{/foreach}> 
	<{/if}> 
</div> 
<div class="sbutton"><p><a href="?m=address&a=add<{if $smarty.get.cart == '1'}>&cart=1<{/if}>" id="add_address">新增收货地址</a></p></div>

<{include file="default/footer.html"}>
<script type="text/javascript">
$(function(){
	<{if $smarty.get.cart == '1'}>
		$(document).on('click','.addr_info',function(){ 
			addr_id = $(this).attr('data-id');
			$.get('?m=cart&a=address_ch&id='+addr_id, function(data){ 
				if(data == '1'){
					location.href="?m=cart&a=settle";
				}else{
					$.alert('操作失败');
				}
			}); 
		});
	<{/if}>
	$(document).on("click",".addr_del",function(){ 
		$this = $(this);
		var id = $this.attr('data-id');
		$.post('member.php?m=address&a=del',{id:id},function(result){
			var data = jQuery.parseJSON(result);  
			if(data.error == '0'){ 
				$.alert('删除成功');	
				location.reload();
			}else{
				$.alert(data.msg);
			}
		});
	});
	// 设为默认
	$(".set_default input").click(function(){
		$this = $(this);
		var id = $(this).attr('data-id');
		$.post('member.php?m=address&a=set_default',{id:id},function(result){
			var data = jQuery.parseJSON(result); 
			if(data.error == '0'){
				$.alert('设置成功');  
			}else{
				$.alert(data.msg);
			}
		});
	});
});
</script>