Authored by Rock Zhang

逛频道优化-banner切换会根据章雷彪不同而不同

Code Review By Rock Zhang
{{> layout/header}}
<div class="guang-list-page guang-page yoho-page">
{{# guang}}
{{#if swiper}}
<div class="swiper-container">
<div class="swiper-wrapper">
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination"></div>
</div>
{{/if}}
<ul id="guang-nav" class="guang-nav clearfix">
{{# navs}}
... ... @@ -24,6 +9,22 @@
</li>
{{/ navs}}
</ul>
{{#if swiper}}
<div class="swiper-container">
<div class="swiper-wrapper">
{{# swiper}}
<div class="swiper-slide">
<a href="{{url}}">
<img class="swiper-lazy" data-src="{{img}}">
</a>
<div class="swiper-lazy-preloader"></div>
</div>
{{/ swiper}}
</div>
<div class="swiper-pagination"></div>
</div>
{{/if}}
<div id="info-list" class="info-list-container">
{{# infos}}
... ...
... ... @@ -315,6 +315,50 @@ class IndexModel
}
/**
* @param string $gender "1,3"表示男, "2,3"表示女
* @param int $sortId 分类ID
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @param string $tag 标签
* @param string $authorId 作者ID
* @param boolean $isApp 是否是APP
* @param boolean $showAuthor 是否显示作者
* @param boolean $isTab 是否为tab切换操作
* @return array
*/
public static function getPageData($gender, $sortId, $uid, $udid, $page, $tag, $authorId, $isApp, $showAuthor, $isTab)
{
$result = array();
do {
$article = ListData::article($gender, $sortId, $uid, $udid, $page, $tag, $authorId);
if (empty($article['data']['list']['artList'])) {
break;
}
// 广告列表
if ($isTab && !empty($article['data']['list']['adlist'])) {
foreach ($article['data']['list']['adlist'] as $value) {
$build = array();
$build['url'] = Helpers::getFilterUrl($value['url']);
$build['img'] = Helpers::getImageUrl($value['src'], 830, 327);
$data['guang']['swiper'][] = $build;
}
}
/* 构建资讯文章内容 */
$build = array();
foreach ($article['data']['list']['artList'] as $article) {
$build[] = Helpers::formatArticle($article, true, $isApp, $showAuthor, $uid);
}
$result['infos'] = $build;
} while (false);
return $result;
}
/**
* 构建信息内容
*
* @param array $data
... ...
<?php
use Action\AbstractAction;
use Guang\IndexModel;
use LibModels\Wap\Guang\ListData;
use Plugin\Helpers;
use Plugin\Cache;
... ... @@ -42,7 +43,7 @@ class IndexController extends AbstractAction
// $this->setNavSide();
// }
$this->_view->display('index', Guang\IndexModel::getArticle($gender, $type, $uid, $udid));
$this->_view->display('index', IndexModel::getArticle($gender, $type, $uid, $udid));
}
/**
... ... @@ -91,7 +92,7 @@ class IndexController extends AbstractAction
// 标签聚合内容列表
//$article = ListData::article($gender, 0, $uid, $udid, 1, $tag);
$article = Guang\IndexModel::getArticleByTagOrEditor($gender, 0, $uid, $udid, 1, $tag);
$article = IndexModel::getArticleByTagOrEditor($gender, 0, $uid, $udid, 1, $tag);
// 标签聚合内容不存在, 跳到错误页面
if (empty($article['data']['list']['artList'])) {
$this->error();
... ... @@ -184,7 +185,7 @@ class IndexController extends AbstractAction
// 标签聚合内容列表
//$article = ListData::article($gender, 0, $uid, $udid, 1, null, $id);
$article = Guang\IndexModel::getArticleByTagOrEditor($gender, 0, $uid, $udid, 1, null, $id);
$article = IndexModel::getArticleByTagOrEditor($gender, 0, $uid, $udid, 1, null, $id);
// 构建资讯文章内容
if (!empty($article['data']['list']['artList'])) {
$build = array();
... ... @@ -227,6 +228,7 @@ class IndexController extends AbstractAction
$gender = $this->get('gender');
$authorId = $this->get('authorId');
$isApp = $this->get('isApp', false);
$isTab = $this->get('isTab', false); // 是否为tab切换操作
$showAuthor = true;
if (!empty($sortId) && !is_numeric($sortId)) {
break;
... ... @@ -247,18 +249,7 @@ class IndexController extends AbstractAction
$udid = $this->getUdid();
}
//$page = intval($page) + 1;
$article = ListData::article($gender, $sortId, $uid, $udid, $page, $tag, $authorId);
if (empty($article['data']['list']['artList'])) {
break;
}
/* 构建资讯文章内容 */
$data = array();
$build = array();
foreach ($article['data']['list']['artList'] as $article) {
$build[] = Helpers::formatArticle($article, true, $isApp, $showAuthor, $uid);
}
$data['infos'] = $build;
$data = IndexModel::getPageData($gender, $sortId, $uid, $udid, $page, $tag, $authorId, $isApp, $showAuthor, $isTab);
} while (false);
if (isset($data)) {
... ...