Authored by whb

Merge branch 'temp'

@@ -12,7 +12,6 @@ @@ -12,7 +12,6 @@
12 namespace Api; 12 namespace Api;
13 13
14 use Plugin\Cache; 14 use Plugin\Cache;
15 -  
16 class Yohobuy 15 class Yohobuy
17 { 16 {
18 /* 正式环境 */ 17 /* 正式环境 */
@@ -68,6 +67,13 @@ class Yohobuy @@ -68,6 +67,13 @@ class Yohobuy
68 */ 67 */
69 public static function clientType() 68 public static function clientType()
70 { 69 {
  70 +// if(self::isMobile()) {
  71 +// return 'h5';
  72 +// }
  73 +// else {
  74 +// return 'web';
  75 +// }
  76 +
71 // 苹果设备 77 // 苹果设备
72 if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) { 78 if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
73 return 'iphone'; 79 return 'iphone';
@@ -486,4 +492,37 @@ class Yohobuy @@ -486,4 +492,37 @@ class Yohobuy
486 492
487 return $result; 493 return $result;
488 } 494 }
  495 +
  496 + /**
  497 + * 获取用户User-Agent
  498 + * @return bool
  499 + */
  500 + public static function getUserAgent()
  501 + {
  502 + if (!isset($_SERVER['HTTP_USER_AGENT']) || empty($_SERVER['HTTP_USER_AGENT'])) {
  503 + return '';
  504 + }
  505 + return $_SERVER['HTTP_USER_AGENT'];
  506 + }
  507 +
  508 + /**
  509 + * 判断是否手机
  510 + * @return bool
  511 + */
  512 + public static function isMobile()
  513 + {
  514 + $userAgent = self::getUserAgent();
  515 + if (stristr($userAgent, 'ipad')) {
  516 + return false;
  517 + }
  518 + $mobileAgents = array('iphone','android',"240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
  519 + $isMobile = false;
  520 + foreach ($mobileAgents as $device) {
  521 + if (stristr($userAgent, $device)) {
  522 + $isMobile = true;
  523 + break;
  524 + }
  525 + }
  526 + return $isMobile;
  527 + }
489 } 528 }
@@ -68,7 +68,7 @@ class InfoModel @@ -68,7 +68,7 @@ class InfoModel
68 */ 68 */
69 public static function formatInfo($article, $data, $channel, $limit) 69 public static function formatInfo($article, $data, $channel, $limit)
70 { 70 {
71 - $result = array(); 71 + $result['content'] = $other = array();
72 //推荐商品列表 72 //推荐商品列表
73 $goods = $goodsGroup = array(); 73 $goods = $goodsGroup = array();
74 $result['pathNav'] = self::getCenterCrumb($article['article_title'], $channel); 74 $result['pathNav'] = self::getCenterCrumb($article['article_title'], $channel);
@@ -93,16 +93,17 @@ class InfoModel @@ -93,16 +93,17 @@ class InfoModel
93 } elseif ($type === 'goodsGroup') { 93 } elseif ($type === 'goodsGroup') {
94 $goodsGroup = array_merge_recursive($goodsGroup, self::goodsGroup($con['data'])); 94 $goodsGroup = array_merge_recursive($goodsGroup, self::goodsGroup($con['data']));
95 } else { 95 } else {
96 - $result['content'] = is_callable("self::$type") ? self::$type($con['data']) : ''; 96 + $other = is_callable("self::$type") ? self::$type($con['data']) : '';
  97 + array_push($result['content'], $other);
97 } 98 }
98 } 99 }
99 } 100 }
100 } 101 }
101 if (!empty($goods)) { 102 if (!empty($goods)) {
102 - $result['content'][] = array('relatedReco'=>array('recos'=>$goods)); 103 + $result['content'][]['relatedReco'] = array('recos'=>$goods);
103 } 104 }
104 if (!empty($goodsGroup)) { 105 if (!empty($goodsGroup)) {
105 - $result['content']['relatedReco'] = $goodsGroup; 106 + $result['content'][]['relatedReco'] = $goodsGroup;
106 } 107 }
107 //赞、收藏 108 //赞、收藏
108 if (isset($data['baseInfo']) && !empty($data['baseInfo'])) { 109 if (isset($data['baseInfo']) && !empty($data['baseInfo'])) {