feat: mobile产品搜索页
This commit is contained in:
@@ -267,7 +267,12 @@ class Product extends Common
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$keywords = request()->param('keywords', '');
|
||||
$param = request()->param([
|
||||
'keywords',
|
||||
'page/d' => 1,
|
||||
'size/d' => 10
|
||||
]);
|
||||
$keywords = $param['keywords'] ?? '';
|
||||
|
||||
// 关键词搜索
|
||||
$products = ProductModel::field([
|
||||
@@ -283,7 +288,11 @@ class Product extends Common
|
||||
->onSale(true)
|
||||
->onShelves(true)
|
||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||
->select()
|
||||
->paginate([
|
||||
'list_rows' => $param['size'],
|
||||
'page' => $param['page'],
|
||||
'query' => request()->param()
|
||||
])
|
||||
->each(function ($item) use($keywords) {
|
||||
$item['spu'] = str_replace($keywords, '<strong class="redpoint">'.$keywords.'</strong>', $item['spu']);
|
||||
$item['name'] = str_replace($keywords, '<strong class="redpoint">'.$keywords.'</strong>', $item['name']);
|
||||
@@ -291,6 +300,7 @@ class Product extends Common
|
||||
return $item;
|
||||
});
|
||||
View::assign('products', $products);
|
||||
View::assign('page', $products->render());
|
||||
|
||||
return View::fetch('search');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user