Authored by whb

Merge branch 'temp'

... ... @@ -12,7 +12,6 @@
namespace Api;
use Plugin\Cache;
class Yohobuy
{
/* 正式环境 */
... ... @@ -68,6 +67,13 @@ class Yohobuy
*/
public static function clientType()
{
// if(self::isMobile()) {
// return 'h5';
// }
// else {
// return 'web';
// }
// 苹果设备
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
return 'iphone';
... ... @@ -486,4 +492,37 @@ class Yohobuy
return $result;
}
/**
* 获取用户User-Agent
* @return bool
*/
public static function getUserAgent()
{
if (!isset($_SERVER['HTTP_USER_AGENT']) || empty($_SERVER['HTTP_USER_AGENT'])) {
return '';
}
return $_SERVER['HTTP_USER_AGENT'];
}
/**
* 判断是否手机
* @return bool
*/
public static function isMobile()
{
$userAgent = self::getUserAgent();
if (stristr($userAgent, 'ipad')) {
return false;
}
$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");
$isMobile = false;
foreach ($mobileAgents as $device) {
if (stristr($userAgent, $device)) {
$isMobile = true;
break;
}
}
return $isMobile;
}
}
... ...
... ... @@ -68,7 +68,7 @@ class InfoModel
*/
public static function formatInfo($article, $data, $channel, $limit)
{
$result = array();
$result['content'] = $other = array();
//推荐商品列表
$goods = $goodsGroup = array();
$result['pathNav'] = self::getCenterCrumb($article['article_title'], $channel);
... ... @@ -93,16 +93,17 @@ class InfoModel
} elseif ($type === 'goodsGroup') {
$goodsGroup = array_merge_recursive($goodsGroup, self::goodsGroup($con['data']));
} else {
$result['content'] = is_callable("self::$type") ? self::$type($con['data']) : '';
$other = is_callable("self::$type") ? self::$type($con['data']) : '';
array_push($result['content'], $other);
}
}
}
}
if (!empty($goods)) {
$result['content'][] = array('relatedReco'=>array('recos'=>$goods));
$result['content'][]['relatedReco'] = array('recos'=>$goods);
}
if (!empty($goodsGroup)) {
$result['content']['relatedReco'] = $goodsGroup;
$result['content'][]['relatedReco'] = $goodsGroup;
}
//赞、收藏
if (isset($data['baseInfo']) && !empty($data['baseInfo'])) {
... ...