作者 刘朕
1 个管道 的构建 失败 耗费 11 秒

新闻问题修改

... ... @@ -112,11 +112,15 @@ class Index extends Frontend
}
public function loadNews(){
ini_set('memory_limit','512M');
$data = Db::name('news')
->field('id,name,flag,image,content,createtime,description,weigh')
->where('flag','<>','index')
->order('weigh','desc')
->select();
foreach($data as &$v){
$v['createtime_ym'] = date('Y-m',$v['createtime']);
$v['createtime_d'] = date('d',$v['createtime']);
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
echo json_encode($data);
... ...
... ... @@ -37,6 +37,26 @@
</div>
<!-- main -->
<div class="main">
<div class="main_con">
<ul class="main2_con">
{volist name="list" id="vo"}
<li>
<div class="main_left">
<p class="left1">{:date('Y-m',$vo.createtime)}</p>
<p class="left2">{:date('d',$vo.createtime)}</p>
</div>
<div class="main_right">
<h1>{$vo.name}</h1>
<p>{$vo.description}</p>
<a href="/index/index/news_detail?id={$vo.id}"><div class="more">阅读全文</div></a>
</div>
</li>
{/volist}
</ul>
<div class="btn">浏览更多</div>
</div>
</div>
<div class="main">
<div class="main_tit">
<img src="__CDN__/assets/mobileStyle/images/remen@2x.png">
<p>热门文章</p>
... ... @@ -64,6 +84,39 @@
</div>
<script type="text/javascript" src="__CDN__/assets/mobileStyle/js/jquery.js"></script>
<script type="text/javascript">
$('.btn').click(function(){
$.ajax({
type: 'GET',
url: '/index/index/loadNews',
data:{},
dataType: 'json',
success:function(data,msg,xhr){
console.log(data);
var arrLen = data.length;
var html = '';
if(arrLen>0){
$.each(data,function(i,val) {
html +='<li>';
html +='<div class="main_left">';
html +='<p class="left1">'+val['createtime_ym']+'</p>';
html +='<p class="left2">'+val['createtime_d']+'</p>';
html +='</div>';
html +='<div class="main_right">';
html +='<h1>'+val['name']+'</h1>';
html +='<p>'+val['description']+'</p>';
html +='<a href="/index/index/news_detail?id='+val['id']+'"><div class="more">阅读全文</div></a>';
html +='</div>';
html +='</li>';
});
}
setTimeout(function(){
$('.main2_con li').remove();
$('.main2_con').append(html);
$('.btn').hide();
},100);
}
})
});
$('footer').load('__CDN__/assets/mobileStyle/public/footer.html');
$('.header_right').click(function(){
$('.dh_down').slideToggle();
... ...
... ... @@ -164,4 +164,18 @@ html,body{
font-weight:400;
line-height:0.38rem;
color:rgba(80,80,80,1);
}
.btn {
width: 3.8rem;
height: .8rem;
margin: 0 auto;
cursor: pointer;
border: 1px solid #ccc;
border-radius: .12rem;
text-align: center;
line-height: .8rem;
background: #C50101;
font-size: .32rem;
font-weight: 300;
color: rgba(255,255,255,1);
}
\ No newline at end of file
... ...