<!DOCTYPE html>
<html>
<?php echo $this->fetch('head.html'); ?>

<body>
<div class="header">
	<div class="header-back pos-relative"></div>
	<div class="header-search-box">
		 
		<input id="search-word" class="header-search pdl-5" placeholder="<?php echo $this->_var['cat']['title']; ?>" type="text">
		<div id="search-btn" class="header-search-btn bg-primary cl-white iconfont icon-search"></div>
	</div>
	 
</div>
<div class="header-row"></div>
<a href="/module.php?m=fenlei&a=add&catid=<?php echo $this->_var['cat']['catid']; ?>" class="fixedAdd">发布</a>
<div class="main-body">
	<?php if ($this->_var['catList']): ?>
	<div class="row-box mgb-5">
		
		<div class="flex flex-wrap">
			<?php $_from = $this->_var['catList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?>
				<a href="/module.php?m=fenlei&a=list&catid=<?php echo $this->_var['cc']['catid']; ?>" class="pd-5 cl2"><?php echo $this->_var['cc']['title']; ?></a>
				
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
		</div> 
	</div>
	<?php else: ?>
	<div class="pos-relative">
		<div class="tab-select">
			<div class="tab-select-item" id="tab-scarea">
				<div class="tab-select-label">所在区域</div>
				<div class="tab-select-t3down "></div>	
			</div>
			<?php if ($this->_var['typeList']): ?>
			<div class="tab-select-item" id="tab-type">
				<div class="tab-select-label"><?php echo $this->_var['cat']['typeLabel']; ?></div>
				<div class="tab-select-t3down "></div>	
			</div>
			<?php endif; ?>
			<div class="tab-select-item" id="tab-sprice">
				<div class="tab-select-label"><?php echo $this->_var['cat']['moneyLabel']; ?>区间</div>
				<div class="tab-select-t3down "></div>	
			</div>
		</div>
		<div id="scarea-box" class="tab-select-box">
			<a class="tab-select-box-item" v="">所在区域</a>
			<?php $_from = $this->_var['scList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
			<a class="tab-select-box-item" v="<?php echo $this->_var['c']['sc_id']; ?>"><?php echo $this->_var['c']['title']; ?></a>
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
		</div>
		<?php if ($this->_var['typeList']): ?>
		<div id="type-box" class="tab-select-box">
			<a class="tab-select-box-item" v=""><?php echo $this->_var['cat']['typeLabel']; ?></a>
			<?php $_from = $this->_var['typeList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('k', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['k'] => $this->_var['c']):
?>
				<a class="tab-select-box-item" v="<?php echo $this->_var['k']; ?>"><?php echo $this->_var['c']; ?></a>
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
		</div>
		<?php endif; ?>
		<div id="sprice-box" class="tab-select-box">
			<a class="tab-select-box-item" v=""><?php echo $this->_var['cat']['moneyLabel']; ?>区间</a>
			<?php $_from = $this->_var['priceList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
				<a class="tab-select-box-item" v="<?php echo $this->_var['c']; ?>"><?php echo $this->_var['c']; ?></a>
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
		</div>
	</div>	
	<?php endif; ?>
	<?php if ($this->_var['recList']): ?>
	<div class="list" id="list">
	  <?php $_from = $this->_var['recList']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
	 <a href="/module.php?m=fenlei&a=show&id=<?php echo $this->_var['c']['id']; ?>" class="flexlist-item">
	 	<?php if ($this->_var['c']['imgurl']): ?>
	 	<img class="flexlist-img" src="<?php echo $this->_var['c']['imgurl']; ?>.100x100.jpg" />
	 	<?php endif; ?>
		 <div class="flex-1">
			<div class="flex mgb-5">
				<?php if ($this->_var['c']['isrecommend']): ?>
				<div class="bc-recommend mgr-5">荐</div>
				<?php endif; ?>
				<?php if ($this->_var['c']['hb_on']): ?>
				<div class="bc-red mgr-5">红</div>
				<?php endif; ?>
				<div class="f14"><?php echo $this->_var['c']['title']; ?></div>
			</div>
				<?php if ($this->_var['c']['money'] > 0): ?>
				<div class="flexlist-row">
					<div class="cl-money">￥<?php echo $this->_var['c']['money']; ?></div>
				</div>
				<?php endif; ?>
			  <div class="flexlist-desc">
				  <?php echo $this->_var['c']['description']; ?>
			  </div>
		</div>
	 </a>
	  <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
	 </div>
	 <?php endif; ?>
	<?php if (empty ( $this->_var['list'] )): ?>
	<div class="emptyData">暂无信息</div>
	<?php else: ?>
	<div class="list" id="list">
	  <?php $_from = $this->_var['list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
	 <a href="/module.php?m=fenlei&a=show&id=<?php echo $this->_var['c']['id']; ?>" class="flexlist-item">
	 	<?php if ($this->_var['c']['imgurl']): ?>
	 	<img class="flexlist-img" src="<?php echo $this->_var['c']['imgurl']; ?>.100x100.jpg" />
	 	<?php endif; ?>
		 <div class="flex-1">
			<div class="flex mgb-5">
				 
				<?php if ($this->_var['c']['hb_on']): ?>
				<div class="bc-red mgr-5">红</div>
				<?php endif; ?>
				<div class="f14"><?php echo $this->_var['c']['title']; ?></div>
			</div>
			 
				<?php if ($this->_var['c']['money'] > 0): ?>
				<div class="flexlist-row">
					<div class="cl-money">￥<?php echo $this->_var['c']['money']; ?></div>
				</div>
				<?php endif; ?>
			  <div class="flexlist-desc">
				  <?php echo $this->_var['c']['description']; ?>
			  </div>
		</div>
	 </a>
	  <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
	 </div>
  <?php endif; ?>
<div><?php echo $this->_var['pagelist']; ?></div>
  
</div>
<?php echo $this->fetch('ftnav.html'); ?>
<?php echo $this->fetch('footer.html'); ?>
<script id="list-tpl" type="text/html">
	<%for(var i in list){%>
	<% var $c=list[i];%>
	<a href="/module.php?m=fenlei&a=show&id=<%=$c.id%>" class="flexlist-item">
		<%if($c.imgurl){%>	  
		  <img src="<%=$c.imgurl%>.100x100.jpg" class="flexlist-img" />
		<%}%>  
		  <div class="flex-1">
		  <div class="flexlist-title"><%=$c.title%></div>
		  <%if($c.money>0){%>
		  <div class="flexlist-row">
			  <div class="cl-money">￥<%=$c.money%></div>
		  </div>
		  <%}%>
		  <div class="flexlist-desc">
			  <%=$c.description%>
		  </div>
		 </div> 
	</a>
	<%}%>
</script>
<script src="/plugin/jquery/template-native.js"></script>
<script src="/plugin/jquery/listload.js"></script>
<script>
	var catid="<?php echo $this->_var['cat']['catid']; ?>";
	var sc_id=0;
	var sprice="";
	var typeid=0;
	function getList(){
		$.get("/module.php?m=fenlei&a=list&ajax=1",{
			catid:catid,
			sc_id:sc_id,
			sprice:sprice,
			typeid:typeid
		},function(res){
			var html=template("list-tpl",res.data);
			$("#list").html(html);
		},"json")
	}
	$(document).on("click","#search-btn",function(){
		var word=$("#search-word").val();
		window.location="/module.php?m=fenlei&a=search&keyword="+encodeURI(word)
	})
	$(document).on("click",".tab-select-item",function(){
		var index=$(this).index();
		console.log(index);
		$(".tab-select-box:eq("+index+")").toggle();
		$(".tab-select-box:eq("+index+")").siblings(".tab-select-box").hide();
	})
	$(document).on("click", ".tab-select-box-item", function() {
		var $p=$(this).parents(".tab-select-box");
		var $tab;
		switch($p.attr("id")){
			case "choice-box":
				$tab=$("#tab-choice");
				sprice=$(this).attr("v");
				break;
			case "sprice-box":
				$tab=$("#tab-sprice");
				sprice=$(this).attr("v");
				break;
			case "type-box":
				$tab=$("#tab-type");
				typeid=$(this).attr("v");
				break;
			case "scarea-box":
				$tab=$("#tab-scarea");
				sc_id=$(this).attr("v");
				break;
			case "order-box":
				$tab=$("#tab-order");
				orderby=$(this).attr("v");
				break;
			 
		}
		  
		per_page = 0;
		first = true;
		$p.hide();
		$p.find(".tab-select-box-item").removeClass("tab-select-box-active");
		$(this).addClass("tab-select-box-active");
		$tab.find(".tab-select-label").text($(this).text());
		getList();
	});
</script>
<?php wx_jssdk();?>
		<script type="text/javascript">
			wxshare_title=document.title;
		
			<?php if ($this->_var['cat']['imgurl']): ?> 
			 wxshare_imgUrl="<?php echo images_site($this->_var['cat']['imgurl']); ?>.100x100.jpg";
			 <?php endif; ?>
		</script>
</body>
</html>