富贵资源网 Design By www.hznty.com
以前写的分页用了好久了,但是分页时除了传页面外有时还要传一些其它参数,以前操作时要把传的参数放到隐藏hidden中,分页时在取出来,这样比较麻烦,今天无事,重新包装了一下
直接上代码吧
css用了bootstrap中分页的样式
.pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span { border-bottom-left-radius: 6px; border-top-left-radius: 6px; } .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span { border-top-right-radius: 6px; border-bottom-right-radius: 6px; } .pagination-sm > li > a, .pagination-sm > li > span { padding: 5px 10px; font-size: 12px; } .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span { border-bottom-left-radius: 3px; border-top-left-radius: 3px; } .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
分页代码:
(function ($) { var PageFunc = function PageFunc() { } $.PageFunc = function (Total, PageSize, curPageNum, FunUrl,paramStr) { if (PageSize == "" || PageSize == null || PageSize == undefined) { PageSize = 10; } if (curPageNum == "" || curPageNum == null || curPageNum == undefined) { curPageNum = 1; } var hasParam=true; if (paramStr == "" || paramStr == null || paramStr == undefined) { hasParam = false; } //计算总页数 Total = parseInt(Total); //总记录数 PageSize = parseInt(PageSize); //每页显示数 curPageNum = parseInt(curPageNum); //当前页 //总页数 var AllPage = Math.floor(Total / PageSize); if (Total % PageSize != 0) { AllPage++; } var navHtml = "<ul style='margin:0 0 0 0;' class='pagination'>"; if (curPageNum <= 0) curPageNum = 1; if (AllPage > 1) { if (curPageNum != 1) { //处理首页连接 var home=1; if(hasParam) { home=home+","+paramStr; } navHtml += "<li><a href='javascript:" + FunUrl + "("+home+")' >|<</a></li>"; } if (curPageNum > 1) { var previous=parseInt(parseInt(curPageNum) - 1); if(hasParam) { previous=previous+","+paramStr; } //处理上一页的连接 navHtml += "<li><a href='javascript:"+FunUrl+"("+previous+")' ><<</a></li>"; } else { navHtml += "<li class='disabled'><a><<</a></li>"; } var currint = 5; for (var i = 0; i <= 10; i++) { //一共最多显示10个页码,前面5个,后面5个 if ((curPageNum + i - currint) >= 1 && (curPageNum + i - currint) <= AllPage) if (currint == i) { //当前页处理 navHtml += "<li class='active'><a>" + curPageNum + "<span class='sr-only'>(current)</span></a></li>"; } else { //一般页处理 var n = parseInt(parseInt(curPageNum) + parseInt(i) - parseInt(currint)); var nstr=n; if(hasParam) { nstr=nstr+","+paramStr; } navHtml += "<li><a href='javascript:" + FunUrl + "("+nstr+")'>" + n + "</a></li>"; } } if (curPageNum < AllPage) { //处理下一页的链接 var next=parseInt(parseInt(curPageNum) + 1); if(hasParam) { next=next+","+paramStr; } navHtml += "<li><a href='javascript:" + FunUrl + "("+next+")'></a></li>"; } else { navHtml += "<li class='disabled'><a></a></li>"; } if (curPageNum != AllPage) { var last=parseInt(AllPage); if(hasParam) { last=last+","+paramStr; } navHtml += "<li><a href='javascript:" + FunUrl + "("+last+")' |</a></li>"; } } if(parseInt(AllPage)!=0) { navHtml += "<li><a>" + curPageNum + "/" + AllPage + "</a></li> "; } navHtml+="</ul>"; return navHtml; }; })(jQuery);
调用方法:
注意:第一参数一定要是当前页的值啊
function aa(curpage,param1,param2){ if (curpage == "" || curpage == null || curpage == undefined) { curpage = 1; } var pagesize = 5; var paramStr=""; paramStr=param1+","+param2+"; $.post("/appdefult/apporder",{"categoryId":param1,"name":param2,"curpage":curpage,"pagesize":pagesize},function(mydata){ var pageHtml= $.PageFunc(mydata.total, pagesize, curpage, "aa",paramStr); $(".page").html(pageHtml); },"json"); }
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。