|
@@ -6,10 +6,51 @@ defined('InShopNC') or exit('Access Invalid!');
|
|
|
require_once (BASE_ROOT_PATH . '/helper/category_helper.php');
|
|
|
require_once (BASE_ROOT_PATH . '/helper/goods_helper.php');
|
|
|
require_once (BASE_ROOT_PATH . '/helper/search_helper.php');
|
|
|
-require_once(BASE_ROOT_PATH . '/helper/search/searcher.php');
|
|
|
-require_once(BASE_ROOT_PATH . '/helper/search/server.php');
|
|
|
-require_once(BASE_ROOT_PATH . '/helper/search/processor.php');
|
|
|
-require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/search/searcher.php');
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/search/server.php');
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/search/processor.php');
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/search/tcp_client.php');
|
|
|
+
|
|
|
+class search_param
|
|
|
+{
|
|
|
+ private $mKeyWord;
|
|
|
+ private $mBrandId;
|
|
|
+ private $mHotId;
|
|
|
+
|
|
|
+ public function __construct($param)
|
|
|
+ {
|
|
|
+ $this->mKeyWord = '';
|
|
|
+ $this->mBrandId = 0;
|
|
|
+ $this->mHotId = 0;
|
|
|
+
|
|
|
+ if (!empty(trim($param['keyword']))) {
|
|
|
+ $this->mKeyWord = trim(urldecode($param['keyword']));
|
|
|
+ $helper = new history_helper();
|
|
|
+ $helper->add_word($this->mKeyWord);
|
|
|
+ }
|
|
|
+ if (intval($param['brand_id']) > 0) {
|
|
|
+ $this->mBrandId = intval($param['brand_id']);
|
|
|
+ }
|
|
|
+ if (!empty(trim($param['hot_id']))) {
|
|
|
+ $this->mHotId = intval($param['hot_id']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function format()
|
|
|
+ {
|
|
|
+ if(empty($this->mKeyWord || $this->mBrandId == 0 || $this->mHotId == 0)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $result = [];
|
|
|
+ $result['keyword'] = $this->mKeyWord;
|
|
|
+ $result['brand_id'] = $this->mBrandId;
|
|
|
+ $result['hot_id'] = $this->mHotId;
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
class searchControl extends mobileHomeControl
|
|
|
{
|
|
@@ -20,13 +61,17 @@ class searchControl extends mobileHomeControl
|
|
|
|
|
|
public function indexOp()
|
|
|
{
|
|
|
- $condition = $this->condition();
|
|
|
- if(empty($condition)) {
|
|
|
+ $param = new search_param();
|
|
|
+ $params = $param->format();
|
|
|
+ if($params == false) {
|
|
|
return self::outerr(errcode::ErrParamter);
|
|
|
+ } else {
|
|
|
+ $result = search\tcp_client::instance()->get_result($params);
|
|
|
}
|
|
|
$order = $this->get_order($_GET['key'], $_GET['order']);
|
|
|
|
|
|
$model_goods = Model('goods');
|
|
|
+ $condition = [];
|
|
|
$goods_list = $model_goods->getGoodsListByColorDistinct($condition, goods_helper::fieldstr, $order, $this->page_size());
|
|
|
$page_count = $model_goods->gettotalpage();
|
|
|
$model_goods->cls();
|
|
@@ -81,11 +126,12 @@ class searchControl extends mobileHomeControl
|
|
|
|
|
|
public function historyOp()
|
|
|
{
|
|
|
- $helper = new search_helper();
|
|
|
- $result = $helper->get_words();
|
|
|
+ $helper = new history_helper();
|
|
|
+ $result = $helper->histories();
|
|
|
$result = $this->separate_page($result,$pages);
|
|
|
return self::outsuccess(array('words' => $result,'mobile_page' => mobile_page($pages)));
|
|
|
}
|
|
|
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/**
|
|
|
* @return array
|
|
@@ -100,7 +146,7 @@ class searchControl extends mobileHomeControl
|
|
|
// 关键字
|
|
|
if (!empty(trim($_GET['keyword']))) {
|
|
|
$word = trim(urldecode($_GET['keyword']));
|
|
|
- $helper = new search_helper();
|
|
|
+ $helper = new history_helper();
|
|
|
$helper->add_word($word);
|
|
|
$condition['goods_name|goods_jingle'] = array('like', '%' . urldecode($_GET['keyword']) . '%');
|
|
|
}
|