From adc9adac1f61980409c591b8298da2e3f5681687 Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Tue, 18 Oct 2022 17:21:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B4=BB=E5=8A=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Article.php | 25 +++++++++++++++++++++++++ view/page/activity.html | 20 +++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/app/controller/Article.php b/app/controller/Article.php index 7233238..642d285 100755 --- a/app/controller/Article.php +++ b/app/controller/Article.php @@ -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); + } } \ No newline at end of file diff --git a/view/page/activity.html b/view/page/activity.html index fb2ea7f..a65d315 100755 --- a/view/page/activity.html +++ b/view/page/activity.html @@ -20,11 +20,8 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i

{$blocks['brand_activity']['value']}

{$blocks['brand_activity']['title']} - {foreach $items as $k => $item} - {if $k%4==0} -
- {/if} + {foreach $items as $k => $item}
{$item.title}
@@ -33,12 +30,12 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i 查看详情查看详情
- {/foreach} - {if $k%3 == 0 || ($k == count($items) - 1)}
{/if} + {/foreach} + -
点击加载更多
+
点击加载更多
@@ -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 += `
`; - } html += `
${item.title}
@@ -100,13 +93,10 @@ $previewList = Article::getList(Category::CATEGORY_BRAND_ACTIVITY, 10, null, ['i
`; - if (index === 3 || index=== (res.data.length - 1)) { - html += ``; - } }) page++; that.data('page', page); - $('.brand-activities').append(html); + $('.activities-list').append(html); html = ''; return false; }