因为专注,所以专业
2005 - 2019

手机版上拉刷新dropload结合arttemplate实现

时间:2018-08-20 20:01:56    作者:八叔模板堂

话不多说,直接上代码

{js:artTemplate}
<link href="{theme:javascript/dropload/dropload.css}" rel="stylesheet" />
<script type="text/javascript" src="{theme:javascript/dropload/dropload.min.js}"></script>

<div class="newly_box">
	<div id="content"></div>
</div>

<script type='text/html' id='shuoTemplate'>
<%for(var item in templateData){%>
<%item = templateData[item]%>
<a class="say_box" href="<%=item['url']%>">
        <div class="user_info">
            <img onerror="src='{skin:images/avatar.png}'" src="<%=item['head_ico']%>">
            <div class="user_info_text">
                <strong><%=item['username']%></strong>
                <p><span class="started"><%=item['date']%></span><span>婚期:<% if(item['wedding_data']){%><%=item['wedding_data']%><% }else{%>婚期未设置<% }%></span></p>
            </div>
        </div>
		<% if(item['imgs'].length > 0){ %>
        <div class="pic_newly_box">
        	<div class='post <% if(item['imgs'].length == 1){%>xs0-1<% }else if(item['imgs'].length == 2 || item['imgs'].length == 4){%>xs2-4<% }%>'>
			<% for(var im in item['imgs']){%>
            <img src="<%=item['imgs'][im]%>" data-big="<%=item['bigimg'][im]%>">
			<% }%>
            </div>
        </div>
		<% }%>
        <div class="newly_text"><%=#item['content']%></div>
        <div class="newly_bottom">
			<% if(item['location']){ %>
        	<i class="iconfont icon-dingwei"><%=item['location']%></i>
			<% }%>
            <em class="iconfont icon-heart"><%=item['comments']%></em>
            <span class="iconfont icon-speak"><%=item['zans']%></span>
        </div>
    </a>
<%}%>
</script>

var page = 1;
var me = $('.newly_box').dropload({
	scrollArea : window,
	autoLoad: true,
	domDown : {
		domLoad : '<div class="coolc-load">&nbsp;</div>',
		domNoData : '<div class="coolc-noData"><span>到底了暂无数据</span></div>'
	},
	loadUpFn : function(){
		$.getJSON('{url:/ajax_data/shuoshuo_data}',{page:1},function(data){
			var shuoHtml = template.render('shuoTemplate',{"templateData":data});
			$('#content').html(shuoHtml);
			me.resetload();
		});	
	},
	loadDownFn : function(){
		$.getJSON('{url:/ajax_data/shuoshuo_data}',{page:page},function(data){
			if(data.length > 0){
				var shuoHtml = template.render('shuoTemplate',{"templateData":data});
				$('#content').append(shuoHtml);
				page++;
			}else{
				me.noData(true);
			}
			me.resetload();
		});	
	}
});
赞(243
免费拨打  199-7086-1797
免费拨打  199-7086-1797免费拨打 199-7086-1797
微信二维码
手机二维码
返回顶部
返回顶部返回顶部