Authored by yangyang

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into feature/web-list

... ... @@ -270,11 +270,11 @@ class SearchData extends \LibModels\Wap\Product\SearchData
}
/**
* 并行调接口url获取(产品分类)
* @param
* @param $condition
* @return string
*/
public static function getClassesUrl($condition)
public static function getClassesUrl($condition = array())
{
$condition['sales'] = 'Y'; //在销售商品分类
$condition['status'] = 1; //上架商品分类
... ... @@ -284,7 +284,8 @@ class SearchData extends \LibModels\Wap\Product\SearchData
/**
* 并行调接口url获取(获取折扣区间)
* @param
* @param array $param
* @return string
*/
public static function getDiscountUrl($param = array())
... ...
... ... @@ -151,6 +151,7 @@ class HelperSearch
/**
* TODO 组织商品列表信息
* @param $product 接口返回商品列表
* @param $options 条件
* @author sefon 2015-12-21 17:24:04
* @return array
*/
... ... @@ -1056,7 +1057,7 @@ class HelperSearch
* @param array $list
* @return array
*/
public static function getDiscount(array $list = array())
public static function getDiscount($list = array())
{
$params = self::$params;
$query = array();
... ... @@ -1390,4 +1391,65 @@ class HelperSearch
}
return $url;
}
public static function stripTags($html) {
$search = array(
' ',
"'<script[^>]*?>.*?</script>'si",
"'<[\/\!]*?[^<>]*?>'si",
"'([\r\n])[\s]+'",
"'&(quot|#34|#034|#x22);'i",
"'&(amp|#38|#038|#x26);'i",
"'&(lt|#60|#060|#x3c);'i",
"'&(gt|#62|#062|#x3e);'i",
"'&(nbsp|#160|#xa0);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&(reg|#174);'i",
"'&(deg|#176);'i",
"'&(#39|#039|#x27);'",
"'&(euro|#8364);'i",
"'&a(uml|UML);'",
"'&o(uml|UML);'",
"'&u(uml|UML);'",
"'&A(uml|UML);'",
"'&O(uml|UML);'",
"'&U(uml|UML);'",
"'&szlig;'i",
"\n",
"\r",
"\t",
"\0",
" "
);
return trim(str_replace($search, '', strip_tags($html,"")));
}
/**
*
* 按字来切分字符 (UTF-8截字)
*
* @param String $str
* @param Integer $length
* @param Integer $start
* @param String $encoding
* @return String
*/
public static function mbSubstr($str, $length, $start = 0, $suffix = '...', $encoding = "utf-8") {
if (!is_string($str)) {
return $str;
}
$str = trim($str);
if (mb_strlen($str) == $length) {
return $str;
}
$strs = mb_substr($str, $start, $length, $encoding);
if ((mb_strlen($str) / 3) > $length) {
$strs .= $suffix;
}
return $strs;
}
}
... ...
... ... @@ -157,9 +157,10 @@ class SearchModel
// 组合搜索商品url
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
//$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
$urlList['sort'] = SearchData::getClassesUrl();
// 组合搜索折扣区间url
$urlList['discount'] = SearchData::getDiscountUrl($searchCondition['condition']);
$urlList['discount'] = SearchData::getDiscountUrl();
$result = Yohobuy::getMulti($urlList);
// 组织模板数据
$data = HelperSearch::getList($result, $searchCondition['options']);
... ... @@ -275,4 +276,32 @@ class SearchModel
return HelperSearch::size($result['data']['filter'], true);
}
}
/**
* @param $keyword
* @return array
*/
public static function searchError($keyword) {
$keyword = HelperSearch::stripTags($keyword);
$keyword = HelperSearch::mbSubstr($keyword, 300);
$data = array(
//初始化js
'searchListPage' => true,
'search' => array(
'keyWord' => $keyword,
'searchActionUrl' => 'http://search.yohobuy.com',
'latestWalk' => 7,
'pathNav' => Array(
'0'=>array(
'href' => '/',
'name' => '首页'
),
'1'=>array(
'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'
)
)
)
);
return $data;
}
}
\ No newline at end of file
... ...
... ... @@ -66,14 +66,15 @@ class ListController extends WebAction
$options['controller'] = 'Index';
$options['action'] = 'sale';
$options['reviewNum'] = 6;
$condition = array(
'p_d' => '0.01,0.99'
);
$option = array(
'controller' => 'List',
'action' => 'sale',
'reviewNum' => 6
);
$condition = array();
if (!$this->get('p_d')){
$condition['p_d'] = '0.01,0.99';
}
$list = SearchModel::getListData($condition,$option);
$data = array(
//初始化js
... ...
... ... @@ -63,24 +63,7 @@ class SearchController extends WebAction
public function errorAction()
{
$keyword = $this->get('query');
$data = array(
//初始化js
'searchListPage' => true,
'search' => array(
'keyWord' => $keyword,
'searchActionUrl' => 'http:://search.yohobuy.com',
'latestWalk' => 7,
'pathNav' => Array(
'0'=>array(
'href' => '/',
'name' => '首页'
),
'1'=>array(
'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'
)
)
)
);
$data = SearchModel::searchError($keyword);
$this->setTitle('潮流商品搜索 | YOHO!有货');
$this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
$this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
... ...
... ... @@ -26,10 +26,18 @@ routes.searchsuggest.route.module = Product
routes.searchsuggest.route.controller = Search
routes.searchsuggest.route.action = suggest
;error(suggest 错误提示)
routes.searchsuggest.type = "rewrite"
routes.searchsuggest.match = "/error"
routes.searchsuggest.route.module = Product
routes.searchsuggest.route.controller = Search
routes.searchsuggest.route.action = error
;about(品牌介绍)
routes.brandabout.type = "rewrite"
routes.brandabout.match = "/about"
routes.brandabout.route.module = Product
routes.brandabout.route.controller = Index
routes.brandabout.route.action = about
\ No newline at end of file
routes.brandabout.route.action = about
... ...