StrToAscii($keywords)])); } else { // 参数初始化 $this->ParamsInit(); // 品牌列表 $this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id'], 'keywords'=>$this->params['wd']])); // 商品分类 $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); // seo $this->SetSeo(); return $this->fetch(); } } /** * seo设置 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2019-06-02T21:29:04+0800 */ private function SetSeo() { $seo_title = $this->params['wd']; if(!empty($this->params['category_id'])) { $category = GoodsService::GoodsCategoryRow(['id'=>$this->params['category_id'], 'field'=>'name,seo_title,seo_keywords,seo_desc']); if(!empty($category)) { $seo_title = empty($category['seo_title']) ? $category['name'] : $category['seo_title']; // 关键字和描述 if(!empty($category['seo_keywords'])) { $this->assign('home_seo_site_keywords', $category['seo_keywords']); } if(!empty($category['seo_desc'])) { $this->assign('home_seo_site_description', $category['seo_desc']); } } } $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle(empty($seo_title) ? '商品搜索' : $seo_title, 1)); } /** * 参数初始化 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @datetime 2019-06-02T01:38:27+0800 */ private function ParamsInit() { // 参数 $params = input(); // 品牌id $this->params['brand_id'] = isset($params['brand_id']) ? intval($params['brand_id']) : 0; // 分类id $this->params['category_id'] = isset($params['category_id']) ? intval($params['category_id']) : 0; // 筛选价格id $this->params['screening_price_id'] = isset($params['screening_price_id']) ? intval($params['screening_price_id']) : 0; // 搜索关键字 $this->params['wd'] = empty($params['wd']) ? '' : (IS_AJAX ? trim($params['wd']) : AsciiToStr($params['wd'])); // 排序方式 $this->params['order_by_field'] = empty($params['order_by_field']) ? 'default' : $params['order_by_field']; $this->params['order_by_type'] = empty($params['order_by_type']) ? 'desc' : $params['order_by_type']; // 用户信息 $this->params['user_id'] = isset($this->user['id']) ? $this->user['id'] : 0; } /** * 获取商品列表 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2018-09-07 * @desc description */ public function GoodsList() { // 参数初始化 $this->ParamsInit(); // 获取商品列表 $this->params['keywords'] = $this->params['wd']; $ret = SearchService::GoodsList($this->params); if(empty($ret['data']['data'])) { $msg = '没有相关数据'; $code = -100; } else { $msg = '操作成功'; $code = 0; } // 搜索记录 SearchService::SearchAdd($this->params); // 返回 return DataReturn($msg, $code, $ret['data']); } } ?>