<?php include_once(mvc::$cfg['PATH_TPL'].'public/headBase.php');?>
<link rel="stylesheet" type="text/css" href="<?php echo mvc::$cfg['SYS_URL'];?>static/css/user.css?ver=<?php echo mvc::$cfg['VER']['css'];?>">
<header class="mui-bar mui-bar-nav">
    <h1 class="mui-title">最新动态</h1>
</header>
<div class="mui-content ord-list mui-scroll-wrapper" id="refreshContainer" style="padding-top: 44px;">
	<div class="mui-scroll">
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper news_box item-con item-li">
			<div class="news_box_content">
				<!--数据列表-->
				<ul class="mui-table-view mui-table-view-chevron"></ul>
			</div>
		</div>
		<script type="text/javascript">
			mui.init({
			  pullRefresh : {
			    container:'#pullrefresh',//待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
			    up : {
			      height:50,//可选.默认50.触发上拉加载拖动距离
			      auto:true,//可选,默认false.自动上拉加载一次
			      contentrefresh : "正在加载...",//可选，正在加载状态时，上拉加载控件上显示的标题内容
			      contentnomore:'没有更多数据了',//可选，请求完毕若没有更多数据时显示的提醒内容；
			      callback :function(){
			      	$('.item-li').show();
			      	var _this=this;
					_this.page=_this.page||1;
			      	$.get(SELF_URI+'index/getNewsLists?isAjax=1',{"page":_this.page},function(res){
			      		if(res['data'].length>0){
			      			var html='';
			      			var items=res['data'];
			      			for(var i in items){
			      				var img=(items[i]['art_imgs']!=undefined&&items[i]['art_imgs'][0]!=undefined)?items[i]['art_imgs'][0]:'';
			      				var imgHtml=img==''?'':'<img src="'+img+'">';
					      		html+=`<li style="background-color: #f9f9f9; padding: 0.8rem; margin-bottom: 10px;">
											<a href="javascript:;" data-href="`+SELF_URI+`index/new?aId=`+items[i]['art_id']+`">
												`+imgHtml+`
												<p class="news_title">`+items[i]['art_name']+`</p>
												<p>`+items[i]['time']+`</p>
											</a>
										</li>`;
			      			}
							$('#pullrefresh ul').append(html);
							_this.endPullupToRefresh(false);
			      		}else{
			      			_this.endPullupToRefresh(true);
			      		}
						_this.page++;
			      	},'json');
			      } //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
			    }
			  }
			});
		</script>
	</div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footBase.php');?>
