<{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%; padding:0.1rem 0; cursor:pointer; float:left; }
.addCon .name{ width:100%; padding:0.2rem 0; float:left;}
.addCon .name span.left{ width:2rem; padding:0 0 0 0.2rem; font-size:0.3rem; color:#333; float:left; }
.addCon .name span.right{ font-size:0.3rem; color:#333; float:left; }
.addCon .mobile{ width:100%; font-size:0.3rem; color:#333; padding:0.2rem 0 0.1rem; line-height:0.2rem; float:left;}
.addCon .con{ width:100%; color:#888; padding:0 0 0.2rem 0; float:left;} 
.addCon .con p{ padding:0 0.2rem; font-size:0.28rem; color:#666; line-height:0.44rem; }

.addCon .edit{ width:100%; border-top:1px solid #eee; padding:0.2rem 0; float:left;}
.addCon .edit .set_default{ padding:0 0 0 0.2rem; float:left; } 
.addCon .edit .set_default label{ color:#888;}
.addCon .edit .set_default label input{ margin:0.05rem 0.1rem 0 0; float:left; }
.addCon .edit .set_default label em{ font-size:0.3rem; margin:0.05rem 0 0 0; float:left; }
.addCon .edit .set_addr{ padding:0.01rem 0.2rem 0 0; float:right; }
.addCon .edit .set_addr a{ margin:0 0.2rem; color:#666; font-size:0.3rem; float:left; } 
.addCon .edit .set_addr span{ padding:0 0.2rem; color:#999; } 
</style>
<body>
<div class="cnav">
	<a class="back" href="<{if $smarty.get.cart}><{$__WAP__}>cart/settle"<{else}><{$__WAP__}>member/index<{/if}>"></a>
	地址列表
	<a href="javascript:;" class="thome">主页</a>
</div>
<div class="addConC olist">
	<{uqcms m="address" v="addr" c="get_all::page=smarty.get.page&page_type=scroll"}>
	<{if $addr}> 
		<{foreach item=i from=$addr}> 
			<div class="addCon obox">
				<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="<{$__WAP__}>address/edit?id=<{$i.id}><{if $smarty.get.cart == '1'}>&cart=1<{/if}>">编辑</a> 
						<a href="javascript:;" class="addr_del" data-id="<{$i.id}>">删除</a>
					</div>
				</div> 
			</div> 
		<{/foreach}> 
		<{$data.page}>
	<{/if}> 
	<div class="sbutton"><a href="<{$__WAP__}>address/edit<{if $smarty.get.cart == '1'}>?cart=1<{/if}>" id="add_address">新增收货地址</a></div>
</div>
<{include file="default/footer.html"}>
<script type="text/javascript"> 
scrollLoad(".olist", ".obox"); 
$(function(){ 
	<{if $smarty.get.cart == '1'}>	// 选中操作 
		$(document).on('click','.addr_info',function(){ 
			addr_id = $(this).attr('data-id');
			$.post(URI+'cart/address_ch', {id:addr_id}, function(result){
				data = jQuery.parseJSON(result); 
				if(data.error == '0'){
					location.href=WAP+"cart/settle";
				}else{
					$.alert(data.msg);
				}
			});
		});
	<{/if}> 
	// 设为默认
	$(".set_default input").click(function(){
		$this = $(this);
		var id = $(this).attr('data-id');
		$.post(URI+'address/set_default', {id:id}, function(result){
			var data = jQuery.parseJSON(result); 
			if(data.error == '0'){
				$.alert('设置成功');  
			}else{
				$.alert(data.msg);
			}
		});
	});
});
// 删除地址
$(document).on("click","a.addr_del",function(){ 
	if (!confirm("确认要删除？")) { 
		if(window.event){
			window.event.returnValue = false;
		}else{
			event.preventDefault();	//for firefox
		}
	}else{
		$this = $(this);
		var id = $this.attr('data-id');
		$.post(URI+'address/del', {id:id}, function(result){
			data = jQuery.parseJSON(result);  
			if(data.error == '0'){ 
				$.alert('删除成功', function(){
					location.reload();
				});
			}else{
				alert(data.msg);
			}
		});	
	}
});

</script>