init
This commit is contained in:
38
app/usmobile/controller/Search.php
Executable file
38
app/usmobile/controller/Search.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user