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 @@ -270,11 +270,11 @@ class SearchData extends \LibModels\Wap\Product\SearchData
270 } 270 }
271 271
272 /** 272 /**
273 - * 并行调接口url获取(产品分类)  
274 - * @param 273 + * @param $condition
  274 + * @return string
275 */ 275 */
276 276
277 - public static function getClassesUrl($condition) 277 + public static function getClassesUrl($condition = array())
278 { 278 {
279 $condition['sales'] = 'Y'; //在销售商品分类 279 $condition['sales'] = 'Y'; //在销售商品分类
280 $condition['status'] = 1; //上架商品分类 280 $condition['status'] = 1; //上架商品分类
@@ -284,7 +284,8 @@ class SearchData extends \LibModels\Wap\Product\SearchData @@ -284,7 +284,8 @@ class SearchData extends \LibModels\Wap\Product\SearchData
284 284
285 /** 285 /**
286 * 并行调接口url获取(获取折扣区间) 286 * 并行调接口url获取(获取折扣区间)
287 - * @param 287 + * @param array $param
  288 + * @return string
288 */ 289 */
289 290
290 public static function getDiscountUrl($param = array()) 291 public static function getDiscountUrl($param = array())
@@ -151,6 +151,7 @@ class HelperSearch @@ -151,6 +151,7 @@ class HelperSearch
151 /** 151 /**
152 * TODO 组织商品列表信息 152 * TODO 组织商品列表信息
153 * @param $product 接口返回商品列表 153 * @param $product 接口返回商品列表
  154 + * @param $options 条件
154 * @author sefon 2015-12-21 17:24:04 155 * @author sefon 2015-12-21 17:24:04
155 * @return array 156 * @return array
156 */ 157 */
@@ -1056,7 +1057,7 @@ class HelperSearch @@ -1056,7 +1057,7 @@ class HelperSearch
1056 * @param array $list 1057 * @param array $list
1057 * @return array 1058 * @return array
1058 */ 1059 */
1059 - public static function getDiscount(array $list = array()) 1060 + public static function getDiscount($list = array())
1060 { 1061 {
1061 $params = self::$params; 1062 $params = self::$params;
1062 $query = array(); 1063 $query = array();
@@ -1390,4 +1391,65 @@ class HelperSearch @@ -1390,4 +1391,65 @@ class HelperSearch
1390 } 1391 }
1391 return $url; 1392 return $url;
1392 } 1393 }
  1394 +
  1395 +
  1396 + public static function stripTags($html) {
  1397 + $search = array(
  1398 + ' ',
  1399 + "'<script[^>]*?>.*?</script>'si",
  1400 + "'<[\/\!]*?[^<>]*?>'si",
  1401 + "'([\r\n])[\s]+'",
  1402 + "'&(quot|#34|#034|#x22);'i",
  1403 + "'&(amp|#38|#038|#x26);'i",
  1404 + "'&(lt|#60|#060|#x3c);'i",
  1405 + "'&(gt|#62|#062|#x3e);'i",
  1406 + "'&(nbsp|#160|#xa0);'i",
  1407 + "'&(iexcl|#161);'i",
  1408 + "'&(cent|#162);'i",
  1409 + "'&(pound|#163);'i",
  1410 + "'&(copy|#169);'i",
  1411 + "'&(reg|#174);'i",
  1412 + "'&(deg|#176);'i",
  1413 + "'&(#39|#039|#x27);'",
  1414 + "'&(euro|#8364);'i",
  1415 + "'&a(uml|UML);'",
  1416 + "'&o(uml|UML);'",
  1417 + "'&u(uml|UML);'",
  1418 + "'&A(uml|UML);'",
  1419 + "'&O(uml|UML);'",
  1420 + "'&U(uml|UML);'",
  1421 + "'&szlig;'i",
  1422 + "\n",
  1423 + "\r",
  1424 + "\t",
  1425 + "\0",
  1426 + " "
  1427 + );
  1428 + return trim(str_replace($search, '', strip_tags($html,"")));
  1429 + }
  1430 +
  1431 + /**
  1432 + *
  1433 + * 按字来切分字符 (UTF-8截字)
  1434 + *
  1435 + * @param String $str
  1436 + * @param Integer $length
  1437 + * @param Integer $start
  1438 + * @param String $encoding
  1439 + * @return String
  1440 + */
  1441 + public static function mbSubstr($str, $length, $start = 0, $suffix = '...', $encoding = "utf-8") {
  1442 + if (!is_string($str)) {
  1443 + return $str;
  1444 + }
  1445 + $str = trim($str);
  1446 + if (mb_strlen($str) == $length) {
  1447 + return $str;
  1448 + }
  1449 + $strs = mb_substr($str, $start, $length, $encoding);
  1450 + if ((mb_strlen($str) / 3) > $length) {
  1451 + $strs .= $suffix;
  1452 + }
  1453 + return $strs;
  1454 + }
1393 } 1455 }
@@ -157,9 +157,10 @@ class SearchModel @@ -157,9 +157,10 @@ class SearchModel
157 // 组合搜索商品url 157 // 组合搜索商品url
158 $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); 158 $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
159 // 组合搜索分类url 159 // 组合搜索分类url
160 - $urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']); 160 + //$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
  161 + $urlList['sort'] = SearchData::getClassesUrl();
161 // 组合搜索折扣区间url 162 // 组合搜索折扣区间url
162 - $urlList['discount'] = SearchData::getDiscountUrl($searchCondition['condition']); 163 + $urlList['discount'] = SearchData::getDiscountUrl();
163 $result = Yohobuy::getMulti($urlList); 164 $result = Yohobuy::getMulti($urlList);
164 // 组织模板数据 165 // 组织模板数据
165 $data = HelperSearch::getList($result, $searchCondition['options']); 166 $data = HelperSearch::getList($result, $searchCondition['options']);
@@ -275,4 +276,32 @@ class SearchModel @@ -275,4 +276,32 @@ class SearchModel
275 return HelperSearch::size($result['data']['filter'], true); 276 return HelperSearch::size($result['data']['filter'], true);
276 } 277 }
277 } 278 }
  279 +
  280 + /**
  281 + * @param $keyword
  282 + * @return array
  283 + */
  284 + public static function searchError($keyword) {
  285 + $keyword = HelperSearch::stripTags($keyword);
  286 + $keyword = HelperSearch::mbSubstr($keyword, 300);
  287 + $data = array(
  288 + //初始化js
  289 + 'searchListPage' => true,
  290 + 'search' => array(
  291 + 'keyWord' => $keyword,
  292 + 'searchActionUrl' => 'http://search.yohobuy.com',
  293 + 'latestWalk' => 7,
  294 + 'pathNav' => Array(
  295 + '0'=>array(
  296 + 'href' => '/',
  297 + 'name' => '首页'
  298 + ),
  299 + '1'=>array(
  300 + 'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'
  301 + )
  302 + )
  303 + )
  304 + );
  305 + return $data;
  306 + }
278 } 307 }
@@ -66,14 +66,15 @@ class ListController extends WebAction @@ -66,14 +66,15 @@ class ListController extends WebAction
66 $options['controller'] = 'Index'; 66 $options['controller'] = 'Index';
67 $options['action'] = 'sale'; 67 $options['action'] = 'sale';
68 $options['reviewNum'] = 6; 68 $options['reviewNum'] = 6;
69 - $condition = array(  
70 - 'p_d' => '0.01,0.99'  
71 - );  
72 $option = array( 69 $option = array(
73 'controller' => 'List', 70 'controller' => 'List',
74 'action' => 'sale', 71 'action' => 'sale',
75 'reviewNum' => 6 72 'reviewNum' => 6
76 ); 73 );
  74 + $condition = array();
  75 + if (!$this->get('p_d')){
  76 + $condition['p_d'] = '0.01,0.99';
  77 + }
77 $list = SearchModel::getListData($condition,$option); 78 $list = SearchModel::getListData($condition,$option);
78 $data = array( 79 $data = array(
79 //初始化js 80 //初始化js
@@ -63,24 +63,7 @@ class SearchController extends WebAction @@ -63,24 +63,7 @@ class SearchController extends WebAction
63 public function errorAction() 63 public function errorAction()
64 { 64 {
65 $keyword = $this->get('query'); 65 $keyword = $this->get('query');
66 - $data = array(  
67 - //初始化js  
68 - 'searchListPage' => true,  
69 - 'search' => array(  
70 - 'keyWord' => $keyword,  
71 - 'searchActionUrl' => 'http:://search.yohobuy.com',  
72 - 'latestWalk' => 7,  
73 - 'pathNav' => Array(  
74 - '0'=>array(  
75 - 'href' => '/',  
76 - 'name' => '首页'  
77 - ),  
78 - '1'=>array(  
79 - 'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'  
80 - )  
81 - )  
82 - )  
83 - ); 66 + $data = SearchModel::searchError($keyword);
84 $this->setTitle('潮流商品搜索 | YOHO!有货'); 67 $this->setTitle('潮流商品搜索 | YOHO!有货');
85 $this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流'); 68 $this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
86 $this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜'); 69 $this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
@@ -26,10 +26,18 @@ routes.searchsuggest.route.module = Product @@ -26,10 +26,18 @@ routes.searchsuggest.route.module = Product
26 routes.searchsuggest.route.controller = Search 26 routes.searchsuggest.route.controller = Search
27 routes.searchsuggest.route.action = suggest 27 routes.searchsuggest.route.action = suggest
28 28
  29 +;error(suggest 错误提示)
  30 +routes.searchsuggest.type = "rewrite"
  31 +routes.searchsuggest.match = "/error"
  32 +routes.searchsuggest.route.module = Product
  33 +routes.searchsuggest.route.controller = Search
  34 +routes.searchsuggest.route.action = error
29 35
30 ;about(品牌介绍) 36 ;about(品牌介绍)
31 routes.brandabout.type = "rewrite" 37 routes.brandabout.type = "rewrite"
32 routes.brandabout.match = "/about" 38 routes.brandabout.match = "/about"
33 routes.brandabout.route.module = Product 39 routes.brandabout.route.module = Product
34 routes.brandabout.route.controller = Index 40 routes.brandabout.route.controller = Index
35 -routes.brandabout.route.action = about  
  41 +routes.brandabout.route.action = about
  42 +
  43 +