正在显示
2 个修改的文件
包含
21 行增加
和
3 行删除
@@ -215,6 +215,24 @@ class IndexController extends WeChatBaseController | @@ -215,6 +215,24 @@ class IndexController extends WeChatBaseController | ||
215 | 215 | ||
216 | } | 216 | } |
217 | 217 | ||
218 | + /** | ||
219 | + * 首页搜索结果页 价格排序 | ||
220 | + */ | ||
221 | + public function search_price_order(){ | ||
222 | + | ||
223 | + $search_content = $_POST['search_content']; | ||
224 | + $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(); | ||
225 | + if(!empty($search_content_data)){ | ||
226 | + foreach ($search_content_data as $key => $val){ | ||
227 | + $price = explode('.',$search_content_data[$key]['price']); | ||
228 | + $search_content_data[$key]['price0'] = $price[0]; | ||
229 | + $search_content_data[$key]['price1'] = $price[1]; | ||
230 | + $search_content_data[$key]['show_img'] = cmf_get_image_url($search_content_data[$key]['show_img']); | ||
231 | + } | ||
232 | + } | ||
233 | + return json_encode($search_content_data); | ||
234 | + | ||
235 | + } | ||
218 | 236 | ||
219 | 237 | ||
220 | 238 |
@@ -102,14 +102,14 @@ | @@ -102,14 +102,14 @@ | ||
102 | *价格排序 | 102 | *价格排序 |
103 | */ | 103 | */ |
104 | function classify_price(){ | 104 | function classify_price(){ |
105 | - lable_id = $('.cl_Active2').attr('data-id'); | ||
106 | - $.post("{:url('Classify/classify_price')}",{classify_id:classify_id,lable_id:lable_id},function(data){ | 105 | + search_content = $("input[name='search_content']").val(); |
106 | + $.post("{:url('Index/search_price_order')}",{search_content:search_content},function(data){ | ||
107 | $('.in_hotLi').remove(); | 107 | $('.in_hotLi').remove(); |
108 | data_arr = JSON.parse(data); | 108 | data_arr = JSON.parse(data); |
109 | for(var i=0;i<data_arr.length;i++){ | 109 | for(var i=0;i<data_arr.length;i++){ |
110 | show_img = data_arr[i].show_img; | 110 | show_img = data_arr[i].show_img; |
111 | url = "{:url('Goodsdetails/Goods_details')}?goods_id="+data_arr[i].id; | 111 | url = "{:url('Goodsdetails/Goods_details')}?goods_id="+data_arr[i].id; |
112 | - $('.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>"); | 112 | + $('.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>"); |
113 | } | 113 | } |
114 | }); | 114 | }); |
115 | } | 115 | } |
-
请 注册 或 登录 后发表评论