mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-30 11:05:27 +08:00
优化 安装包生成
This commit is contained in:
108
Application/Home/Controller/SearchController.class.php
Executable file
108
Application/Home/Controller/SearchController.class.php
Executable file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Service\SearchService;
|
||||
use Service\BrandService;
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class SearchController extends CommonController
|
||||
{
|
||||
private $params;
|
||||
|
||||
/**
|
||||
* [_initialize 前置操作-继承公共前置方法]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-03T12:39:08+0800
|
||||
*/
|
||||
public function _initialize()
|
||||
{
|
||||
// 调用父类前置方法
|
||||
parent::_initialize();
|
||||
|
||||
// 品牌id
|
||||
$this->params['brand_id'] = intval(I('brand_id', 0));
|
||||
|
||||
// 分类id
|
||||
$this->params['category_id'] = intval(I('category_id', 0));
|
||||
|
||||
// 筛选价格id
|
||||
$this->params['screening_price_id'] = intval(I('screening_price_id', 0));
|
||||
|
||||
// 搜索关键字
|
||||
$this->params['keywords'] = trim(I('keywords'));
|
||||
|
||||
// 排序方式
|
||||
$this->params['order_by_field'] = I('order_by_field', 'default');
|
||||
$this->params['order_by_type'] = I('order_by_type', 'desc');
|
||||
|
||||
// 用户信息
|
||||
$this->params['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Index 首页]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-02-22T16:50:32+0800
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
if(IS_POST)
|
||||
{
|
||||
$this->redirect('Home/Search/Index', ['keywords'=>$this->params['keywords']]);
|
||||
} else {
|
||||
// 品牌列表
|
||||
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id']]));
|
||||
|
||||
// 商品分类
|
||||
$this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->params['category_id']]));
|
||||
|
||||
// 筛选价格区间
|
||||
$this->assign('screening_price_list', SearchService::ScreeningPriceList(['field'=>'id,name']));
|
||||
|
||||
// 参数
|
||||
$this->assign('params', $this->params);
|
||||
|
||||
$this->display('Index');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-07
|
||||
* @desc description
|
||||
*/
|
||||
public function GoodsList()
|
||||
{
|
||||
// 获取商品列表
|
||||
$data = SearchService::GoodsList($this->params);
|
||||
if(empty($data['data']))
|
||||
{
|
||||
$msg = L('common_not_data_tips');
|
||||
$code = -100;
|
||||
} else {
|
||||
$msg = L('common_operation_success');
|
||||
$code = 0;
|
||||
}
|
||||
|
||||
// 搜索记录
|
||||
SearchService::SearchAdd($this->params);
|
||||
|
||||
// 返回
|
||||
$this->ajaxReturn($msg, $code, $data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user