zzwy2/view/article/news_list.html

129 lines
5.4 KiB
HTML
Raw Normal View History

2022-10-08 09:31:39 +00:00
{layout name="layout_two"/}
{php}
use app\model\Category;
use app\model\Article;
use app\model\Block;
$position = Category::getPosition($category["id"]);
$topNews = Article::getLastTopList($category["id"],1,[],["top"=>"desc"]);
$topNews = empty($topNews)?[]:$topNews[0];
$blocks = Block::getByCategoryId(Category::CATEGORY_NEWS_BLOCK);
$blocks = Block::convertValue($blocks);
{/php}
<div class="bannerdata">
<div class="img"><img src="{$category['src']}" alt="{$category['title']}"></div>
</div>
<div class="searceboxtop">
<div class="cont w1360">
<div class="navminbox">
{$position|raw}
</div>
</div>
</div>
<div class="contentboxer">
{if !empty($topNews)}
<div class="newsboxone">
<div class="cont w1360">
<a href="{:archiveGetUri($topNews)}" class="a"><div class="img"><img src="{$topNews['src']}" alt="{$topNews['title']}"></div></a>
<div class="text">
<div class="e wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0">{$topNews['create_time']|date="Y.m.d"}</div>
<a href="{:archiveGetUri($topNews)}" class="a">
<div class="h1 wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0.2s">
{$topNews['title']}
</div></a>
<div class="p wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0.4s">
{$topNews['summary']}
</div>
<a href="{:archiveGetUri($topNews)}" class="s wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0.6s">点击详情 +</a>
</div>
</div>
</div>
{/if}
<div class="newslist">
<div class="cont w1360">
<div class="left">
<div id="content">
{foreach $items as $item}
<div class="li wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0">
<a href="{:archiveGetUri($item)}">
<div class="time">
<div>
<div class="m">{$item['create_time']|date="d"}</div>
<div class="f">{$item['create_time']|date="Y-m"}</div>
</div>
</div>
<div class="text">
<div class="h1">{$item['title']}</div>
<div class="p">{$item['summary']}</div>
</div>
</a>
</div>
{/foreach}
</div>
<div class="more wow fadeInUp" id="more" data-wow-duration="0.8s" data-wow-delay="0">
<a href="javascript:;">更多+</a>
</div>
</div>
<div class="right">
{if !empty($blocks['img_1'])}
<a href="{$blocks['img_1']['link']}" class="wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0"><img src="{$blocks['img_1']['value']}" alt=""></a>
{/if}
{if !empty($blocks['img_2'])}
<a href="{$blocks['img_2']['link']}" class="wow fadeInUp" data-wow-duration="0.8s" data-wow-delay="0.2s"><img src="{$blocks['img_2']['value']}" alt=""></a>
{/if}
</div>
</div>
</div>
</div>
<script>
$(function () {
var page= 2;
$("#more").on("click",function () {
$.ajax('/article/ajaxList',{
data:{
category_id:{$category['id']},
page:page,
},
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
timeout:10000,//超时时间设置为10秒
success:function(data){
if(data.code == 0){
if(data.data.length > 0){
let html = '';
$.each(data.data,function(i,item){
html += `<div class="li ">
<a href="${item.uri}">
<div class="time">
<div>
<div class="m">${item.create_date_d}</div>
<div class="f">${item.create_date_y_m}</div>
</div>
</div>
<div class="text">
<div class="h1">${item.title}</div>
<div class="p">${item.summary}</div>
</div>
</a>
</div>`
})
$("#content").append(html);
page++;
}else{
$("#more").remove();
}
}
},
error:function(xhr,type,errorThrown){
}
});
})
})
</script>