调整活动列表

master
yin5th 2022-10-18 17:21:14 +08:00
parent 58e549aa3b
commit adc9adac1f
2 changed files with 30 additions and 15 deletions

View File

@ -187,4 +187,29 @@ class Article extends Base
return $this->json(0, 'ok', $items);
}
//获取活动列表
public function getActivity()
{
$categoryId = input('category_id/d', 0);
$page = input('page/d', 1);
$size = input('size/d', 10);
if ($categoryId <= 0) {
return $this->json(1, '参数错误');
}
$category = Category::getById($categoryId);
if (empty($category)) {
return $this->json(2, '栏目不存在');
}
$items = MArticle::findListByWhere(["category_id" => $categoryId, 'is_prev' => 0], $page, $size);
foreach ($items as $item) {
$item['uri'] = archiveGetUri($item);
$item['src'] = $this->isMobile ? $item['src_mobile'] : $item['src'];
}
return $this->json(0, 'ok', $items);
}
}

View File

@ -20,11 +20,8 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i
<p class="capitalize font-helvetica color-blue wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0">{$blocks['brand_activity']['value']}</p>
<strong class="wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0.2s">{$blocks['brand_activity']['title']}</strong>
</div>
{foreach $items as $k => $item}
{if $k%4==0}
<div class="activities-list flex">
{/if}
{foreach $items as $k => $item}
<a href="/activity/{$item.id}.html" class="activities-item flex wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0">
<div class="img"><img src="{$isMobile ? $item.src_mobile : $item.src}" alt="{$item.title}"></div>
<div class="txt bg-col-f5">
@ -33,12 +30,12 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i
<span class="article-more-btn color-blue">查看详情<img src="__STATIC__/web/images/icon/icon-arrow-more.png" alt="查看详情"></span>
</div>
</a>
{/foreach}
{if $k%3 == 0 || ($k == count($items) - 1)}</div>{/if}
{/foreach}
</div>
</div>
<div style="text-align: center;margin-top: 15px;display: none" class="show-msg">没有更多了</div>
<div class="load-more color-66 get-more-list" data-href="/article/getList?category_id={:Category::CATEGORY_BRAND_ACTIVITY}" data-page="2" data-size="{$category['number'] ?? 4}">点击加载更多</div>
<div class="load-more color-66 get-more-list" data-href="/article/getActivity?category_id={:Category::CATEGORY_BRAND_ACTIVITY}" data-page="2" data-size="{$category['number'] ?? 4}">点击加载更多</div>
</div>
<!-- 活动预告 -->
@ -86,10 +83,6 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i
}
let html = '';
$.each(res.data, function (index, item) {
console.log(index,'sdfdasfs')
if (index%4 === 0) {
html += `<div class="activities-list flex">`;
}
html += `
<a href="/activity/id=${item.id}.html" class="activities-item flex wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0">
<div class="img"><img src="${item.src}" alt="${item.title}"></div>
@ -100,13 +93,10 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i
</div>
</a>
`;
if (index === 3 || index=== (res.data.length - 1)) {
html += `</div>`;
}
})
page++;
that.data('page', page);
$('.brand-activities').append(html);
$('.activities-list').append(html);
html = '';
return false;
}