作者 anyv
1 个管道 的构建 通过 耗费 0 秒

分类

... ... @@ -36,5 +36,30 @@ class ClassifyController extends WeChatBaseController{
}
/**
* 分类下的商品
*/
public function classify_goods(){
$classify_id = $_POST['classify_id'];
$data_classify_goods = Db::name('goods') -> alias('a') -> join('classification b','a.classify_id = b.id','LEFT') -> where("a.type = 1 and a.classify_id =".$classify_id) -> select() -> toArray();
foreach($data_classify_goods as $key => $val){
$price = explode('.',$data_classify_goods[$key]['price']);
$data_classify_goods[$key]['price0'] = $price[0];
$data_classify_goods[$key]['price01'] = $price[1];
}
return json_encode($data_classify_goods);
}
}
\ No newline at end of file
... ...
... ... @@ -27,7 +27,7 @@
<div class="cl_nav">
<ul>
<volist name="data_classify" id="vo">
<li class="<eq name='$key' value='0'>cl_navActive</eq>" data-id="{$vo.id}">{$vo.name}</li>
<li onclick="classify_goods({$vo.id})" class="<eq name='$key' value='0'>cl_navActive</eq>" data-id="{$vo.id}">{$vo.name}</li>
</volist>
</ul>
</div>
... ... @@ -97,6 +97,21 @@
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script>
/**
*分类下的商品
*/
function classify_goods(id){
$.post("{:url('Classify/classify_goods')}",{classify_id:id},function(data){
$('.in_hotLi').remove();
data_arr = JSON.parse(data);
console.log(data_arr);
for(var i=0;i<data_arr.length;i++){
$('.se_con').after("");
}
});
}
</script>
<script>
$('.cl_nav ul li').click(function() {
$(this).addClass('cl_navActive').siblings().removeClass('cl_navActive');
})
... ...