<{import file="index/header.html" title="收货地址"}>
<style type="text/css"> 
.addtab{ width:100%; border-bottom:none; padding:0 0 12px 0; float:left; }
.addtab a{ border:1px solid #ddd; padding:7px 25px; font-size:12px; border-radius:1px; font-weight:100; background:#f8f8f8; color:#333; float:left; }
a.edit_font{ margin:0 12px 0 0; float:left; }
</style> 
<div class="lbox">
	<div class="addtab"> 
		<a href="javascript:;" onClick="edit_address('添加地址','member.php?m=address&a=edit')" id="add_address">新增收货地址</a>
	</div>
	<table class="ltable">
		<thead>
			<tr>
				<th width="70">姓名</th>
				<th width="110">电话</th>
				<th>地址</th>
				<th width="100">操作</td>
				<th width="80">默认</th>
			</tr>
		</thead> 
		<tbody>
		<{uqcms m="address" v="add" c="get_all"}> 	
		<{if $add}> 	
			<{foreach item=i from=$add}>		
			<tr>
				<td><{$i.name}></td>
				<td><{$i.mobile}></td>
				<td><{$i.area}>, <{$i.address}> </td> 
				<td>
					<a href="javascript:;" class="edit_font" onClick="edit_address('修改地址','member.php?m=address&a=edit&id=<{$i.id}>')">编辑</a>
					<a href="javascript:;" class="addr_del" data-id="<{$i.id}>">删除</a>
				</td>
				<td>
					<div class="dft_box">
						<{if $i.is_default == '1'}>
							<a style="color:#FF0000;">默认</a>
						<{else}>
							<a href="javascript:;" class="set_default" data-id="<{$i.id}>">设为默认</a>
						<{/if}>
					</div> 
				</td> 
			</tr>
			<{/foreach}>
		<{else}>
			<tr><td colspan="5" class="btm"><div class="nomsg"><i></i><span>您还没添加送货地址~</span></div></td></tr> 
		<{/if}>
		</tbody> 
	</table>
</div> 	 
<{include file="index/footer.html"}> 
<script type="text/javascript"> 
function edit_address(name,url){ 
	ajax_dialog(name,url, 440); 
} 
// 设为默认 
$(document).on("click",".set_default",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('设置成功', function(){
				location.reload();
			});
		}else{
			$.alert(data.msg);
		}
	});
});
// 删除地址
$(document).on("click",".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('member.php?m=address&a=del',{id:id},function(result){
			var data = jQuery.parseJSON(result);  
			if(data.error == '0'){ 
				$.alert('删除成功', function(){
					location.reload();
				});
			}else{
				alert(data.msg);
			}
		});	
	}
});
</script>