<{import 
	file="cart/header.html"
	title="购物车"  
	css="public,cart"
}>
<div class="main_bar" style="padding:20px 0 0 0;">
	<div class="main">  
		<div class="cm_zd">
			<div class="zd m0"><input type="checkbox" name="cartid[]" class="checked_cartid_all" /></div>
			<div class="zd m1">商品名</div>
			<div class="zd m2">单价</div>
			<div class="zd m3">数量</div>
			<div class="zd m4">小计(元)</div> 
			<div class="zd m5">操作</div> 
		</div>
	<form action="<{$__URI__}>cart/settle" method="post" name="post_cart" id="post_cart"> 
		<div class="cart_box"> 
		<{uqcms m="cart" v="cart" c="cart_list:id=smarty.get.id"}>
		<{if $cart.list}>
			<div class="cart_list">
				<{foreach item=i from=$cart.list}> 
					<div class="spbox">  
						<div class="name">
							<em><input type="checkbox" name="spcartid[]" class="checked_cartid_shop"/></em>
							<i class="sp_icon"></i>
							<a href="<{$__URI__}>shop/<{$i.id}><{$__HTML__}>" target="_blank"><{$i.name}></a>
						</div>
					<{foreach item=ii from=$i.goods}> 
						<{if $ii.goods_status}>
							<div class="gsbox cart_detail_<{$ii.cartid}>">
								<div class="cart_id">
									<input type="checkbox" name="cartid[]" value="<{$ii.cartid}>" class="checked_cartid"<{if $ii.cartid == $smarty.get.cartid}> checked="checked"<{/if}>/>
								</div>
								<div class="cart_ttl"> 
									<div class="images">
										<a href="<{$__URI__}>goods/<{$ii.gid}><{$__HTML__}>" target="_blank">
											<img src="<{$__IMG__}><{$ii.images|img_size:120x120}>" width="70"/>
										</a>
									</div>
									<div class="ttl">
										<div class="sttl">
											<a href="<{$__URI__}>goods/<{$ii.gid}><{$__HTML__}>" target="_blank" class="gttl"><{$ii.title}></a>
										</div>
										<div class="sku">
											<{if $ii.sku_name}> 
												<{foreach item=iii from=$ii.sku_name}>
													 <span style="color:#999;"><{$iii.0}>：<{$iii.1}> &nbsp;&nbsp;</span>
												<{/foreach}>
											<{/if}>
										</div>
									</div>
								</div> 
								<div class="cart_price">
									<p><span><{$ii.price}></span><{if $ii.act_status}><a class="cuxiao">促</a><{/if}></p>
									<s><{$ii.market_price}></s>
								</div>
								<div class="cart_num_box">
									<div class="cssCenter">
										<a href="javascript:;" class="cart_minus" cartid="<{$ii.cartid}>">-</a>
										<input type="text" id="cart_num_<{$ii.cartid}>" size="1" value="<{$ii.buy_num}>" autoComplete="off" class="num" cartid="<{$ii.cart_id}>"/>
										<a href="javascript:;" class="cart_plus" cartid="<{$ii.cartid}>" data-buy-limit="<{$ii.limit_num}>" data-stock="<{$ii.stock}>">+</a>
									</div>
								</div>
								
								<div class="cart_total_price">¥ <span></span></div>
								<a href="javascript:;" cartid="<{$ii.cartid}>" class="cart_del del">删除</a>
							</div>
								
						<{else}>
							<div class="gsbox cart_detail_<{$ii.cartid}>" style="background:#f9f9f9;">
								<div class="cart_id"><input type="checkbox" name="cartid[]" value="<{$ii.cartid}>" class="ckbox_cartid"  disabled="disabled"/></div>  
								<div class="cart_ttl"> 
									<div class="images">
										<a href="<{$__URI__}>goods/<{$ii.gid}><{$__HTML__}>" target="_blank">
											<img src="<{$__IMG__}><{$ii.images|img_size:120x120}>" width="70"/>
										</a>
									</div>
									<div class="ttl">
										<div class="sttl">
											<a href="<{$__URI__}>goods/<{$ii.gid}><{$__HTML__}>" target="_blank" class="gttl"><{$ii.title}></a>
										</div> 
									</div>
								</div> 
								<div class="gs_remove">
									<a href="javascript:;" cartid="<{$ii.cartid}>" class="cart_del del_no">移除</a> 
									<span>该产品已经实效</span>
								</div> 
							</div> 
						<{/if}>
					<{/foreach}> 
					</div>
				<{/foreach}>
			</div>
			<!--购物总计-->
			<div class="cart_pay">
				<div class="lft"><a href="<{$__URI__}>" class="gobuy">继续购物</a></div>
				<div class="rit"> 
					<div class="total" id='total_num'>共计：<span></span>件</div> 
					<div class="total" id='total_price'>合计：<span>0.00</span> 元</div>
					<div class="total postage">(不含邮费)</div>
					<input type="submit" class="gopay" value="去结算" disabled="disabled"/>
				</div> 
			</div>
		<{else}>
			<div class="cart_null">
				<div class="cnull_center">
					<div class="l"><img src="<{$__PUBLIC__}>images/cart_null.png"/></div>
					<div class="r">
						<span>购物车内暂时没有商品</span><br>
						<a href="<{$__URI__}>">现在就去购物 >></a>	
					</div> 
				</div>
			</div> 
		<{/if}> 
		</div>
	</form>
	</div>
</div>
<{import file="footer.html"}> 
<script type="text/javascript" src="<{$__APP__}>public/js/cart.js?v=<{$js_version}>"></script>
<script type="text/javascript">
$(function(){
	$(document).on("click", "input.gopay", function(){ 
		var cartid = [];
		$("input.checked_cartid:checked").each(function(i,k){ 
			cartid.push($(k).val());
		});
		if(cartid.length <= 0){
			$.alert('没有选择商品'); return false;
		}
		<{if $UQCMS.order_settle_login}>		// 检测是否登录 
			$.ajax({
				type:'post',
				url :URI+'ajax/check_login', 
				async:false,
				success:function(result){  
					data = jQuery.parseJSON(result); 
					if(data.error == '4'){ 
						sys_login(function(){ 
							create_settle(cartid); 
						});
					}else{
						create_settle(cartid); 
					}
				} 
			});
			return false; 
		<{else}>
			create_settle(cartid); 
		<{/if}> 
	}); 
	
	function create_settle(chid){
		$.post(URI+'cart/create_settle', {cartid:chid}, function(result2){
			data2 = jQuery.parseJSON(result2);
			if(data2.error == '0'){ 
				location.href=URI+"cart/settle";
			}else{
				$.alert(data2.msg);
			}
		});		
	}   
});
</script>