<link type="text/css" rel="stylesheet" href="{url:#css/ucenter.css}" />
<div class="container list ">
	<div class="row-5 blank">
	<div class="col-1">
	{widget:name=sub_navs action=ucsidebar sidebar=$sidebar act=$actionId}
	</div>
	<div class="col-4">
			<h1 class="title"><span>我的积分：</span></h1>
			<div class="">当前积分：<b class="red f18">{$customer['point']|'0'}</b></div>
			<div class=" tab">
				<ul class="tab-head">
					<li>积分记录<i></i></li>
					<li>积分换券<i></i></li>
				</ul>
				<div class="tab-body"  style="padding: 20px 10px;">
					<div class="">
					<table class="table table-list">
						<tr>
							<th width="180">时间</th> <th width="120">积分</th><th>当前积分</th><th >备注</th>
						</tr>
						{query:name=point_log where=user_id eq $user[id] order=id desc page=1 id=$obj}
						<tr {if:$key%2==1}class="even"{/if}>
							<td>{$item['create_time']}</td><td>{$item['value']}</td><td>{$item['point']}</td><td>{$item['note']}</td>
						</tr>
						{/query}
					</table>
					<div class="page-nav">{echo:$obj->pagebar()}</div>
					</div>
					<div class='p10'>
						<table class="table table-list">
						{query:name=voucher_template where= point gt 0}
						<tr><td><label><input type="radio" name="id" value="{$item['id']}"><b>{$item['name']}（需{$item['point']}积分）</b></label></td><td>订单需满足{$currency_symbol}{$item['money']} 才可使用</td><td> 自兑换之日起{$item['valid_days']}天内有效</td></tr>
						{/query}
						</table>
						<div class='mt20 tc'><a href="javascript:;" id="point_exchange" class="btn btn-main">兑换代金券</a></div>
					</div>
				</div>
		</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$("#point_exchange").on('click',function(){
	var id = $("input[name='id']:checked").val();
	$.post("{url:/ucenter/point_exchange}",{id:id},function(data){
		if(data['status']=='success'){
			alert('代金券兑换成功！');
			location.reload();
		}else{
			alert(data['msg']);
		}
	},'json');
});
</script>
