feat: mobile产品搜索页

This commit is contained in:
2025-05-26 17:36:05 +08:00
parent 7273594013
commit 6d9a0f3d06
8 changed files with 170 additions and 29 deletions

View File

@@ -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');
}

View File

@@ -58,4 +58,6 @@ return [
'支持型号' => 'Supported Models',
'支持系统' => 'Supported Systems',
'全站搜索' => 'Search',
'搜索' => 'Search',
'请搜索' => 'Please search...',
];

View File

@@ -1,7 +1,33 @@
{extend name="public/base" /}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__CSS__/product_search.css" />
{/block}
{block name="main"}
<div class="oricoEGapp">
<!-- 搜索页面 -->
<div class="oricoEGapp-topsearch">
<form action="{:url('product/search')}" method="get" class="topsearch">
<div class="sleft">
<img src="__IMAGES__/ssapp.png" class="icosearch"/>
<input class="topseach-ipt" name="keywords" placeholder="{:lang('请搜索')}"/>
</div>
<button type="submit" class="searchbt">{:lang('搜索')}</button>
</form>
{notempty name="products"}
<div class="prlist">
{volist name="products" id="pro"}
<a class="pritem">
<img src="{$pro.cover_image}" class="primg"/>
<div class="prinfo">
<span class="t1">{$pro.name|raw}</span>
<span class="t2">{$pro.spu|raw}</span>
</div>
</a>
{/volist}
</div>
<!-- 分页 -->
<div>{$page|raw}</div>
{/notempty}
</div>
</div>
{/block}

View File

@@ -47,8 +47,10 @@
<div class="popup-quick">
<div class="ac-close float_r "><img src="__IMAGES__/close.png"></div>
<div class="search-in">
<input type="text" placeholder="{:lang('产品')} USB 2.0...">
<button id="search-btnput" class="search-button">{:lang('搜索')}</button>
<form action="{:url('product/search')}" method="get">
<input type="text" name="keywords" placeholder="{:lang('产品')} USB 2.0...">
<button type="submit" id="search-btnput" class="search-button">{:lang('搜索')}</button>
</form>
<div class="title-text">
<p><a href="#">{:lang('搜索历史')}</a></p>
</div>