<div class="main f_r">
	<div class="uc_title m_10">
		<label class="current"><span>收藏夹</span></label>
	</div>

	<div class="box">
		<div class="title">
			<b class="gray">按分类查找：</b>
			<a href="{url:/ucenter/favorite}" id="catarea">全部（<label id='favoriteSum'></label>）</a>
			{set:$favoriteSum = 0}
			{foreach:items=Api::run('getUcenterFavoriteByCatid',array('#user_id#',$this->user['user_id']))}
			{set:$favoriteSum+=$item['num']}
			<a href="{url:/ucenter/favorite/cat_id/$item[id]}" id="catarea{$item['id']}">{$item['name']}（{$item['num']}）</a>
			{/foreach}
		</div>
	</div>

	<table class="border_table" width="100%" cellpadding="0" cellspacing="0">
		<colgroup>
			<col />
			<col width='120px' />
			<col width='100px' />
			<col width='100px' />
		</colgroup>

		<thead>
			<tr>
				<td align="center">商品名称</td>
				<td align="center">收藏时间</td>
				<td align="center">价格</td>
				<td align="center">操作</td>
			</tr>
		</thead>

		<tbody>
			{set:$favoriteObj = Api::run('getFavorite',$this->user['user_id'],IReq::get('cat_id'))}
			{foreach:items=$favoriteObj->find()}
			<tr>
				<td>
					<dl>
						<dt><a href="{url:/site/products/id/$item['goods_id']}"><img src="{url:/pic/thumb/img/$item['img']/w/88/h/88}" width="88px" height="88px" alt="{$item['name']}" /></a></dt>
						<dd><a class="blue" href="{url:/site/products/id/$item['goods_id']}">{$item['name']}</a></dd>

						<input type='hidden' name='goods_id[]' value='{$item['goods_id']}' />
						<dd>库存：{$item['store_nums']}</dd>

						<dd id='summary_show_{$item['id']}'>{$item['summary']}</dd>
						<a class="blue" href='javascript:edit_summary({$item['id']});'>+更新备注</a>
					</dl>
				</td>

				<td>{$item['time']}</td>
				<td><span class='red'>￥{$item['sell_price']}</span></td>
				<td>
					<label class="btn_gray_s"><input type="button" value="加购物车" onclick="joinCart_list({$item['goods_id']});" /></span></label><br />
					<label class="btn_gray_s"><input type="button" value="取消收藏" onclick="delModel({link:'{url:/ucenter/favorite_del/id/$item[id]}',msg:'是否取消收藏？'});" /></span></label>
				</td>
			</tr>
			{/foreach}
		</tbody>
	</table>
</div>

<script type='text/javascript'>
//修改备注信息
function edit_summary(idVal)
{
	art.dialog.prompt('修改备注信息',function(summary)
	{
		if(!summary)
		{
			alert('请填写备注信息');
			return;
		}

		$.getJSON("{url:/ucenter/edit_summary}",{"id":idVal,"summary":summary},function(result){
			if(result.isError == false)
			{
				$('#summary_show_'+idVal).html(summary);
				return;
			}
			else
			{
				alert(result.message);
			}
		});
	});
}

//统计总数
$('#favoriteSum').html('{$favoriteSum}');
$("#catarea{echo:IFilter::act(IReq::get('cat_id'))}").addClass('orange');
</script>
