<?xml version="1.0"?>
<labeltemplate>

  <cartbox type="3g">
    <![CDATA[
	 <form name="buyform" id="buyform" action="{=GetRewriteUrl(orderinfo)}" method="post">
		 <input type='hidden' name='app' id='app' value='shoppingcart'/>
		   [!--showlimitbuy--]
		   [!--showjsstr--]
			<div class="carbox property" id="carbox">
				<div class="property-box">
					<a href="javascript:;" class="property-close"><i class="fa iconfont">&#xe7b1;</i></a>
					<div class="goods-piece clearfix">
						<div class="imgbox">
							<img src="{KS:Field:DefaultPic}" class="zoom1">
						</div>
						<div class="goods-rbd">
							<div class="goods-title">{KS:Field:Title}</div>
							<div class="one_price">
								 <font class="fontcor showDynamicPrice"></font>
							</div>
							<div style="clear:both;height:1px"></div>
							<div id="buyselect"></div>
						</div>
					</div>
					
					
					[!--showattrstr--]
					<script>
					 var alen=[!--alen--];
					 var promotPrice=parseFloat({KS:Field:Price_Member});
					 var maxordernum='[!--maxordernum--]';
					 $(document).ready(function(){
					 
					 
					   if (maxordernum=='1'){
						 $("#setbuynum").hide();
					   }
					   if ("{KS:Field:IsLimitBuy}" != "0" || "{KS:Field:LimitCityNum}" != "0"){
						 $("#carbtn").hide();
					   }
					  
					   
					 });
					 $(window).load(function(){
						   if (alen>=1){
							 $(".txt").eq(0).click();  //选中第一个版本
							 }
							 if (alen>=2){
							  $("#carbox").find("div").eq(1).find(".txt").eq(0).click();
							 }
							 if (alen>=3){
							  $("#carbox").find("div").eq(2).find(".txt").eq(0).click();
							 }
					 });
					</script>
					<div class="clear"></div>
					<div id='setbuynum'>
						<input type='hidden' name='maxordernum' id='maxordernum' value='[!--maxordernum--]'/>
						<span class="lititle">数量：</span><a href='javascript:shop.buynum(0)' class="Reducebtn"><i>-</i></a> 
						<input type="text" onkeyup="this.value=this.value.replace(/\D/,'');" name="Q_{KS:Field:InfoID}" id="num" size="4" value="1" style="text-align:center" class="cnumtext"> 
						<a href='javascript:shop.buynum(1)' class="addbtn"><i>+</i></a> {KS:Field:Unit}
						<label class="showstock">(库存<label id='stock' class='stock'><script src='{$GetInstallDir}index.aspx?c=mall&a=getstock&id={KS:Field:InfoID}'></script></label>
						<font id='unit'>{KS:Field:Unit}</font>)</label>
					</div>
		    	</div>
				<div class="showCartBtn"  style="display:none">
				<a href="javascript:;" id="cartconfirmbtn" class="btn set-submit"/>确定</a>
				</div>
			     <div class="showEmptyStockTips" style="display:none">{KS:Field:EmptyStockTips}</div>
				
			</div>
			<div class="btn-group">
			 <input type='hidden' name='ID' id='ID' value='{KS:Field:InfoID}'>
			 <input type="button" value="加入购物车" id="carbtn" onpopclick="shop.addCart(event,{KS:Field:InfoID},[!--alen--],{KS:Field:ChannelID},'[!--from--]')">
			  <input type="button" value="立即购买"  id="buybtn" onpopclick="shop.gobuy([!--alen--])" />
			</div>
      <div class="btn-group1" style="display:none">
			  <input type="button" value="立即购买" class="noclick"  />
			</div>
		</form>
   ]]>
  </cartbox>

  <wholesale>
   <head>
    <![CDATA[
	<style type="text/css">
        table.gridtable {
	        font-family: verdana,arial,sans-serif;
	        font-size:14px;
	        color:#333333;
	        border-width: 1px;
	        border-color: #ccc;
	        border-collapse: collapse;
        }
        table.gridtable tr.CTitle td{
	        border-width: 1px;
	        padding: 2px;
	        border-style: solid;
	        border-color: #ccc;
            height:22px;
			text-align:center;
			background:#f1f1f1;
        }
        table.gridtable td {
	        border-width: 1px;
	        padding: 8px;
	        border-style: solid;
	        border-color: #ccc;
	        background-color: #ffffff;
			text-align:center;
        }
		 table.gridtable td span{
		 cursor:pointer;
		 }
		.gwxgjh{ padding:1px 7px; background: #C00; color:#FFF}
		.gwxgjh a:hover{ color:#FFF}
		.gwxgjh a{ color:#FFF}
		.buyNum{ border:1px solid #C00; height:20px; text-align:center; line-height:18px;}
		.hasTotalPrice{ color:#C00; font-size:20px; font-weight:bold}
        #hasSelectNum{ color:#C00; font-size:20px; font-weight:bold}

        </style>
	<div class="carbox" id="carbox">
	 <form name="buyform" id="buyform" action="{=GetRewriteUrl(shoppingcart)}" method="post">
         <input type="hidden" name="id" value="{KS:Field:InfoID}" />
	   <div>批量订购</div>
      <table class="gridtable" id="specialtable" border='1' cellspacing='1' cellpadding='1' width="99%">
	    <tr class="CTitle">
		  [!--property--]
		  <td nowrap>货号</td>
	      <td  width='100' nowrap>市场价</td>
          <td  width='100' nowrap>销售价</td>
		  <td  width='100' nowrap>库存</td>
		  <td  width='100' nowrap>重量</td>
		  <td  width='100' nowrap>购买</td>
	　　</tr>
	     [!--looplist--]
	  </table>
	  
	 <div style="height:35px;line-height:35px;border:1px solid #f1f1f1;">
	 已选 <font id="hasSelectNum">0</font> {KS:Field:Unit}&nbsp;&nbsp;共计 <font class="hasTotalPrice">{$GetCurrencySymbol}<font id="hasTotalPrice">0.00</font></font> {$GetCurrencyUnit}
	 </div>
	 <div style="text-align:center;height:50px;line-height:50px">
	  <input type="submit" value=""  id="buybutton" onclick="return(checkWholesale());">
	  <input type="button" value="" id="cartbutton" onclick="return(addWholeCart({KS:Field:ChannelID},{KS:Field:InfoID}));">
	 </div>
	 </form>
	 
	 <script>
	 var DecimalPlaces={$DecimalPlaces};               //保留小数位数
	 function changeBuyNum(flag,id){
	  var num=parseInt($("#num_"+id).html());
	  var v=parseInt($("#amount_"+id).val());
	  if (flag=='+'){
	   if (v+1>num){
	     KesionJS.Alert('对不起，库存不足！');
	   }else{
	     $("#amount_"+id).val(v+1);
	    }
	  }else{
	   if (v>=0) $("#amount_"+id).val(v-1);
	  }
	  culTotalPrice();
	 }
	 function changeInputNum(id,v){
	  var num=parseInt($("#num_"+id).html());
	  if (v>num){
	     KesionJS.Alert('对不起，库存不足！');
		 $("#amount_"+id).val(num);
	  }
	  culTotalPrice();
	 }
	  var attids='';
	  var attnums='';
	 function culTotalPrice(){
	  var totalNum=0;
	  var totalPrice=0;
	  attids='';
	  attnums=''
	  $("#specialtable .buyNum").each(function(){
	     totalNum+=parseInt($(this).val());
		 var price=parseFloat($("#price_"+$(this).attr("attrid")).html());
		 totalPrice+=price*parseInt($(this).val());
		 if (parseInt($(this).val())>0){
		  	 attids+=(attids!=''?',':'')+$(this).attr("attrid");
		     attnums+=(attids!=''?',':'')+parseInt($(this).val());
		 }
	  });
	  $("#hasSelectNum").html(totalNum);
	  $("#hasTotalPrice").html(totalPrice.toFixed(DecimalPlaces));
	 }
	 function checkWholesale(){
	   var hasNum=parseInt($("#hasSelectNum").html());
	   if (hasNum<=0){
	    KesionJS.Alert('您没有选择要购买的商品!','');
		return false;
	   }
	   return true;
	 }
	 //加入购物车
	 function addWholeCart(m,id){
	  if (checkWholesale()){
	            var top=$('#cartbutton').offset().top - $(document).scrollTop()+28;
				if (top<0) top=28;
				var left=parseInt($('#cartbutton').offset().left);
				if (left+400-parseInt($(document.body).width())>0) left=left-300;
				 var str="<img src='"+appurl+"ks_inc/mall/img/suc.gif' align='absmiddle'><span style='font-size:14px;color:#000;'>已成功加入进货车！</span><div id='cartShow' style='width:360px;height:160px;'></div><div class='jrgwc'> <a href=\'"+appurl+"index.aspx?c=mall&a=orderinfo\'><img src=\'"+appurl+"ks_inc/mall/img/hesuan.gif\'></a> <a href=\'{=GetRewriteUrl(shoppingcart)}\'><img src=\'"+appurl+"ks_inc/mall/img/chakangouwuche.gif\'></a></form></div>";

			
jQuery.getScript(appurl+'plus/Ajaxs.ashx?id='+id+'&attrid='+attids+'&m='+m+'&a=addCart&num='+attnums+'&AttributeCart='+escape($("#AttributeCart").val()),function(){
				  if (data.flag=='error'){
						    alert('参数出错啦!');
					}else if (data.flag=='error1'){
						    alert('对不起，您没有登录!');
              window.location.href='{=GetRewriteUrl(userlogin)}';
							//showuserlogin();
					   }else{
					    	$.dialog({id:'mycart',title:'购物车内商品',max:false,min:false,content:str,left: left,top: top});
				            $("#cartShow").html(unescape(data.str));
					   }																														                 
				 });
	  }
	  
	 }
	 </script>
	 
	]]>
   </head>
   
   <loop>
    <![CDATA[
	    <tr>
		  [!--property--]
		  <td style="text-align:center" nowrap>{KS:Field:ItemNo}</td>
	      <td style="text-align:center" nowrap>{$GetCurrencySymbol}{KS:Field:Price_Market}</td>
	      <td style="text-align:center" nowrap>
		  {$GetCurrencySymbol}
		  <font id="price_{KS:Field:ID}">{KS:Field:Price}</font>
		  </td>
	      <td style="text-align:center" nowrap><font id="num_{KS:Field:ID}">{KS:Field:Num}</font></td>
	      <td style="text-align:center" nowrap>{KS:Field:Weight} KG</td>
	      <td style="text-align:center" nowrap>
		   <a href="javascript:void(0)"  onclick="changeBuyNum('-',{KS:Field:ID})" target="_self" class="gwxgjh"><i>-</i></a>
		  <input type='text' class="buyNum" name='amount_{KS:Field:ID}' attrid='{KS:Field:ID}' id='amount_{KS:Field:ID}' value='0' onKeyDown='if(event.keyCode == 13) event.returnValue = false' onchange="changeInputNum('{KS:Field:ID}',this.value)" onkeypress="javascript:return isNumber(event);"/>
		   <a href="javascript:void(0)"  onclick="changeBuyNum('+',{KS:Field:ID})" target="_self" class="gwxgjh"><i>+</i></a>
		   
           <input type="hidden" name="attrids" value="{KS:Field:ID}"/>  <!--属性ID-->
		   
		  </td>
	　　</tr>
	]]>
   </loop>
</wholesale>

</labeltemplate>