Authored by yangyang

根据app访问调整跳转地址

... ... @@ -66,26 +66,25 @@ class Yohobuy
public static function clientType()
{
if(self::isMobile()) {
return 'h5';
// 苹果设备
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
return 'iphone';
}
// 苹果IPAD
elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
return 'ipad';
}
elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
return 'android';
}
// 其它
else {
return 'h5';
}
}
else {
return 'web';
}
// // 苹果设备
// if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
// return 'iphone';
// }
// // 苹果IPAD
// elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
// return 'ipad';
// }
// elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
// return 'android';
// }
// // 其它
// else {
// return 'android';
// }
}
/**
... ...
... ... @@ -19,6 +19,7 @@ use Api\Yohobuy;
*/
class StarClassModel
{
public static $_isApp = false;
/* 星潮教室首页楼层资源的位置码 */
const CODE_FLOOR_STARCLASS_INDEX = '8adc27fcf5676f356602889afcfd2a8e';
... ... @@ -31,8 +32,10 @@ class StarClassModel
* @param $uid
* @return array
*/
public static function getStarClass($uid)
public static function getStarClass($uid, $isApp)
{
self::$_isApp = $isApp;
$result = array();
//头部导航
$result['headTab'] = self::getHeadTab('index');
... ... @@ -102,8 +105,9 @@ class StarClassModel
* 星专题
* @return array
*/
public static function getspecial()
public static function getspecial($isApp)
{
self::$_isApp = $isApp;
$result = array();
//头部导航
$result['headTab'] = self::getHeadTab('special');
... ... @@ -165,7 +169,7 @@ class StarClassModel
foreach ($data['data']['list']['artList'] as $key => $value) {
//获得原尺寸图片
$collocationList[$key]['img'] = Helpers::getOriginalImg($value['src']);
$collocationList[$key]['url'] = $value['url'];
$collocationList[$key]['url'] = $isApp ? $value['url'] : Helpers::getFilterUrl($value['url']);
$collocationList[$key]['title'] = $value['title'];
$collocationList[$key]['content'] = $value['intro'];
$collocationList[$key]['time'] = $value['publish_time'];
... ... @@ -307,9 +311,10 @@ class StarClassModel
*/
public static function single_name_image($data)
{
$isApp = self::$_isApp;
$result = array();
$result['url'] = $data['url'];
$result['url'] = $isApp ? $data['url'] : Helpers::getFilterUrl($data['url']);
$result['img'] = Helpers::getOriginalImg($data['src']);
$result['title'] = $data['title'];
$result['subject'] = true;
... ... @@ -325,10 +330,11 @@ class StarClassModel
*/
public static function focus($data)
{
$isApp = self::$_isApp;
$result = array();
foreach ($data as $key=>$value) {
$result['banner'][$key]['url'] = $value['url'];
$result['banner'][$key]['url'] = $isApp ? $value['url'] : Helpers::getFilterUrl($value['url']);
$result['banner'][$key]['img'] = Helpers::getOriginalImg($value['src']);
$result['banner'][$key]['bgColor'] = $value['bgColor'];
$result['banner'][$key]['title'] = $value['title'];
... ... @@ -346,12 +352,14 @@ class StarClassModel
*/
public static function title_image($data)
{
$isApp = self::$_isApp;
$result = array();
$result['title']['title'] = $data['title'];
$result['title']['more_url'] = $data['more_url'];
$result['title']['moreName'] = $data['more_name'];
$result['subjectBanner']['url'] = $data['image']['url'];
$result['subjectBanner']['url'] = $isApp ? $data['image']['url'] : Helpers::getFilterUrl($data['image']['url']);
$result['subjectBanner']['img'] = Helpers::getOriginalImg($data['image']['src']);
$result['starSubject'] = true;
... ... @@ -365,10 +373,11 @@ class StarClassModel
*/
public static function single_image($data)
{
$isApp = self::$_isApp;
$result = array();
$result['videoImg'] = Helpers::getOriginalImg($data[0]['src']);
$result['videoUrl'] = $data[0]['url'];
$result['videoUrl'] = $isApp ? $data[0]['url'] : Helpers::getFilterUrl($data[0]['url']);
$result['alt'] = $data[0]['alt'];
$result['title'] = $data[0]['title'];
$result['video'] = true;
... ... @@ -383,6 +392,7 @@ class StarClassModel
*/
public static function match_image($data)
{
$isApp = self::$_isApp;
$result = array();
//title
... ... @@ -392,13 +402,13 @@ class StarClassModel
//两张大图
foreach ($data['top_image'] as $key=>$value) {
$result['collocationBigImg'][$key]['url'] = $value['url'];
$result['collocationBigImg'][$key]['url'] = $isApp ? $value['url']: Helpers::getFilterUrl($value['url']);
$result['collocationBigImg'][$key]['img'] = Helpers::getOriginalImg($value['src']);
}
//n张小图
foreach ($data['list'] as $key=>$value) {
$result['collocationList'][$key]['url'] = $value['url'];
$result['collocationList'][$key]['url'] = $isApp ? $value['url'] : Helpers::getFilterUrl($value['url']);
$result['collocationList'][$key]['img'] = Helpers::getOriginalImg($value['src']);
}
... ...
... ... @@ -33,15 +33,16 @@ class StarClassController extends AbstractAction
}
}
//设置头部公共导航
$isApp = $this->getCookie('isApp', false);
if (!($isApp || $this->_isApp)) {
$app = $this->getCookie('isApp', false);
$isApp = $app || $this->_isApp;
if (!$isApp) {
$this->setNavHeader('星潮教室', true, false);
}
$this->setTitle('星潮教室', false, '');
//调用模型获得星潮教室首页数据
$data = StarClassModel::getStarClass($uid);
$data = StarClassModel::getStarClass($uid, $isApp);
//渲染模板
$this->_view->display('index', array(
'trendClassHome' => $data,
... ... @@ -66,7 +67,7 @@ class StarClassController extends AbstractAction
$this->setTitle('星潮教室', false, '');
//调用模型获得星专题数据
$data = StarClassModel::getspecial();
$data = StarClassModel::getspecial($isApp);
//渲染模板
$this->_view->display('subject', array(
... ...