<?xml version="1.0"?>
<labeltemplate>
   <label>
    <![CDATA[
	<script type="text/javascript">
	 function removeOnShoppingCart(cartid){ 
	   if (confirm("确定从购物车里删除吗?")) delfromcart(cartid);
	 }
	 function delfromcart(cartid){
	    jQuery.get("/plus/ajaxs.ashx", { a: "delfromcart", cartid:cartid},
			 function(data){
					if (data=="success"){
					 location.href='shoppingcart.aspx';
					}else{
					 alert('删除失败!');
					}
			  });
	 }
	 function addChangeBuyPro(proid,needPrice){
	    var totalPrice=parseFloat(jQuery("#orderTotalPrice").html());
		if (parseFloat(needPrice)>totalPrice){
		  alert('对不起,您的订单金额不足,还差￥'+(needPrice-totalPrice).toFixed(2)+'元!');
		  return false;
		}
		if (jQuery("#chnagebuyproid")[0]){
		  if (jQuery("#chnagebuyproid").val()!=proid){
		    if (confirm('您已挑选过换购品,确认替换吗?')==false) return false;
		  }
		}
	     jQuery.get("/plus/ajaxs.ashx", { a: "addchangebuytocart", proid:proid},
			 function(data){
					if (data=="success"){
					 location.href='?app=shoppingcart';
					}else{
					 alert('添加失败!');
					}
			  });
	 }
	 function removeAllPro(){
	  if (confirm('确定清空购物车里的商品吗?')){
	  removeallprofromcart();
	  }
	 }
	 function removeallprofromcart(){
	   jQuery.get("/plus/ajaxs.ashx", { a: "removeallprofromcart"},
			 function(data){
					if (data=="success"){
					 location.href='?app=shoppingcart';
					}else{
					 alert('删除失败!');
					}
			  });
	 }
	 function changeBar(t,cartid,obj){
	   var num=parseInt(jQuery("#num_"+cartid).val());
	   var ProID=jQuery("#proid_"+cartid).val()
	   if (t=='+'){
	    num++;
	   }else if(t=='o'){
	    num=parseInt(jQuery('#num_'+cartid).val());
	   }else{
	    num--;
	   }
	   if (num<=0){
		 removeOnShoppingCart(cartid);
	   }else{
       jQuery.getScript('/plus/ajaxs.ashx?a=setbuynum&cartid='+cartid+'&num='+num+'&ProID='+ProID,function(){
	         if (data.issuccess=='false')
			   alert('操作失败了!');
			  else if (data.issuccess=='failnum')
			   alert('库存量不足,最多还能购买'+data.amount+'件!');
			  else if (data.issuccess=='failmaxnum')
			   alert('本商品限定每人最多只能购买'+data.amount+'件!');
			  else if (data.issuccess=='failminnum'){
			    if (confirm('本商品限定每人最少需要购买'+data.amount+'件,您要取消本次购买吗?')){
				removeOnShoppingCart(cartid);
				}
			   }
			  else if (data.issuccess=='reload'){
			   location.href='shoppingcart.aspx';
			  }
			  else if(data.issuccess=='true'){
			   jQuery("#num_"+cartid).val(num);
			   jQuery("#subtotal_"+cartid).html(parseFloat(num*parseFloat(jQuery('#price_'+cartid).html())).toFixed(2));
			   jQuery("#changescoresubtotal_"+cartid).html(parseInt(num*parseInt(jQuery('#changescore_'+cartid).html())));
			   jQuery("#subscore_"+cartid).html(parseInt(num*parseInt(jQuery('#score_'+cartid).val())));
		   
			   var totalPrice=0;
			   var totalChangeScore=0;
			   var priceMarket=0;
			   var score=0;
			   jQuery(".subtotal").each(function(){
				 totalPrice+=parseFloat($(this).html());
			   });
			   jQuery(".changescoresubtotal").each(function(){
				 totalChangeScore+=parseInt($(this).html());
			   });
			   jQuery(".pricemarket").find('span').each(function(){
				 priceMarket+=parseFloat($(this).html())*parseFloat(jQuery("#num_"+$(this).attr("id")).val());
			   });
			   jQuery(".subscore").find('span').each(function(){
				score+=parseInt($(this).html());
			   });
			   jQuery("#orderTotalChangeScore").html(totalChangeScore);
               jQuery("#orderTotalPrice").html(totalPrice.toFixed(2));
               jQuery("#SaveMoney").html((priceMarket-totalPrice).toFixed(2));
			   jQuery("#orderScore").html(score);
			   showCouponMsg=false;  
			   checkCoupon();    //检查优惠券是否可用
			 }
		});	   
	   }
	 }
  	 
$(document).ready(function(){
 showCouponMsg=false;
 checkCoupon(); //检查是否有录入优惠券!
});

	</script>
	<table class='ShoppingCart' cellpadding='1' cellspacing='1' width='100%' id='CartTb'>

 [norecord]
  <tr class='tdbg'>
   <td colspan='7' align="center" height="25">
     您的购物车中没有商品!
   </td>
  </tr>
 [/norecord]
 
 [recordloop]
		   <tr class='tdbg'>
			<td class='align_Left'  style="text-align:center" width="70">
			<img src='{KS:DefaultPic}' onerror="this.src='{KS:ErrDefaultPic}';" width='60' height='50' align='left'/>
			<br/><a href="javascript:removeOnShoppingCart('{KS:CartID}')">删除</a>
			</td>
			<td class='align_Left' style="text-align:left">
			<span><a target='_blank' href='{KS:LinkUrl}' onclick='this.blur();' title="{KS:Title}">{KS:Title}</a>{KS:PromotionsTips}</span>
			{KS:Attribute}
			
			<br/>
			
			数量：<a href='javascript:;' title='减一' onclick="changeBar('-',{KS:CartID},this)" style='margin-right:2px;'><img style='display:inline' src='{M:HomeDir}images/shop/bag_close.gif' border='none' /></a><input type='text' id='num_{KS:CartID}' name='num_{KS:CartID}' maxlength='4' style='text-align:center;width:30px' onKeyDown='if(event.keyCode == 13) event.returnValue = false' value='{KS:Num}' onchange="changeBar('o',{KS:CartID},this)" onkeypress="javascript:return isNumber(event);"/><a href='javascript:;' title='加一' onclick="changeBar('+',{KS:CartID},this)" style='margin-left:2px;'><img style='display:inline' src='{M:HomeDir}images/shop/bag_open.gif' border='none' /></a>
	      <input type="hidden" name="proid_{KS:CartID}" id="proid_{KS:CartID}" value="{KS:ProID}"/>
	      <input type="hidden" name="score_{KS:CartID}" id="score_{KS:CartID}" value="{KS:Score}"/>
	     
		 <div style="display:none">市场价：<span class='pricemarket'>￥<span id="{KS:CartID}">{KS:Price_Market}</span>元</span></div>
			<br/>
			单价：
			<span class='price'>{KS:Price}</span>
			<br/>
			总计：{KS:SubTotal}
			<br/>
			积分：<span class='subscore'><span id="subscore_{KS:CartID}">{KS:SubScore}</span> 分</span>
		   </td>
		  </tr>
		 
[/recordloop]

[changebuyrecord]
 <tr class='tdbg'>
	<td class='align_Left' style="text-align:center" width="70">
			<img src='{KS:DefaultPic}' width='60' height='50' align='left'/>
			<a href="javascript:removeOnShoppingCart('{KS:CartID}')">删除</a>
	</td>
	<td class='align_Left' >
			<a target='_blank' href='{KS:LinkUrl}' onclick='this.blur();'>{KS:Title}</a> {KS:PromotionsTips} </span>
			<br/>数量：<input type='hidden' id='num_{KS:CartID}' name='num_{KS:CartID}' maxlength='4' style='text-align:center;width:30px' value="1"/>
			 <input type="hidden" name="proid_{KS:CartID}" id="proid_{KS:CartID}" value="{KS:ProID}"/> 1
			 <input type="hidden" name="chnagebuyproid" id="chnagebuyproid" value="{KS:ProID}"/>
			  <div style="display:none">市场价：<span class='pricemarket'>￥<span id="{KS:CartID}">{KS:Price_Market}</span>元</span></div>
			<br/>
			价格：<span class='price'>￥<span id="price_{KS:CartID}">{KS:Price}</span></span>
			<br/>总计：<span class='subtotal'>￥<span id="subtotal_{KS:CartID}">{KS:Price}</span></span>
			<br/>
			积分：<span class='subscore'><span id="subscore_{KS:CartID}">{KS:SubScore}</span> 分</span>
	  </td>
</tr>
[/changebuyrecord]

[bundlesalerecord]
  <tr class='tdbg'>
	<td class='align_Left' style="text-align:center" width="70">
	    <img src='{KS:DefaultPic}' width='60' height='50' align='left'/>
		<a href="javascript:removeOnShoppingCart('{KS:CartID}')">删除</a>
	    </td>
		<td class='align_Left' style="text-align:left">
        <span>
		 <font color=#ff6600><strong>{KS:PromotionsTips}</strong></font><br/>
		<a href="{KS:LinkUrl}" target="_blank">{KS:Title}</a></span>
		<br/>
		数量：<input type='hidden' id='num_{KS:CartID}' name='num_{KS:CartID}' maxlength='4' style='text-align:center;width:30px' value="1"/>
	  {KS:Num}
		<div style="display:none">市场价：<span class='pricemarket'>￥<span id="{KS:CartID}">{KS:Price_Market}</span>元</span></div>
		<br/>价格：<span class='price'>￥<span id="price_{KS:CartID}">{KS:Price}</span></span>
	   <br/>总计：<span class='subtotal'>￥<span id="subtotal_{KS:CartID}">{KS:Price}</span></span>
	   <br/>
			积分：<span class='subscore'><span id="subscore_{KS:CartID}">{KS:SubScore}</span> 分</span>
	   </td>
</tr>
[/bundlesalerecord]



 <tr>
    <td class='Tfoot' colspan='2' style='text-align:left;height:30px; font-size:14px;'>
	完成本次交易您可以得到<span class='price'> <span id="orderScore">{KS:OrderScore}</span> </span>分的积分,
	本次总共为您节省了：<span class='saveMoney'>￥<span id="SaveMoney">{KS:OrderSaveMoney}</span>元</span><br /><span style='font-size:14px'><b>商品总金额(不含运费)：<span class='price'>{KS:OrderTotalPrice}</span></b></span>
	<span id="ORDER_COSTS"></span>
	</td>
 </tr>
</table>        

<div style="margin:10px;text-align:left">
<a href="{M:HomeDir}orderinfo.aspx" class="qjsbtn">去结算</a>&nbsp;&nbsp;
<a href="{M:HomeDir}shop.aspx" class="jxgwbtn">继续购物</a>

<div class="clear blank10"></div>
<span class="emptycart"><img src="{M:HomeDir}images/shop/quick_none.png" align="absmiddle"> <a href="javascript:;" onclick="removeAllPro()" style="font-size:16px;line-height:45px;color:#FB4E3A;">清空购物车数据</a></span>
<br/>
<div class="useFavor">
<strong style="font-size:16px">使用优惠券:</strong><input type="text" class="coupontxt" id="couponnum" name="couponnum" size="15">
</div>
<input type="button" value="验证" onclick="validateCoupon()" class="couponbtn"/>

</div>

	]]>
   </label>
</labeltemplate>