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

5

... ... @@ -215,6 +215,24 @@ class IndexController extends WeChatBaseController
}
/**
* 首页搜索结果页 价格排序
*/
public function search_price_order(){
$search_content = $_POST['search_content'];
$search_content_data = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where("type =2 ") -> where('book_name','like',"%".$search_content."%") -> order('price desc') -> select() -> toArray();
if(!empty($search_content_data)){
foreach ($search_content_data as $key => $val){
$price = explode('.',$search_content_data[$key]['price']);
$search_content_data[$key]['price0'] = $price[0];
$search_content_data[$key]['price1'] = $price[1];
$search_content_data[$key]['show_img'] = cmf_get_image_url($search_content_data[$key]['show_img']);
}
}
return json_encode($search_content_data);
}
... ...
... ... @@ -102,14 +102,14 @@
*价格排序
*/
function classify_price(){
lable_id = $('.cl_Active2').attr('data-id');
$.post("{:url('Classify/classify_price')}",{classify_id:classify_id,lable_id:lable_id},function(data){
search_content = $("input[name='search_content']").val();
$.post("{:url('Index/search_price_order')}",{search_content:search_content},function(data){
$('.in_hotLi').remove();
data_arr = JSON.parse(data);
for(var i=0;i<data_arr.length;i++){
show_img = data_arr[i].show_img;
url = "{:url('Goodsdetails/Goods_details')}?goods_id="+data_arr[i].id;
$('.se_con').append("<div class='in_hotLi'><a href='"+url+"'><div class='in_hotImg'><img src='"+show_img+"'></div><div class='in_hotText'><div class='in_hotName txt-cut'><span>"+data_arr[i].name+"</span>"+data_arr[i].book_name+"</div><div class='in_cam_shopPrice'><div class='in_hotPrice1'>¥<span>"+data_arr[i].price0+"</span>."+data_arr[i].price01+"</div></div></div></a></div>");
$('.se_con').append("<div class='in_hotLi'><a href='"+url+"'><div class='in_hotImg'><img src='"+show_img+"'></div><div class='in_hotText'><div class='in_hotName txt-cut'><span></span>"+data_arr[i].book_name+"</div><div class='in_cam_shopPrice'><div class='in_hotPrice1'>¥<span>"+data_arr[i].price0+"</span>."+data_arr[i].price1+"</div></div></div></a></div>");
}
});
}
... ...