Authored by 刘传洋

guagn zhuanti

... ... @@ -359,7 +359,7 @@ class Helpers
$result['id'] = $articleData['id'];
$result['classification'] = $articleData['category_name'];
$result['isReco'] = $articleData['is_recommended'] ? true : false;
$result['url'] = $isApp ? $articleData['url'] : self::url('/'.$articleData['id'].'.html', array(), 'guang');
$result['url'] = self::getArticleUrl($articleData['url'], $articleData['id'], $isApp);
$result['img'] = self::getImageUrl($articleData['src'], $width, $height, 1);
$result['isSquareImg'] = $isSquareImage;
$result['title'] = $articleData['title'];
... ... @@ -1146,4 +1146,34 @@ class Helpers
}
return 'http:';
}
/**
* 获得文章 url
* @param type string url 后台返回的url
* @param type $productSkn 产品编号
* @param type $productName 产品名称
* @param type $cnAlphaBet
* @return type url
*/
public static function getArticleUrl($url, $id, $isApp = false)
{
$rurl;
if(!empty($url)) {
try {
$jurl = json_decode($url);
if(!empty($jurl) && !empty($jurl->url)) {
$rurl = $jurl->url;
}
} catch(Exception $e){}
}
if(empty($rurl)) {
$rurl = $isApp ? $url : self::url('/'.$id.'.html', array(), 'guang');
}
return $rurl;
}
}
... ...
... ... @@ -75,9 +75,9 @@ class IndexModel
$data = ListData::category();
foreach($data['data'] as $category)
{
if ($category['name'] == '专题') {
continue;
}
// if ($category['name'] == '专题') {
// continue;
// }
$ret[] = array('typeId' => $category['id'],'type' => $category['name'],
'isActive' => $currentSortId == $category['id'] ? true :false,
... ... @@ -153,7 +153,7 @@ class IndexModel
if(!empty($data['data'])) {
foreach($data['data'] as $key => $article) {
$list[] = array(
'url' => Helpers::url('/'.$article['id'].'.html', '', 'guang'),
'url' => Helpers::getArticleUrl($article['url'], $article['id']), //Helpers::url('/'.$article['id'].'.html', '', 'guang'),
'title' => $article['title']
);
if (isset($article['src']) && !empty($article['src'])) {
... ...
... ... @@ -134,7 +134,7 @@ class InfoModel
foreach ($data['relate'] as $key => $val) {
$result['relatedPost'][$key]['title'] = $val['title'];
$result['relatedPost'][$key]['thumb'] = Images::getImageUrl($val['thumb'], 264, 173, 1);
$result['relatedPost'][$key]['url'] = Helpers::url('/'.$val['id'].'.html', array(), 'guang');
$result['relatedPost'][$key]['url'] = Helpers::getArticleUrl($val['url'], $val['id']); //Helpers::url('/'.$val['id'].'.html', array(), 'guang');
}
}
//精彩推荐
... ... @@ -142,7 +142,7 @@ class InfoModel
foreach ($data['recommend'] as $key => $val) {
$result['exRecos'][$key]['title'] = $val['title'];
$result['exRecos'][$key]['img'] = isset($val['src']) ? Images::getImageUrl($val['src'], 90, 60) : '';
$result['exRecos'][$key]['url'] = Helpers::url('/'.$val['id'].'.html', array(), 'guang');
$result['exRecos'][$key]['url'] = Helpers::getArticleUrl($val['url'], $val['id']); //Helpers::url('/'.$val['id'].'.html', array(), 'guang');
}
}
//热门标签
... ...