Authored by yangyang

根据app访问调整跳转地址

@@ -66,26 +66,25 @@ class Yohobuy @@ -66,26 +66,25 @@ class Yohobuy
66 public static function clientType() 66 public static function clientType()
67 { 67 {
68 if(self::isMobile()) { 68 if(self::isMobile()) {
69 - return 'h5'; 69 + // 苹果设备
  70 + if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
  71 + return 'iphone';
  72 + }
  73 + // 苹果IPAD
  74 + elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
  75 + return 'ipad';
  76 + }
  77 + elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
  78 + return 'android';
  79 + }
  80 + // 其它
  81 + else {
  82 + return 'h5';
  83 + }
70 } 84 }
71 else { 85 else {
72 return 'web'; 86 return 'web';
73 } 87 }
74 -// // 苹果设备  
75 -// if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {  
76 -// return 'iphone';  
77 -// }  
78 -// // 苹果IPAD  
79 -// elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {  
80 -// return 'ipad';  
81 -// }  
82 -// elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {  
83 -// return 'android';  
84 -// }  
85 -// // 其它  
86 -// else {  
87 -// return 'android';  
88 -// }  
89 } 88 }
90 89
91 /** 90 /**
@@ -19,6 +19,7 @@ use Api\Yohobuy; @@ -19,6 +19,7 @@ use Api\Yohobuy;
19 */ 19 */
20 class StarClassModel 20 class StarClassModel
21 { 21 {
  22 + public static $_isApp = false;
22 23
23 /* 星潮教室首页楼层资源的位置码 */ 24 /* 星潮教室首页楼层资源的位置码 */
24 const CODE_FLOOR_STARCLASS_INDEX = '8adc27fcf5676f356602889afcfd2a8e'; 25 const CODE_FLOOR_STARCLASS_INDEX = '8adc27fcf5676f356602889afcfd2a8e';
@@ -31,8 +32,10 @@ class StarClassModel @@ -31,8 +32,10 @@ class StarClassModel
31 * @param $uid 32 * @param $uid
32 * @return array 33 * @return array
33 */ 34 */
34 - public static function getStarClass($uid) 35 + public static function getStarClass($uid, $isApp)
35 { 36 {
  37 + self::$_isApp = $isApp;
  38 +
36 $result = array(); 39 $result = array();
37 //头部导航 40 //头部导航
38 $result['headTab'] = self::getHeadTab('index'); 41 $result['headTab'] = self::getHeadTab('index');
@@ -102,8 +105,9 @@ class StarClassModel @@ -102,8 +105,9 @@ class StarClassModel
102 * 星专题 105 * 星专题
103 * @return array 106 * @return array
104 */ 107 */
105 - public static function getspecial() 108 + public static function getspecial($isApp)
106 { 109 {
  110 + self::$_isApp = $isApp;
107 $result = array(); 111 $result = array();
108 //头部导航 112 //头部导航
109 $result['headTab'] = self::getHeadTab('special'); 113 $result['headTab'] = self::getHeadTab('special');
@@ -165,7 +169,7 @@ class StarClassModel @@ -165,7 +169,7 @@ class StarClassModel
165 foreach ($data['data']['list']['artList'] as $key => $value) { 169 foreach ($data['data']['list']['artList'] as $key => $value) {
166 //获得原尺寸图片 170 //获得原尺寸图片
167 $collocationList[$key]['img'] = Helpers::getOriginalImg($value['src']); 171 $collocationList[$key]['img'] = Helpers::getOriginalImg($value['src']);
168 - $collocationList[$key]['url'] = $value['url']; 172 + $collocationList[$key]['url'] = $isApp ? $value['url'] : Helpers::getFilterUrl($value['url']);
169 $collocationList[$key]['title'] = $value['title']; 173 $collocationList[$key]['title'] = $value['title'];
170 $collocationList[$key]['content'] = $value['intro']; 174 $collocationList[$key]['content'] = $value['intro'];
171 $collocationList[$key]['time'] = $value['publish_time']; 175 $collocationList[$key]['time'] = $value['publish_time'];
@@ -307,9 +311,10 @@ class StarClassModel @@ -307,9 +311,10 @@ class StarClassModel
307 */ 311 */
308 public static function single_name_image($data) 312 public static function single_name_image($data)
309 { 313 {
  314 + $isApp = self::$_isApp;
310 $result = array(); 315 $result = array();
311 316
312 - $result['url'] = $data['url']; 317 + $result['url'] = $isApp ? $data['url'] : Helpers::getFilterUrl($data['url']);
313 $result['img'] = Helpers::getOriginalImg($data['src']); 318 $result['img'] = Helpers::getOriginalImg($data['src']);
314 $result['title'] = $data['title']; 319 $result['title'] = $data['title'];
315 $result['subject'] = true; 320 $result['subject'] = true;
@@ -325,10 +330,11 @@ class StarClassModel @@ -325,10 +330,11 @@ class StarClassModel
325 */ 330 */
326 public static function focus($data) 331 public static function focus($data)
327 { 332 {
  333 + $isApp = self::$_isApp;
328 $result = array(); 334 $result = array();
329 335
330 foreach ($data as $key=>$value) { 336 foreach ($data as $key=>$value) {
331 - $result['banner'][$key]['url'] = $value['url']; 337 + $result['banner'][$key]['url'] = $isApp ? $value['url'] : Helpers::getFilterUrl($value['url']);
332 $result['banner'][$key]['img'] = Helpers::getOriginalImg($value['src']); 338 $result['banner'][$key]['img'] = Helpers::getOriginalImg($value['src']);
333 $result['banner'][$key]['bgColor'] = $value['bgColor']; 339 $result['banner'][$key]['bgColor'] = $value['bgColor'];
334 $result['banner'][$key]['title'] = $value['title']; 340 $result['banner'][$key]['title'] = $value['title'];
@@ -346,12 +352,14 @@ class StarClassModel @@ -346,12 +352,14 @@ class StarClassModel
346 */ 352 */
347 public static function title_image($data) 353 public static function title_image($data)
348 { 354 {
  355 + $isApp = self::$_isApp;
  356 +
349 $result = array(); 357 $result = array();
350 358
351 $result['title']['title'] = $data['title']; 359 $result['title']['title'] = $data['title'];
352 $result['title']['more_url'] = $data['more_url']; 360 $result['title']['more_url'] = $data['more_url'];
353 $result['title']['moreName'] = $data['more_name']; 361 $result['title']['moreName'] = $data['more_name'];
354 - $result['subjectBanner']['url'] = $data['image']['url']; 362 + $result['subjectBanner']['url'] = $isApp ? $data['image']['url'] : Helpers::getFilterUrl($data['image']['url']);
355 $result['subjectBanner']['img'] = Helpers::getOriginalImg($data['image']['src']); 363 $result['subjectBanner']['img'] = Helpers::getOriginalImg($data['image']['src']);
356 $result['starSubject'] = true; 364 $result['starSubject'] = true;
357 365
@@ -365,10 +373,11 @@ class StarClassModel @@ -365,10 +373,11 @@ class StarClassModel
365 */ 373 */
366 public static function single_image($data) 374 public static function single_image($data)
367 { 375 {
  376 + $isApp = self::$_isApp;
368 $result = array(); 377 $result = array();
369 378
370 $result['videoImg'] = Helpers::getOriginalImg($data[0]['src']); 379 $result['videoImg'] = Helpers::getOriginalImg($data[0]['src']);
371 - $result['videoUrl'] = $data[0]['url']; 380 + $result['videoUrl'] = $isApp ? $data[0]['url'] : Helpers::getFilterUrl($data[0]['url']);
372 $result['alt'] = $data[0]['alt']; 381 $result['alt'] = $data[0]['alt'];
373 $result['title'] = $data[0]['title']; 382 $result['title'] = $data[0]['title'];
374 $result['video'] = true; 383 $result['video'] = true;
@@ -383,6 +392,7 @@ class StarClassModel @@ -383,6 +392,7 @@ class StarClassModel
383 */ 392 */
384 public static function match_image($data) 393 public static function match_image($data)
385 { 394 {
  395 + $isApp = self::$_isApp;
386 $result = array(); 396 $result = array();
387 397
388 //title 398 //title
@@ -392,13 +402,13 @@ class StarClassModel @@ -392,13 +402,13 @@ class StarClassModel
392 402
393 //两张大图 403 //两张大图
394 foreach ($data['top_image'] as $key=>$value) { 404 foreach ($data['top_image'] as $key=>$value) {
395 - $result['collocationBigImg'][$key]['url'] = $value['url']; 405 + $result['collocationBigImg'][$key]['url'] = $isApp ? $value['url']: Helpers::getFilterUrl($value['url']);
396 $result['collocationBigImg'][$key]['img'] = Helpers::getOriginalImg($value['src']); 406 $result['collocationBigImg'][$key]['img'] = Helpers::getOriginalImg($value['src']);
397 } 407 }
398 408
399 //n张小图 409 //n张小图
400 foreach ($data['list'] as $key=>$value) { 410 foreach ($data['list'] as $key=>$value) {
401 - $result['collocationList'][$key]['url'] = $value['url']; 411 + $result['collocationList'][$key]['url'] = $isApp ? $value['url'] : Helpers::getFilterUrl($value['url']);
402 $result['collocationList'][$key]['img'] = Helpers::getOriginalImg($value['src']); 412 $result['collocationList'][$key]['img'] = Helpers::getOriginalImg($value['src']);
403 } 413 }
404 414
@@ -33,15 +33,16 @@ class StarClassController extends AbstractAction @@ -33,15 +33,16 @@ class StarClassController extends AbstractAction
33 } 33 }
34 } 34 }
35 //设置头部公共导航 35 //设置头部公共导航
36 - $isApp = $this->getCookie('isApp', false);  
37 -  
38 - if (!($isApp || $this->_isApp)) { 36 + $app = $this->getCookie('isApp', false);
  37 + $isApp = $app || $this->_isApp;
  38 + if (!$isApp) {
39 $this->setNavHeader('星潮教室', true, false); 39 $this->setNavHeader('星潮教室', true, false);
40 } 40 }
41 41
42 $this->setTitle('星潮教室', false, ''); 42 $this->setTitle('星潮教室', false, '');
43 //调用模型获得星潮教室首页数据 43 //调用模型获得星潮教室首页数据
44 - $data = StarClassModel::getStarClass($uid); 44 + $data = StarClassModel::getStarClass($uid, $isApp);
  45 +
45 //渲染模板 46 //渲染模板
46 $this->_view->display('index', array( 47 $this->_view->display('index', array(
47 'trendClassHome' => $data, 48 'trendClassHome' => $data,
@@ -66,7 +67,7 @@ class StarClassController extends AbstractAction @@ -66,7 +67,7 @@ class StarClassController extends AbstractAction
66 $this->setTitle('星潮教室', false, ''); 67 $this->setTitle('星潮教室', false, '');
67 68
68 //调用模型获得星专题数据 69 //调用模型获得星专题数据
69 - $data = StarClassModel::getspecial(); 70 + $data = StarClassModel::getspecial($isApp);
70 71
71 //渲染模板 72 //渲染模板
72 $this->_view->display('subject', array( 73 $this->_view->display('subject', array(