真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

前后端結(jié)合怎么實(shí)現(xiàn)amazeUI分頁效果

這篇文章給大家分享的是有關(guān)前后端結(jié)合怎么實(shí)現(xiàn)amazeUI分頁效果的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

10余年的治多網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。網(wǎng)絡(luò)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整治多建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)公司從事“治多網(wǎng)站設(shè)計(jì)”,“治多網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

前端實(shí)現(xiàn)

1、引入paginator.js

(function ($) {
    $.fn.paginator = function (options) {
        //this指向當(dāng)前的選擇器
        var config = {
            url: "",
            pageParent: "",
            totalBars: -1,
            limit: -1,
            offset: 1,
            callback: null
        }
        //合并參數(shù)
        var opts = $.extend(config, options);
 
        opts.totalBars = Math.ceil(opts.totalBars / opts.limit);
        //計(jì)算按鈕的總個(gè)數(shù)
 
        //獲取offset參數(shù)
        var queryString = function (url) {
            var offset = (url.split("?")[1]).split("=")[1];
            return parseInt(offset);
        }
 
        //ajax核心方法,用于分頁的數(shù)據(jù)操作
        var ajaxCore = function (offset, fn) {
            $.ajax({
                "url": opts.url,
                "data": {
                    "offset": offset,
                    "limit": opts.limit
                },
                "dataType": "JSON",
                "method": "POST",
                "success": fn
            });
        }
 
        //重新裝配分頁按鈕
        var pageCore = function (offset) {
            if (opts.offset == offset) {
                return;
            } //如果是當(dāng)前頁面,那么就什么事都不用干了!
            else {
                ajaxCore(offset, opts.callback);
                $(opts.pageParent).empty();
                //否則,清空所有的節(jié)點(diǎn),重新向DOM插入新的分頁按鈕
                var output = "";
                var nextBar = offset == opts.totalBars ? "»" : "
  • »
  • ";                 var preBar = offset == 1 ? "«" : "
  • «
  • ";                 //組裝向上一個(gè)節(jié)點(diǎn)和下一頁節(jié)點(diǎn)                 if (opts.totalBars > 7) {                     if (offset < 5) {                         output += preBar;                         for (var i = 1; i <= 5; i++) {                             if (i == offset) {                                 output += "" + offset + "";                             } else {                                 output += "
  • " + i + "
  • ";                             }                         }                         output += "
  • ...
  • ";                         output += "
  • " + (opts.totalBars) + "
  • " + nextBar;                     } else if (offset >= 5 && offset <= opts.totalBars - 4) {                         //當(dāng)頁面大于7個(gè)的時(shí)候,那么在第五個(gè)和倒數(shù)第五個(gè)時(shí),執(zhí)行                         output += preBar;                         output += "
  • " + 1 + "
  • ";                         //第一個(gè)                         output += "
  • ...
  • "; //省略號                           output += "
  • " + (offset - 1) + "
  • ";                           output += "" + offset + "";                           output += "
  • " + (offset + 1) + "
  • ";                           output += "
  • ...
  • "; //省略號;                           output += "
  • " + (opts.totalBars) + "
  • "; //尾頁                           output += nextBar;                       } else if (offset > opts.totalBars - 4 && offset <= opts.totalBars) {                         //當(dāng)頁面位于倒數(shù)第四個(gè)時(shí)候                         output += preBar;                         output += "
  • " + 1 + "
  • " + "
  • ...
  • ";                           for (var j = 4; j >= 0; j--) {                             if (opts.totalBars - j == offset) {                                 output += "" + (opts.totalBars - j) + "";                             } else {                                 output += "
  • " + (opts.totalBars - j) + "
  • ";                             }                         }                         output += nextBar;                     } else {                         console.log("分頁數(shù)據(jù)出錯!");                         return;                     }                 } else {                     output += preBar;                     for (var i = 1; i <= opts.totalBars; i++) {                         if (i == offset) {                             output += "" + offset+ "";                         } else {                             output += "
  • " + i+ "
  • ";                         }                     }                     output += nextBar;                 }                 $(opts.pageParent).append(output);                 opts.offset = offset; //將偏移量賦值給config里面的offset             }         }           //清理函數(shù),防止多綁定事件和重新計(jì)算分頁         var clear = function () {             $(opts.pageParent).empty().undelegate();         }             //初始化裝配分頁按鈕         var init = function (fn) {             if (typeof (fn) != "function") {                 console.log("將不能正確的執(zhí)行回調(diào)函數(shù)");             } else {                 opts.callback = fn;             }             clear();             ajaxCore(1, opts.callback);//執(zhí)行初始化ajax方法             var preBar = "«";             //上一頁,(禁用的效果)             //如果只有一頁,那么禁用下一頁             var nextBar = opts.totalBars > 1 ? "
  • »
  • " : "»";             //最后一頁             var output = "1";               if (opts.totalBars <= 7) {                 for (var i = 1; i < opts.totalBars; i++) {                     output += "
  • " + (i + 1) + "
  • ";                 }             } else {                 for (var j = 1; j < 5; j++) {                     output += "
  • " + (j + 1) + "
  • ";                 }                 output += "
  • ...
  • ";                 output += "
  • " + (opts.totalBars) + "
  • ";             }             $(opts.pageParent).delegate("a","click", function () {                 var offset = queryString($(this).attr("yxhref"));                 console.log("ok");                 pageCore(offset);             });             $(opts.pageParent).append(preBar + output + nextBar);         };         init(opts.callback);//初始化分頁引擎     } }(window.jQuery))

    2、獲取總頁數(shù),再獲取分頁

    $.ajax({
            type: "GET",
            url: selectSendNumberNumsByContURL,//獲取總數(shù)
            data: {},
            dataType: "json",
            success: function(data){
    
                if (data[0].code == 200) {
    
                    $("#paginator").paginator({
                        url: selectSendNumberByContURL + "?offsets=",
                        pageParent: "#paginator",
                        totalBars: data[0].allNums,
                        limit: 10,
                        offset: 1,
                        callback: function (data1) {
    
                            //清空DOM節(jié)點(diǎn)
                            
                            //動態(tài)加dom節(jié)點(diǎn)
                        }
                    });
                }else{
    
                }
            },
            error: function (err) {
    
            }
        });

    后端實(shí)現(xiàn)(分頁)

    這里是controller,拿到offset(第幾頁)參數(shù)、limit(每頁多少數(shù)量),再寫SQL實(shí)現(xiàn)分頁就好了。

    @RequestMapping(value = "/selectNumberCheckByCont", method = RequestMethod.POST)
        @ResponseBody
        public List selectNumberCheckByCont(HttpServletRequest request,
                                                         HttpServletResponse response) throws Exception {
    
            //統(tǒng)一設(shè)置返回?cái)?shù)據(jù)格式
            response.setContentType("application/json");
            response.setHeader("Pragma", "no-cache");
            response.setCharacterEncoding("UTF-8");
    
            String offset = request.getParameter("offset");
            String limit = request.getParameter("limit");
    
            List list = iNumberCheckService.selectNumberCheckByCont(offset, limit);
    
            return list;
        }

    感謝各位的閱讀!關(guān)于“前后端結(jié)合怎么實(shí)現(xiàn)amazeUI分頁效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!


    當(dāng)前題目:前后端結(jié)合怎么實(shí)現(xiàn)amazeUI分頁效果
    本文來源:http://weahome.cn/article/ipppop.html

    其他資訊

    在線咨詢

    微信咨詢

    電話咨詢

    028-86922220(工作日)

    18980820575(7×24)

    提交需求

    返回頂部