').append().appendTo(_ucPagination.pageNumber); allNumber++; //添加前两行 var newItem = $(); for (var i = 1; i <= Math.floor((_ucPagination.NumberCount - 1) / 2); i++) { if (_ucPagination.current - i > 0) { var num = _ucPagination.current - i; //_ucPagination.ItemCreate(num).prependTo(_ucPagination.pageNumber); //追加到数组的开头。 liArray.unshift(_ucPagination.ItemCreate(num)); allNumber++; } } //添加后两行或者多行 var k = 1; while (allNumber < _ucPagination.NumberCount && (_ucPagination.current + k) <= _ucPagination.totalPage) { var num = (_ucPagination.current - 0 + k); //_ucPagination.ItemCreate(num).appendTo(_ucPagination.pageNumber); liArray.push(_ucPagination.ItemCreate(num)); k++; allNumber++; } //查看还够不够5个,从头添加,获取最小的数字 var firstNum = liArray[0].text() - 0; // _ucPagination.pageNumber.find("a").first().text() - 0; var k = 1; while (allNumber < _ucPagination.NumberCount && (firstNum - k) > 0) { var num = firstNum - k //_ucPagination.ItemCreate(num).prependTo(_ucPagination.pageNumber); liArray.unshift(_ucPagination.ItemCreate(num)); k++; allNumber++; } //插入数据 _ucPagination.Div = $("#ucPagination"); var ulAll = _ucPagination.Div.find("ul").empty(); var minNumber = 0; var maxNumber = 0; if (liArray.length) { minNumber = liArray[0].find("a").text() - 0; maxNumber = liArray[liArray.length - 1].find("a").text() - 0; } //上一页 var prePage = $("#ucpagebarTemp").find("[name=li_PrePage]").clone(); //上一页 //判断当前页是否是第一页,是第一页则上一页按钮变灰 if (_ucPagination.current == 1 || _ucPagination.current == 0) { prePage.attr("class", "y_pre j_prehui"); prePage.find("[name=li_PrePage_img]").attr("class", "l_page22"); } else { prePage.attr("class", "y_pre"); prePage.find("[name=li_PrePage_img]").attr("class", "l_page2"); } prePage.find("a").attr("page", _ucPagination.current > 1 ? _ucPagination.current - 1 : 0); ulAll.append(prePage); //... if (minNumber > 1) { var liPoints = $("#ucpagebarTemp").find("[name=li_points]").clone(); //... ulAll.append(liPoints); } //页码 $.each(liArray, function () { ulAll.append(this); }); //... if (maxNumber > 0 && maxNumber < _ucPagination.totalPage) { var liPoints = $("#ucpagebarTemp").find("[name=li_points]").clone(); //... ulAll.append(liPoints); } //下一页 var nextPage = $("#ucpagebarTemp").find("[name=li_NextPage]").clone(); //下一页 nextPage.find("a").attr("page", _ucPagination.current < _ucPagination.totalPage ? _ucPagination.current + 1 : 0); //判断当前页是否是最后一页 if (_ucPagination.current != 0 && _ucPagination.current == _ucPagination.totalPage) { nextPage.attr("class", "y_pre j_prehui"); nextPage.find("[name=li_NextPage_img]").attr("class", "l_page33"); } else { nextPage.attr("class", "y_pre"); nextPage.find("[name=li_NextPage_img]").attr("class", "l_page3"); } ulAll.append(nextPage); //统计信息 var li_msg = $("#ucpagebarTemp").find("[name=li_msg]").clone(); //统计信息 li_msg.find("[name=PageCount]").text(_ucPagination.totalPage); var tbCurPage = li_msg.find("[name=tbCurPage]"); tbCurPage.val(_ucPagination.current); tbCurPage.on("keyup", function (event) { this.value = this.value.replace(/\D/gi, ""); //只能输入数字 if (event.keyCode == 13) { _ucPagination.btPageJumpTo.click(); //点击确定按钮 } }); ulAll.append(li_msg); //按钮 var li_button = $("#ucpagebarTemp").find("[name=li_button]").clone(); //按钮 ulAll.append(li_button); _ucPagination.btPageJumpTo = li_button.find("[name=btPageJumpTo]"); //点去确定按钮 _ucPagination.btPageJumpTo.click(function () { var no = $.trim($("#ucPagination").find("[name=tbCurPage]").val()); if (no == "") { no = "1"; } var no = parseInt(no); //设置成数字 000=0 if (no == 0) { no = 1; } _ucPagination.tbCurPage.val(no); //消除空格,如果没有值，设定成1 _ucPagination.goPage = no; if (_ucPagination.goPage > 0 && _ucPagination.goPage <= _ucPagination.totalPage) { _ucPagination.tbCurPage.val(_ucPagination.goPage); //标记当前页 _ucPagination.LoadDate(); //可以由调用方法重新函数 } else { //alert("请输入正确的跳转页数"); layer.msg("请输入正确的跳转页数",{shift: -1}); } _ucPagination.tbCurPage.focus(); //文本框获取焦点。 _ucPagination.tbCurPage.select(); //全选 }); }; _ucPagination.ItemCreate = function (n) { var number = $("#ucpagebarTemp").find("[name=li_paegNumber]").clone(); //上一页 number.find("a").attr("page", n); number.find("a").text(n); if (_ucPagination.current == n) { //number.find("a").addClass("on"); number.addClass("cur"); } return number; }; _ucPagination.ItemClick = function (_this) { _ucPagination.goPage = $(_this).attr("page") - 0; if (_ucPagination.goPage > 0)//&& _ucPagination.goPage <= _ucPagination.totalPage) { _ucPagination.tbCurPage.val(_ucPagination.goPage); //标记当前页 _ucPagination.LoadDate(); //可以由调用方法重新函数 } }