微擎框架下拉分页(使用js模板引擎)

script language="javascript" src="/upload/attach/blank.gif" data-echo="\addons\{$_GPC[‘m‘]}\template\mobile\js/config.js"/script!--分页相关--
style type="text/css"
.credit_list {height:40px; width:94%; background:#fff; padding:10px 3%;margin-top:5px;}
.credit_list .info {height:40px; width:70%; float:left; font-size:16px; color:#666; line-height:20px; text-align:left;}
.credit_list .info span {font-size:14px; color:#999;}
.credit_list .num {height:40px; border-left:1px solid #eaeaea; width:20%;line-height:40px; float:right; text-align:right; font-size:16px; color:#666;}
.credit_list .num span {font-size:14px; color:#999;}
.credit_tab {height:30px; margin:5px; border:1px solid #ff6801; border-radius:5px; overflow:hidden;font-size:13px;background:#fff;padding-right: -2px;}
.credit_nav {height:30px; width:50%; background:#fff; color:#666; text-align:center; line-height:30px; float:left;}
.credit_navon {color:#fff; background:#ff6801;}
.credit_no {height:100px; width:100%; margin:50px 0px 60px; color:#ccc; font-size:12px; text-align:center;}
#credit_loading { padding:10px;color:#666;text-align: center;}
/style

====================================

发起请求

script language="javascript"

require([‘core‘,‘tpl‘],function(core,tpl){//分页相关请求
core.init({
siteUrl: "{$_W[‘siteroot‘]}",
baseUrl: "{$_SERVER[‘REQUEST_URI‘]}"
});

})
/script

========================================

循环,注意最外面div的id

div class="weui-form-preview"class="credit_loading_zzjz"i class="fa fa-spinner fa-spin"/i 正在加载.../div‘);
setTimeout(function(){
$(".credit_loading_zzjz").remove()
},2000);

page++;
core.json(‘wdyy‘, {type:current_type,page: page}, function (json) {
stop = true;
var morejson = json;
$(‘#credit_loading‘).remove();
$("#container").append(tpl(‘tpl_log‘,morejson.resu< ));
if (morejson.resu< .list.len >h morejson.resu< .pagesize) {
$("#container").append(‘div已经加载完全部记录/div‘);
loaded = true;
$(window).scroll = null;
return;
}
}, true);
}
}
});
}
function getLog(type) {
$(‘.weui-navbar__item‘).removeClass(‘weui-bar__item_on‘);
$(‘.weui-navbar__item[data-type=‘ + type + ‘]‘).addClass(‘weui-bar__item_on‘);
core.json(‘wdyy‘, {type:type,page: page}, function (json) {
if (json.resu< .list.len >h = 0) {
$(‘#container‘).html(tpl(‘tpl_empty‘));
return;
}
$(‘#container‘).html(tpl(‘tpl_log‘, json.resu< ));
bindScroller();
}, true);
}
$(‘.weui-navbar__item‘).unbind(‘click‘).click(function () {
page = 1; current_type = $(this).data(‘type‘)
getLog(current_type);

});
getLog(current_type);
})
/script

2.php页面

public function show_json($status = 1, $return = null)
{//分页的函数
$ret = array(
‘status‘ = $status
);
if ($return) {
$ret[‘resu< ‘] = $return;
}
die(json_encode($ret));
}

=================================================

页码定义

$page=(int)($_GET[‘page‘]);
if(empty($page)||!isset($page)){
$page=1;
}
$pagesize=10;

返回方式

if ($_W[‘isajax‘]) {

$this-show_json(1, array(
‘pagesize‘=$pagesize,
‘list‘ = $xmlist
));
}

微擎框架下拉分页(使用js模板引擎)

原文地址:http://www.cnblogs.com/weiyiyong/p/7251508.html


最新回复(0)
/jishu4ffyh0GfHaxXlriz9FAvaF7TIBHSqQqgxp25vnKrbOk_3D4719444
8 简首页