Files
orico-official-website-old/app/usmobile/controller/Search.php
2024-10-29 14:04:59 +08:00

39 lines
1.2 KiB
PHP
Executable File

<?php
namespace app\usmobile\controller;
use think\Loader;
use think\Config;
use think\Db;
class Search extends BaseController {
public function index() {
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
$search = [];
if ($skeyword != '') {
$skeyword = trim($skeyword);
$search['skeyword'] = $skeyword;
$arg_where['name|brand_id|keyword'] = ['like', '%' . $search['skeyword'] . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
}
$arg_where['stat'] = 0;
$arg_where['is_show'] = 0;
$arg_where['country_code'] = $this->country_code;
$dataObject = Loader::model('Product')->field(['id', 'name', 'description', 'list_bk_img' => 'picture', 'createtime','brand_id', "'productdetail'" => 'link'])->where($arg_where)->paginate(6);
//echo model('product')->getLastSql();
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(),
'page' => $dataObject->render(),
];
$value['search'] = $search;
$this->assign($value);
return $this->fetch();
}
}