40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace app\controller;
|
|
|
|
use app\repository\AccountRepository;
|
|
use app\repository\GoodsRepository;
|
|
use app\repository\OperationRepository;
|
|
use Exception;
|
|
use think\response\View;
|
|
|
|
class Search extends Base
|
|
{
|
|
/**
|
|
* 搜索
|
|
*
|
|
* @return View
|
|
* @throws Exception
|
|
*/
|
|
public function index(): View
|
|
{
|
|
$tag = input('get.tag/s', 'goods');
|
|
$keyword = input('get.keyword/s', '');
|
|
$pageParams['query'][] = input('get.');
|
|
$where['size'] = 50;
|
|
$where['where'][] = ['type', '=', $tag];
|
|
$where['where'][] = ['status', '=', GoodsRepository::STATUS_ON];
|
|
$where['where'][] = ['stock', '>', 0];
|
|
$where['where'][] = ['title', 'like', '%'.$keyword.'%'];
|
|
$items = GoodsRepository::getInstance()->findListWithPaginate($where, $pageParams);
|
|
|
|
$position = ['search_banner'];
|
|
$slides = OperationRepository::getInstance()->slideListByPosition($position);
|
|
$collectedIds = $this->authId ? AccountRepository::getInstance()->getCollectedIds($this->authId, $tag) : [];
|
|
|
|
$this->data['items'] = $items;
|
|
$this->data['collectedIds'] = $collectedIds;
|
|
$this->data['slide'] = $slides;
|
|
return $this->view();
|
|
}
|
|
} |