<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view(TPL_FOLDER."header");?>
<div class=ad950>
  <script type="text/javascript" src="<?php echo site_url(CTL_FOLDER.'feed/ads/5');?>"></script>
</div>
<div class="list">
  <div class="list_right">
    <!-- 当前位置 -->
    <div class="list_place">
      <div class="list_place_ioc"><img src="{tpl_path}images/ioc_02.gif" align="absmiddle"/></div>
      <div class="list_place_nav">您的位置:<a href="<?php echo base_url();?>">首页</a> <?php echo $nav;?> &nbsp;&nbsp; 搜索到相关商品<span class="lgoods_list_num"><?php echo $total;?></span>件</div>
    </div>
    <!-- 下级分类 -->
    <?php if(isset($subc) && !empty($subc)) { 
	?>
    <div class="list_class">
      <div class="list_class_catalogs">
        <div class="clear"></div>
        <ul>
          <?php
        foreach($subc as $row){
		?>
          <li><img src="{tpl_path}images/ioc_03.gif"/><a href="<?php echo site_url(CTL_FOLDER.'search'); ?>?cid=<?php echo $row->cid;?>" title="<?php echo $row->cat_name;?>"><?php echo $row->cat_name;?></a></li>
          <?php } ?>
        </ul>
        <div class="clear"></div>
      </div>
    </div>
    <?php } ?>
    <!-- 商品排序 -->
    <div class="list_choose">
      <ul>
        <li<?php if($sort == "commissionNum_desc") { echo ' id="this_choose"';} ?>><a href="<?php echo site_url(CTL_FOLDER.'search'); ?>?sort=commissionNum_desc&cid=<?php echo $cid;?>&keyword=<?php echo $keyword;?>">销量从高到低</a></li>
        <li<?php if($sort == "credit_desc") { echo ' id="this_choose"';} ?>><a href="<?php echo site_url(CTL_FOLDER.'search'); ?>?sort=credit_desc&cid=<?php echo $cid;?>&keyword=<?php echo $keyword;?>">信用从高到低</a></li>
        <li<?php if($sort == "price_desc") { echo ' id="this_choose"';} ?>><a href="<?php echo site_url(CTL_FOLDER.'search'); ?>?sort=price_desc&cid=<?php echo $cid;?>&keyword=<?php echo $keyword;?>">价格从高到低</a></li>
        <li<?php if($sort == "price_asc") { echo ' id="this_choose"';} ?>><a href="<?php echo site_url(CTL_FOLDER.'search'); ?>?sort=price_asc&cid=<?php echo $cid;?>&keyword=<?php echo $keyword;?>">价格从低到高</a></li>
        <li<?php if($sort == "delistTime_desc") { echo ' id="this_choose"';} ?>><a href="<?php echo site_url(CTL_FOLDER.'search'); ?>?sort=delistTime_desc&cid=<?php echo $cid;?>&keyword=<?php echo $keyword;?>">时间从高到低</a></li>
      </ul>
    </div>
    <!-- 高级选项 -->
    <div class="list_look">
      <div class="list_look_img"><img src="{tpl_path}images/sx.gif" /></div>
      <div class="list_look_tit"><span>宝贝筛选</span> 关键字（必选）：</div>
      <form name="item_s_form" action="<?php echo site_url(CTL_FOLDER.'search'); ?>">
        <input type="hidden" name="cid" value="<?php echo $cid ?>">
        <input type="text" name="keyword" value="<?php echo urldecode($keyword); ?>" style="width:100px; height:10px" class="ui-tx-input" maxlength="50">
        <span>价格：</span>
        <input type="text" name="start_price" style="width:40px; height:10px" maxlength="10" class="ui-tx-input"  />
        -
        <input type="text" name="end_price" style="width:40px; height:10px" maxlength="10" class="ui-tx-input" />
        <span>元</span>
      </form>
      <div class="list_look_submit"> <img src="{tpl_path}images/top_search_submit.gif" style="cursor:hand;padding-left:5px;" id="subclkbtn" /> </div>
    </div>
    <!-- 商品列表 -->
    <div class="list_goodslist">
      <?php 
			if(isset($query)){
			foreach($query as $row){
			?>
      <div class="lgoods_list">
        <div class="lgoods_list_img piczoom" onMouseOver="this.className='lgoods_list_img_hover'" onMouseOut="this.className='lgoods_list_img'" id="<?php echo $row['pic_url'];?>"> <a href="<?php echo site_url(CTL_FOLDER.'item/'.$row['num_iid']);?>" target="_blank" title="<?php $row['title'];?>"><img alt="<?php $row['title'];?>" src="<?php echo $row['pic_url'];?>_b.jpg" align="absmiddle"></a> </div>
        <div class="lgoods_list_title"> <a href="<?php echo site_url(CTL_FOLDER.'item/'.$row['num_iid']);?>" target="_blank" title="<?php $row['title'];?>"><?php echo $row['title'];?></a> </div>
        <div class="lgoods_list_price">
          <div class="lgoods_list_pricel">
            <div class="lgoods_list_scprice"><img src="{tpl_path}images/list_ioc01.gif" />市场价:￥<span><?php echo get_market_price($row['price']);?></span> 元</div>
            <div class="lgoods_list_tbprice"><img src="{tpl_path}images/list_ioc02.gif" />淘宝价:￥<span><?php echo $row['price'];?></span> 元</div>
            <div class="lgoods_list_num"><img src="{tpl_path}images/list_ioc03.gif" />已销售:￥<span><?php echo $row['commission_num'];?></span> 件</div>
          </div>
          <div class="lgoods_list_pricer">
            <div class="lgoods_list_button"><a href="<?php echo site_url(CTL_FOLDER.'item/'.$row['num_iid']);?>" target="_blank"><img src="{tpl_path}images/list_ioc05.gif" align="absmiddle" alt="点击购买此商品" /></a></div>
            <div class="lgoods_list_button"><a href="<?php echo $row['shop_click_url'];?>" target="_blank"><img src="{tpl_path}images/list_ioc06.gif" align="absmiddle" alt="点击访问卖家店铺" /></a></div>
            <div class="lgoods_list_button"><a title="收藏该商品" href="javascript:void(0);" onclick="AddFavorite('<?php echo $row['click_url'];?>','<?php echo $row['title'];?>')"><img src="{tpl_path}images/list_ioc07.gif" align="absmiddle" alt="收藏商品到收藏夹" /></a> </div>
          </div>
        </div>
      </div>
      <?php 
				}
			} ?>
    </div>
    <!-- 列表分页 -->
    <div id="pages"> <?php echo $paginate;?> </div>
  </div>
  <div class="list_left">
    <!-- 热销商品 -->
    <div class="list_hot">
      <div class="hot_head"><span>掌柜热卖</span></div>
      <!--列表模块-->
      <div class="hot_goods">
        <?php if(isset($sale_top)){
				foreach($sale_top as $row){
			?>
        <div class="hot_lgoods_list">
          <div class="hot_lgoods_list_img" onMouseOver="this.className='hot_lgoods_list_img_hover'" onMouseOut="this.className='hot_lgoods_list_img'"> <a href="<?php echo site_url(CTL_FOLDER.'item/'.$row['num_iid']);?>" target="_blank" title="<?php $row['title'];?>"><img alt="<?php $row['title'];?>" src="<?php echo $row['pic_url'];?>_160x160.jpg" align="absmiddle"></a> </div>
          <div class="hot_lgoods_list_title"><a href="<?php echo site_url(CTL_FOLDER.'item/'.$row['num_iid']);?>" target="_blank" title="<?php $row['title'];?>"><?php echo strcut($row['title'],39);?></a> </div>
          <div class="hot_lgoods_list_price">市场价:￥<span class="hot_lgoods_list_scprice"><?php echo get_market_price($row['price']);?> </span> 元<br />
            <span class="hot_lgoods_list_tbprice">淘宝价:￥<b><?php echo $row['price'];?></b> 元</span><br />
            <?php 
					if ($row['commission_num'] >= 5){
						echo '本月热销:<span class="hot_lgoods_list_num"><b>'.$row['commission_num'].'</b></span> 件';
                }
                ?>
          </div>
        </div>
        <?php 
				}
			} ?>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
$(function(){
	$('#subclkbtn').click(function(){
		var sform = document.item_s_form;
		var sp = sform.start_price.value;
		var ep = sform.end_price.value;
		if(sform.keyword.value == '' && sp == '' && ep == '' )
		{
			alert('请输入搜索关键字或价格范围');
			return;
		}
		var reg = /^([1-9]+\d*(\.\d+)?)|(0\.\d+)$/;
		if(sp == '' && ep == '')
		{
			
		}
		else
		{
			if( ! reg.test(sp))
			{
				alert('起始价格有误,请重新填写');
				return;
			}
			sp = parseFloat(sp);
			if( ! reg.test(ep))
			{
				alert('结束价格有误,请重新填写');
				return;
			}
			ep = parseFloat(ep);
			if(sp > ep)
			{
				alert('输入的起始价格不能大于结束价格');
				return;
			}
		}
		sform.submit();
	});
})
</script>
<?php $this->load->view(TPL_FOLDER."footer");?>
