Authored by whb

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

... ... @@ -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())
... ...
... ... @@ -27,6 +27,8 @@ class HelperSearch
public static $selected = array();
//list分类面包屑
public static $listNav = array();
//
public static $specialsaleParam = array();
//设置导航
private static function setListNav()
{
... ... @@ -149,6 +151,7 @@ class HelperSearch
/**
* TODO 组织商品列表信息
* @param $product 接口返回商品列表
* @param $options 条件
* @author sefon 2015-12-21 17:24:04
* @return array
*/
... ... @@ -350,10 +353,9 @@ class HelperSearch
);
$sortList = array();
//specialsale_id参数加上
$specialsaleParam = array();
//加上specialsale_id参数
if (self::$options['controller'] == 'Sale') {
$specialsaleParam = array(
self::$specialsaleParam = array(
'specialsale_id' => isset(self::$params['specialsale_id']) ? self::$params['specialsale_id'] : ''
);
}
... ... @@ -393,7 +395,7 @@ class HelperSearch
if (isset($val['sub']) && !empty($val['sub'])) {
foreach ($val['sub'] as $k => $v) {
$sortList[$key]['childList'][$k+1]['name'] = $v['sort_name'];
$sortList[$key]['childList'][$k+1]['href'] = self::buildUrl(array_merge($gender, array('msort' => $val['sort_id'], 'misort' => $v['sort_id']), $specialsaleParam));
$sortList[$key]['childList'][$k+1]['href'] = self::buildUrl(array_merge($gender, array('msort' => $val['sort_id'], 'misort' => $v['sort_id']), self::$specialsaleParam));
$sortList[$key]['childList'][$k+1]['childActive'] = isset(self::$params['misort']) && self::$params['misort'] == $v['sort_id'] ? true : false;
}
}
... ... @@ -1045,6 +1047,7 @@ class HelperSearch
if ($data) {
$result['conditions'] = $data;
$result['clearUrl'] = self::current();
}
return $result;
}
... ... @@ -1054,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();
... ... @@ -1109,6 +1112,9 @@ class HelperSearch
public static function current()
{
$url = explode('?', 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
if (!empty(self::$specialsaleParam)) {
$url[0] .= '?' . http_build_query(self::$specialsaleParam);
}
return $url[0];
}
/**
... ... @@ -1385,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;
}
}
... ...
... ... @@ -46,7 +46,7 @@ class SaleModel
$data['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
$data['saleBanner']['img'] = $special['banner'][0]['img'];
$data['saleTitle']['name'] = '全部商品';
$data['saleTitle']['count'] = $data['totalCount'];
$data['saleTitle']['count'] = isset($data['totalCount']) ? $data['totalCount'] : 0;
}
... ...
... ... @@ -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,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
... ...