拼接分页 js

/**
*收藏或取消收藏
*/
function scSave(_this,id){
        var params={
            collect:trim($("#collect").val()),
            infoid:id,
            rnd:Math.random()
        }
        $.ajax({
              type:"post",
              url:"/userApi/collectOrNot",
              dataType: "json",
              async:true,
              data:params, 
        success: function(data){
                if(undefined==data||data==null) {
                    alert("收藏库文件出现异常");
                }else if("-2"==data){
                    rewardUserLogin();
                }else if("1"==data){
                    $("#collect").val(true);
                    $(".dpart01div div").attr("class","dpart01div_img collect");
                    $(".dpart01div_p").html("");
                    $(".dpart01div_p").html("已收藏");
                }else{
                    $("#collect").val(false);
                    $(".dpart01div div").attr("class", "dpart01div_img");
                    $(".dpart01div_p").html("");
                    $(".dpart01div_p").html("收藏");
                }
            }
        });
}
/**
* 下载当前文件(通过词库id,当前已经关闭)
*/
function downloadth(_this,id){
    //验证是否登录
    if (!isLogin()) {
        rewardUserLogin();
        return false;
    }
    location.href="/exportExcel/downloadThesaurusFileById/"+id;
}
/**
 * 加载更多评论
 */
var currentPage = 2;
var infoId = '${infoId}';
var channelId = 2;
function loadCommentData(){
     $.ajax({
        type:"post",
        url:"/comment/ajaxCommentList",
        dataType: "json",
        async:false,
        data:{currentPage : currentPage,infoId : infoId,channelId : channelId,rnd : Math.random()},
        success: function(page){
            var html="";
            var data = page.data;
            var totalPage = page.totalPage;
            for(var i in data){
                var opt = data[i];
                    html+="<li>"
                    html+="<a href=\"javascript:;\">";
                    if(opt.logoPath!=""&&opt.logoPath!=null){
                        html+="<img src="+opt.logoPath+" alt=\"评论用户\">";
                    }else{
                        html+="<img src=\"images/userDefault.jpg\" alt=\"评论用户\">";
                    }
                    html+="</a>";
                    html+="<div class=\"commentList\">";
                    html+="<div class=\"listTitle\">";
                    html+="<div class=\"listUser\">";
                    html+="    <a href=\"javascript:;\">"+opt.noName+"</a>";
                    html+="</span>";
                    html+="<span class=\"listTime\">"+opt.dateStr+"</span>";
                    html+="</div>";
                    html+="<div class=\"commentDetail\">";
                    html+="<p>"+subStr(opt.content,40,'...')+"</p>";
                    html+="</div>";
                    html+="</div>";
                    html+="</li>";
            }
             if(totalPage >= currentPage){
                $("#com-list").append(html);
                currentPage++;
                if(totalPage < currentPage){
                    $("#load_moreb").text("暂时没有更多相关评论~~~");
                }            
             } 
        }
    }); 
}

function subStr(str,length,append){ 
    var pattern =/#[^#]+#/g;
    str=str.replace(pattern,"");
    if(str.length>length){
        str=str.substring(0,length)+append;
    }
    return str;
}

猜你喜欢

转载自blog.csdn.net/rentian1/article/details/85105241
今日推荐