<{import 
	file="common.html" 
	title="购物车 
"}> 
<link rel="stylesheet" href="<{$__APP__}>public/css/cart.css?v=<{$js_version}>"> 
<div class="cnav">
	<a class="back">&nbsp;</a>购物车<a href="javascript:;" class="thome">主页</a>	
</div>
<form action="<{$__WAP__}>cart/settle" method="post">
<{uqcms m="cart" v="cart" c="cart_list:id=smarty.get.id"}> 
<{if $cart.list}>
<div class="cart">  
	<{foreach item=i from=$cart.list}>
		<div class="sp_cart spbox">
			<div class="spname">
				<input type="checkbox" name="spcartid[]" value="<{$ii.cartid}>" class="ckbox_cartid checked_cartid_shop"/>
				<em></em><a href="<{$__WAP__}>shop/<{$i.id}><{$__HTML__}>" target="_blank"><{$i.name}></a> 
			</div> 
			<div class="cgbox">
				<{foreach item=ii from=$i.goods}>
					<{if $ii.goods_status}>
						<div class="cgone gsbox"> 
							<div class="cart_img">  
								<div class="ckbox">
									<input type="checkbox" name="cartid[]" class="ckbox_cartid checked_cartid" value="<{$ii.cartid}>" />
								</div>
								<div class="img"><a href="<{$__WAP__}>goods/<{$ii.gid}><{$__HTML__}>">
									<img src="<{$__IMG__}><{$ii.images|img_size:200x200}>"/></a>
								</div> 
							</div>
							<div class="cart_ttl">
								<div class="sttl"><a href="<{$__WAP__}>goods/<{$ii.gid}><{$__HTML__}>" class="gttl"><{$ii.title}></a></div>
								<{if $ii.sku_name}>
									<div class="sku">
										<{foreach item=s from=$ii.sku_name}>
											 <span><{$s.0}>:<{$s.1}></span>
										<{/foreach}> 
									</div>
								<{/if}> 
								<div class="price price_<{$ii.cartid}>">
									<div class="pr uq_color">¥ <i class="uq_color"><{$ii.price}></i></div> 
									<div class="num"> 
										<div class="numBox num_<{$ii.cartid}>">
											<a href="javascript:;" class="cart_minus" data-cartid="<{$ii.cartid}>">-</a>
											<input type="text" id="cart_num_<{$ii.cartid}>" class="cnum"  size="1" value="<{$ii.buy_num}>" autoComplete="off" cartid="<{$ii.cart_id}>"/>
											<a href="javascript:;" class="cart_plus" data-cartid="<{$ii.cartid}>" data-buy-limit="<{$ii.limit_num}>" data-stock="<{$ii.stock}>">+</a>
										</div>
										<div class="del"> 
											<a href="javascript:;" class="delCart" data-cartid="<{$ii.cartid}>">删除</a> 
										</div>	
									</div>	
								</div> 
								
							</div> 
							
						</div> 
					<{else}>
						<div class="cgone cart_detail_<{$ii.cartid}>" style="background:#f9f9f9;"> 
							<div class="cart_img">  
								<div class="ckbox">
									<input type="checkbox" name="cartid[]" value="<{$ii.cartid}>" class="ckbox_cartid" <{if $ii.goods_status}> checked="checked"<{else}> disabled="disabled"<{/if}>/>
								</div>
								<div class="img"><img src="<{$__IMG__}><{$ii.images|img_size:200x200}>"/></div> 
							</div> 
							<div class="cart_goods_invalid">
								<span>该产品已经实效</span> 
								<a href="javascript:;" class="delCart" data-cartid="<{$ii.cartid}>">删除</a>
							</div>
						</div>
					<{/if}>
				<{/foreach}> 
			</div>
		</div>
	<{/foreach}> 
</div> 
<!--去结算--> 
<div class="cart_pay">
	<div class="lft"> 
		<label>
			<input type="checkbox" name="cartid[]" class="ckbox_cartid checked_cartid_all" value="<{$ii.cartid}>" />
			<span>全选</span>
		</label>
	</div>
	<div class="rit">
		<div class="goPayPr">
			<div class="total_price" id="total_price">合计 <i class="uq_color"><{$cart.total_price}></i> 元</div>
			<div class="total_express postage">(不含邮费)</div> 	
		</div>
		<div class="goPayBox"><input value="去结算" name="submit" type="submit" class="gopay uq_bg" disabled="disabled"/></div>
	</div> 
</div> 
<{else}>
	<div class="nomsg"><span>购物车没有商品</span></div> 
<{/if}>
<form>
<{import file="btm_tab.html"}>
<{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[name='cartid[]']:checked").each(function(i,k){
			aaa = $(k).val(); 
			cartid.push(aaa);
		});
		if(cartid.length <= 0){
			$.alert('没有选择商品'); return false;
		} 
		$.ajax({
			type:'post',
			url :URI+'ajax/check_login',
			datatype:'text',
			success:function(result){ 
				data = jQuery.parseJSON(result); 
				if(data.error == '4'){ 
					location.href=WAP+"member/login?returnUrl=<{$UQCMS.request_url}>"; 
				}else{
					create_settle(cartid); 
				}
			}
		});
		return false;
	});
	
	function create_settle(chid){
		if(chid != ''){
			$.post(URI+'cart/create_settle', {cartid:chid}, function(result2){
				data2 = jQuery.parseJSON(result2);
				if(data2.error == '0'){ 
					location.href=WAP+"cart/settle";
				}else{
					$.alert(data2.msg);
				}
			});	
			return false;
		}else{
			$.alert('请选择产品');
		} 
	} 
}); 
</script>