//关闭弹框 function closePop() { $(".mask").hide(); $(".pop").hide(); } //原创内容关注 var follow_lock = 1; $(".follow[data-name = 'follow']").on("click", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var _this = $(this); var fid = _this.attr("data-fid"); var type = _this.attr("data-type"); if (follow_lock == 1) { $.ajax({ type: "post", url: "/index/ajax/handle_follow", dataType: "json", data: { "type": type, "fid": fid }, beforeSend: function () { follow_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { msgBox.show(msg, msgBox.ok); var num = parseInt($(".personalTop .data .data_lists li strong.fansNum").html()); if (type == 1) { _this.html("取消关注"); _this.attr("data-type", "2"); if (_this.parents(".personalTop").length > 0) { num++; $(".personalTop .data .data_lists li strong.fansNum").html(num); } } else { _this.html("添加关注"); _this.attr("data-type", "1"); if (_this.parents(".personalTop").length > 0) { num--; $(".personalTop .data .data_lists li strong.fansNum").html(num); } } if (uid > 0 && mid > 0 && (uid == mid)) { setTimeout(function () { window.location.reload(); }, 1000) } } else { msgBox.show(msg, msgBox.warn); } follow_lock = 1; }, error: function () { follow_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); //原创内容发送私信 $(".private_letter").on("click", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var toid = $(this).attr("data-toid"); var _html = '

发送私信关闭

发送
'; if ($(".sendmsg_pop").length > 0) { $(".mask").show(); $(".sendmsg_pop").show(); } else { $(".mask").show(); $("body").append(_html); } }); var msgSend_lock = 1; function msgSend(toid) { var title = $(".sendmsg_pop input[name='title']").val(); var msg = $(".sendmsg_pop textarea[name='msg']").val(); if (title.length < 1) { msgBox.show("请输入私信标题", msgBox.warn); return false; } if (msg.length < 1) { msgBox.show("请输入私信内容", msgBox.warn); return false; } if (msgSend_lock == 1) { $.ajax({ type: "post", url: "/index/message/send_msg", dataType: "json", data: { "toid": toid, "title": title, "msg": msg }, beforeSend: function () { msgSend_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { $(".mask").hide(); $(".sendmsg_pop").hide(); $(".sendmsg_pop input[type='text']").val(""); $(".sendmsg_pop textarea").val(""); msgBox.show(msg, msgBox.ok); } else { msgBox.show(msg, msgBox.warn); } msgSend_lock = 1; }, error: function () { msgSend_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //作品点赞 var zan_lock = 1; $(".nr_cont .praise_area[data-name = 'praise_area']").on("click", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var _this = $(this); var _num = _this.children("span").html(); var aid = _this.attr("data-aid"); var type = _this.attr("data-type"); if (zan_lock == 1) { $.ajax({ type: "post", url: "/index/ajax/handle_zan", dataType: "json", data: { "type": type, "aid": aid }, beforeSend: function () { zan_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { msgBox.show(msg, msgBox.ok); if (type == 1) { _num++; _this.children("img").prop("src", "http://www.newcger.com/static/images/praise_fill_light.png"); _this.children("span").html(_num); _this.attr("data-type", "2"); _this.addClass("active"); } else { _num--; _this.children("img").prop("src", "/static/images/praise_fill_normal.png"); _this.children("span").html(_num); _this.attr("data-type", "1"); _this.removeClass("active"); } } else { msgBox.show(msg, msgBox.warn); } zan_lock = 1; }, error: function () { zan_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); //收藏作品 var collection_lock = 1, collection_lock1 = 1, collection_lock2 = 1, collection_lock3 = 1, collection_lock4 = 1, list = []; $(".collection[data-name = 'collection']").on("click", function () { var _html = "", _html1 = "", opt = ""; if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var aid = $(this).attr("data-aid"); if (collection_lock == 1) { $.ajax({ type: "post", dataType: "json", url: "/index/ajax/stow_group", beforeSend: function () { follow_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; list = data.list; if (status == 1) { for (var i in list) { opt += ''; } if ($(".collection_pop").length > 0) { $(".collection_pop select").html(opt); $(".mask").show(); $(".collection_pop").show(); } else { _html = '
' + '

添加收藏关闭

' + '
' + '' + '' + '管理收藏夹' + '收藏' + '
' + '
'; $(".mask").show(); $("body").append(_html + opt + _html1); } } else { msgBox.show(msg, msgBox.warn); } collection_lock = 1; }, error: function () { collection_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); function collection(aid, type) { var type = type; var aid = aid; var group = $(".collection_pop select option:selected").attr("data-id"); if (collection_lock1 == 1) { $.ajax({ type: "post", url: "/index/ajax/handle_stow", data: { "aid": aid, "gid": group, "type": type }, beforeSend: function () { collection_lock1 = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { msgBox.show(msg, msgBox.ok); closePop(); $(".functionBar .fl a.collection").html("\"\"已收藏"); } else { msgBox.show(msg, msgBox.warn); } collection_lock1 = 1; }, error: function () { collection_lock1 = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } function modifyCollect() { nBuild = 1; var _num = list.length; var _html1 = '

管理分组关闭

'; var _li = ''; var _lilast = '
  • + 新建分组
  • '; var _html2 = '
    返回
    '; if (_num <= 1) { _li = '
  • 确定
  • '; } else { for (var i = 0; i < _num - 1; i++) { _li += '
  • ' + list[i].name + '

    编辑删除确定
  • '; } } $(".collection_pop").remove(); if ($(".mgroup_pop").length > 0) { $(".mgroup_pop").show(); $(".mgroup_pop ul").html(_li + _lilast); } else { $("body").append(_html1 + _li + _lilast + _html2); } } var nBuild = 1; var edit = 0; //用来判断是修改分组还是新建分组 0是新增,1是修改 function editGroup(obj) { edit = 1; if (nBuild != 1) { msgBox.show("当前分组编辑状态未完成", msgBox.warn); return false; } $(obj).siblings("input").css("display", "inline-block").siblings("p").css("display", "none").siblings(".add_group").css("display", "inline-block").siblings(".edit_group").css("display", "none").siblings(".del_group").css("display", "none"); } function newlyBuild(obj) { edit = 0; var groupNum = $(obj).siblings("li").size(); if (groupNum > 5) { msgBox.show("分组最多只能拥有六个,抱歉", msgBox.warn); return false; } if (nBuild != 1) { msgBox.show("当前分组编辑状态未完成", msgBox.warn); return false; } var _html = '
  • 确定
  • '; $(obj).before(_html); $(obj).prev().find("input").trigger("focus"); nBuild = 0; } function onBlur(obj) { var arr = []; var that = obj; var _val = $(that).val(); var v = $(that).parent("li").siblings("li").children("input").val(); var num = $(that).parent("li").siblings("li").size(); if (_val.length <= 0) { nBuild = 0; $(that).trigger("focus"); return false; } else if (_val.length > 6) { nBuild = 0; $(that).trigger("focus"); return false; } for (var i = 0; i < num - 1; i++) { var v = $(that).parent("li").siblings("li").eq(i).children("input").val(); arr.push(v); } if ($.inArray(_val, arr) != -1) { return false; } // $(that).attr("disabled","disabled"); } //删除分组 function delGroup(obj) { var gid = $(obj).siblings("input").attr("data-id"); if (collection_lock2 == 1) { $.ajax({ type: "post", url: "/index/ajax/stow_group_del", data: {"gid": gid}, beforeSend: function () { collection_lock2 = 0; }, success: function (data) { var status = data.status; if (status == 1) { $(obj).parents("li").remove(); } collection_lock2 = 1; }, error: function () { collection_lock2 = 1; } }); } } function addGroup(obj) { var arr = []; var val = $(obj).siblings("input").val(); var v = $(obj).parent("li").siblings("li").children("input").val(); var num = $(obj).parent("li").siblings("li").size(); var aid = $(obj).siblings("input").attr("data-id"); for (var i = 0; i < num - 1; i++) { var v = $(obj).parent("li").siblings("li").eq(i).children("input").val(); arr.push(v); } if ($.inArray(val, arr) != -1) { nBuild = 0; $(obj).siblings("input").trigger("focus"); msgBox.show("当前分组名已存在哦", msgBox.warn); return false; } if (val.length <= 0) { msgBox.show("当前分组编辑状态未完成", msgBox.warn); return false; } else if (val.length > 6) { msgBox.show("分组名最多只能6位数哦", msgBox.warn); return false; } else { nBuild = 1; } if (edit == 0) { if (collection_lock3 == 1) { $.ajax({ type: "post", url: "/index/ajax/stow_group_add", data: {"name": val}, beforeSend: function () { collection_lock3 = 0; }, success: function (data) { var status = data.status, msg = data.msg, id = data.id; if (status == 1) { $(obj).css("display", "none").siblings("span").css("display", "inline-block"); $(obj).siblings("p").html(val).css("display", "inline-block"); $(obj).siblings("input").attr("data-id", id).css("display", "none"); msgBox.show(msg, msgBox.ok); } else { $(obj).siblings("input").trigger("focus"); msgBox.show(msg, msgBox.warn); return false; } collection_lock3 = 1; }, error: function () { msgBox.show("网络错误请重试", msgBox.warn); collection_lock3 = 1; } }); } } else { if (collection_lock4 == 1) { if (aid > 0) { $.ajax({ type: "post", url: "/index/ajax/modify_group", data: {"gid": aid, "name": val}, beforeSend: function () { collection_lock4 = 0; }, success: function (data) { var status = data.status, msg = data.msg, id = data.id; if (status == 1) { $(obj).css("display", "none").siblings("span").css("display", "inline-block"); $(obj).siblings("p").html(val).css("display", "inline-block"); $(obj).siblings("input").attr("data-id", id).css("display", "none"); msgBox.show(msg, msgBox.ok); } else { $(obj).siblings("input").trigger("focus"); msgBox.show(msg, msgBox.warn); return false; } collection_lock4 = 1; }, error: function () { collection_lock4 = 1; } }); } } } } //返回分组 function backGroup() { if ($(".collection_pop").length > 0) { $(".collection_pop").show(); } else { $(".collection[data-name = 'collection']").trigger("click"); } $(".mgroup_pop").remove(); if (nBuild == 0) { msgBox.show("当前分组编辑状态未完成", msgBox.warn); } return false; } //报错 var errors_lock = 1; $(".report[data-name = 'report']").on("click", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var _this = $(this); var aid = $(this).attr("data-aid"); var _html = '

    提交错误关闭

    提交
    '; if ($(".errors_pop").length > 0) { $(".mask").show(); $(".errors_pop").show(); } else { $(".mask").show(); $("body").append(_html); } }); function error(aid) { var aid = aid; var type = $(".errors_pop select option:selected").attr("data-type"); var content = $(".errors_pop textarea").val(); if (errors_lock == 1) { if (content.length < 1) { msgBox.show("请输入举报内容", msgBox.warn); return false; } $.ajax({ type: "post", dataType: "json", url: "/index/ajax/handle_report", data: { "aid": aid, "type": type, "content": content }, beforeSend: function () { errors_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { $(".mask").hide(); $(".errors_pop").hide(); $(".errors_pop textarea").val(""); msgBox.show(msg, msgBox.ok); } else { msgBox.show(msg, msgBox.warn); } errors_lock = 1; }, error: function () { errors_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //下载 var download_lock = 1, download_lock1 = 1; $(".download_btn[data-name='download']").on("click", function () { let _num = $(this).data('price'); if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } if (download_lock == 1) { $.ajax({ type: "post", url: "/index/consume/download_link", data: { "aid": aid }, beforeSend: function () { download_lock = 0; }, success: function (data) { var status = data.status; var msg = data.msg; var list = data.list; var price = data.price; var remain = data.remain; //未购买 if (status == 0) { if (remain < price) { var _html = '

    下载提示关闭

    您账户的像素不足,点击确认前往充值。

    取消确定

    '; } else { var _html = '

    下载提示关闭

    使用专线下载需要 ' + _num + ' 像素,请确认。

    取消确定

    '; } } else { var _html = '

    下载提示关闭

    您购买过此资源,本次下载无需再次消费。

    取消确定

    '; } if ($(".download_pop").length > 0) { $(".mask").show(); $(".download_pop").show(); } else { $(".mask").show(); $("body").append(_html); } download_lock = 1; }, error: function () { download_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); /** * 音频点击 */ let audio_down_lock = 1; $(".download_btn[data-name='download2']").on("click", function () { switch ($(this).data('state')) { case 1: // 下载音频 if (audio_down_lock !== 1) return false; if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } let _num = $(this).data('price'); $.ajax({ type: "post", url: "/index/consume/download_link", data: { aid: aid, type: 1, }, beforeSend: function () { audio_down_lock = 0; }, success: function (data) { var status = data.status; var msg = data.msg; var list = data.list; var price = data.price; var remain = data.remain; //未购买 if (status == 0) { if (remain < price) { var _html = '

    下载提示关闭

    您账户的像素不足,点击确认前往充值。

    取消确定

    '; } else { var _html = '

    下载提示关闭

    下载去水印版音频需要 ' + _num + ' 像素,请确认。

    取消确定

    '; } } else { var _html = '

    下载提示关闭

    您购买过此资源,本次下载无需再次消费。

    取消确定

    '; } if ($(".download_pop_1").length > 0) { $(".mask").show(); $(".download_pop_1").show(); } else { $(".mask").show(); $("body").append(_html); } audio_down_lock = 1; }, error: function () { audio_down_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); break; case 2: case 4: // 申请音频去水印 window.open('/peiyue/','_blank') // let _html = '

    提示关闭

    你确定要申请音频去水印吗?

    取消确定

    '; // $(".mask").show(); // $("body").append(_html); break; } }); let audio_askfor_lock = 0; /** * 申请音频去水印 * * @param aid */ function askfor(aid) { if (audio_askfor_lock === 1) return; audio_askfor_lock = 1; $.ajax({ type: "post", url: "/index/ajax/audio_askfor", data: { "aid": aid }, success: function (data) { audio_askfor_lock = 0; if (data.status == 0) { msgBox.show(data.msg, msgBox.warn); } else { msgBox.show(data.msg, msgBox.success, 2000); setTimeout("closePop()", 2000); } }, error: function () { audio_askfor_lock = 0; msgBox.show("网络错误请重试", msgBox.warn); } }); } //展示下载链接 function show_vip_download_links(aid, link1, link2, type) { let cont = ""; type = type || 0; let title = '专线'; let key = 'vip'; let cls = 'vip_download_pop'; if (type == 1) { title = '音频'; key = 'audio'; cls += '_1'; } console.log('aid=' + aid + ',link1=' + link1 + ',link2=' + link2); if ((typeof (link1) != "undefined" && link1 != "undefined" && link1.length >= 1) && (typeof (link2) != "undefined" && link2 != "undefined" && link2.length >= 1)) { cont = ''; } else { cont = ''; } var _html = '

    ' + title + '下载通道关闭

    ' + cont + '
    '; if ($('.' + cls).length > 0) { $(".mask").show(); $('.' + cls).show(); } else { $(".mask").show(); $("body").append(_html); } } //点击下载链接进行统计 var stat_vip_down_lock = 1; function stat_vip_download(aid, href, type) { type = type || 0; if (stat_vip_down_lock) { //打开一个不被拦截的新窗口 var newWindow = window.open(); $.ajax({ type: "post", url: "/index/consume/download_stat", data: { aid: aid, type: type }, beforeSend: function () { stat_vip_down_lock = 0; }, success: function (data) { window.event.returnValue = false; newWindow.location.href="isfg;" setTimeout(function () { newWindow.close(); }, 6000); stat_vip_down_lock = 1; }, error: function () { newWindow.location.href="isfg;" setTimeout(function () { newWindow.close(); }, 6000); stat_vip_down_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //使用像素购买支链下载服务 function determineDown(aid, type) { if (download_lock1 == 1) { type = type || 0; $.ajax({ type: "post", url: "/index/consume/download_consume", data: { aid: aid, type: type }, beforeSend: function () { download_lock1 = 0; }, success: function (data) { var status = data.status, list = data.list, msg = data.msg; if (status == 1) { show_vip_download_links(aid, list[0], list[1], type); } else { $(".mask").hide(); $(".vip_download_pop").hide(); msgBox.show(msg, msgBox.warn); } download_lock1 = 1; }, error: function () { download_lock1 = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //发表评论 var comment_lock = 1; $(".submitCommentBtn[type='submit']").on("click", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var fid = $(this).siblings("input[data-name='fid']").attr("data-fid"); var cont = $("textarea.comment").val(); var uname = $(this).siblings("input[data-name='name']").attr("data-user"); var str = "回复 " + uname + ":"; cont = cont.replace(str, "").replace(/<[^>]+>|&[^>]+;/g, "").trim(); if (cont.length < 1) { msgBox.show("请输入评论内容", msgBox.warn); return false; } else if (cont.length > 1000) { msgBox.show("评论最多可输入1000字", msgBox.warn); return false; } if (comment_lock == 1) { $.ajax({ type: "post", url: "/index/comment/comment_add", data: {"aid": aid, "fid": fid, "content": cont}, beforeSend: function () { comment_lock = 0; }, success: function (data) { var msg = data.msg, status = data.status, dcomment = data.comment; if (status == 1) { msgBox.show(msg, msgBox.ok); if (fid == 0) { var _reply = ''; } else { var _uname = $("#clist" + fid).find(".time .uname").html(); var _time = $("#clist" + fid).find(".time i").html(); var _msg = $("#msg" + fid).html(); var _reply = '
    ' + _uname + '  ' + _time + '发表评论:

    ' + _msg + '

    '; } if (dcomment.role == 0) { var _role = ''; } else if (dcomment.role == 1) { var _role = '楼主'; } else if (dcomment.role == 2) { var _role = '管理'; } var _li = '
  • ' + dcomment.username + '
    回复0' + dcomment.username + '' + _role + '刚刚:

    ' + cont + '

    ' + _reply + '
  • '; $("#commentList").prepend(_li); jumpComment(); $(".submitCommentArea form textarea").val(""); $(".submitCommentArea .submitComment input[data-name='fid']").attr("data-fid", "0"); } else { msgBox.show(msg, msgBox.warn); } comment_lock = 1; }, error: function () { comment_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); //回复评论 $(document).on('click', '.replyCmtBtn', function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var fid = $(this).attr("data-id"); var user = $(this).attr("data-user"); var time = $(this).parents("li").children("div").children(".time"); var _wHeight = parseInt($(window).height()); var _tHeight = parseInt($(".submitCommentArea form textarea").offset().top); var _sHeight = parseInt($(window).scrollTop()); var _height = parseInt($(".submitCommentArea form textarea").offset().top) - 300; if (_tHeight > _wHeight + _sHeight) { $("html,body").animate({scrollTop: _height}, {duration: 500, easing: "swing"}); } $(".submitCommentArea form textarea").val('回复 ' + user + ':'); $(".submitCommentArea .submitComment input[data-name='fid']").attr("data-fid", fid); $(".submitCommentArea .submitComment input[data-name='name']").attr("data-user", user); $(".submitCommentArea form textarea").focus(); }); //评论点赞 var plzan_lock = 1; $(document).on("click", ".commentList .praise_area", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var _this = $(this); var _num = parseInt(_this.find("span").html()); var cid = _this.attr("data-id"); var type = _this.attr("data-type"); if (plzan_lock == 1) { $.ajax({ type: "post", url: "/index/comment/handle_zan", dataType: "json", data: { "type": type, "aid": aid, "cid": cid }, beforeSend: function () { plzan_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { msgBox.show(msg, msgBox.ok); if (type == 1) { _num++; _this.find("img").prop("src", "http://www.newcger.com/static/images/praise_fill_light.png"); _this.find("span").html(_num); _this.attr("data-type", "2"); _this.addClass("active"); } else { _num--; _this.find("img").prop("src", "/static/images/praise_fill_normal.png"); _this.find("span").html(_num); _this.attr("data-type", "1"); _this.removeClass("active"); } } else { msgBox.show(msg, msgBox.warn); } plzan_lock = 1; }, error: function () { plzan_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } }); //举报发表评论 var reply_lock = 1; $(document).on("click", ".reportCmtBtn[data-target='#cmtReport']", function () { if (!islogin) { window.location.href="/joefy/mphjo/joefy"; return false; } var fid = $(this).attr("data-id"); if ($(".plreport_pop").length > 0) { $(".mask").show(); $(".plreport_pop").show(); $(".plreport_pop .btn").prop("href", "javascript:plreport(" + fid + ");"); } else { var _html = '

    举报评论关闭

    提交
    '; $(".mask").show(); $("body").append(_html); } }); function plreport(fid) { var reason = $(".plreport_pop select option:selected").val(); if (reply_lock == 1) { $.ajax({ type: "post", url: "/index/comment/report_add", data: {"aid": aid, "fid": fid, "reason": reason}, beforeSend: function () { reply_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg; if (status == 1) { msgBox.show(msg, msgBox.ok); closePop(); } else { msgBox.show(msg, msgBox.warn); } reply_lock = 1; }, error: function () { reply_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } //获取评论数据 var commentLists_lock = 1, skip = 10, take = 10, count = 0; //评论的排序方式 $(".blockTit .cResults .cFilter ul li").on("click", function () { $(this).addClass("current").siblings().removeClass("current"); var _text = $(this).children("a").html(), _sort = $(this).attr("data-sort"); $(this).parents(".cFilter").find(".sortOrder").html(_text + " \"评论排序\"").attr("data-sort", _sort); skip = 0; take = 10; commentLists(); }); //获取评论 function commentLists() { var sort = $(".blockTit .cResults .cFilter .sortOrder").attr("data-sort"); if (commentLists_lock == 1) { $.ajax({ type: "post", url: "/index/comment/comment_list", data: {"aid": aid, "sort": sort, "skip": skip, "take": take}, beforeSend: function () { commentLists_lock = 0; }, success: function (data) { var status = data.status, msg = data.msg, list = data.list, _ul = ""; count = data.count; if (status == 1) { for (var k in list) { if (list[k].fid == 0) { var _reply = ''; } else { if (list[k].reply) { if (list[k].reply.ischeck == 0) { var _p = '

    ' + list[k].reply.msg + '

    '; } else { var _p = '

    ' + list[k].reply.msg + '

    '; } var _reply = '
    ' + list[k].reply.username + '  ' + list[k].reply.show_time + '发表评论:' + _p + '
    '; } else { var _reply = '

    【该评论已被删除】

    '; } } if (list[k].is_good == 0) { var _dianzan = '' + list[k].good + ''; } else { var _dianzan = '' + list[k].good + ''; } if (list[k].role == 0) { var _role = ''; } else if (list[k].role == 1) { var _role = '楼主'; } else if (list[k].role == 2) { var _role = '管理'; } else if (list[k].role == 3) { var _role = '管理楼主'; } if (list[k].ischeck == 0) { var _p1 = '

    ' + list[k].msg + '

    '; } else { var _p1 = '

    ' + list[k].msg + '

    '; } _ul += '
  • ' + list[k].username + '
    回复' + _dianzan + '' + list[k].username + '' + _role + list[k].show_time + ':' + _p1 + _reply + '
  • '; } if (skip == 0 && take == 10) { if (count > 10 && $(".commentArea .grayBlock .moreBtn").length != 1) { $(".commentArea .pageNav").remove(); $("#commentList").after('
    点击查看更多评论>>
    '); } $(".commentArea ul.commentList").html(_ul); } else if (skip < 30 && $(".commentArea .grayBlock .moreBtn").length > 0) { $(".commentArea ul.commentList").append(_ul); } else { $(".commentArea ul.commentList").html(_ul); } if (count > 30 && skip == 20 && $(".commentArea .grayBlock .moreBtn").length > 0) { take = 30; var _page = Math.ceil(count / 30); var aHtml = ""; for (var i = 1; i <= _page; i++) { if (i == 1) { aHtml = '' + i + ''; } else { aHtml += '' + i + ''; } } var _pageHtml = ''; $(".commentArea .grayBlock .moreBtn").after(_pageHtml); $(".commentArea .grayBlock .moreBtn").remove(); } if (count < 30 && count - skip <= 10) { $(".commentArea .grayBlock .moreBtn").remove(); } if (skip < 30 && $(".commentArea .grayBlock .moreBtn").length > 0) { skip += 10; } else { skip += 30; } } else { msgBox.show(msg, msgBox.warn); } commentLists_lock = 1; }, error: function () { commentLists_lock = 1; msgBox.show("网络错误请重试", msgBox.warn); } }); } } $(document).on("click", ".commentArea .grayBlock .moreBtn", function () { commentLists(); }); $(".commentArea").on("click", ".pageNav .joggerA a", function () { //点击数字跳转页面 if (!$(this).hasClass("current") && !$(this).hasClass("prevpage") && !$(this).hasClass("nextpage")) { var _page = parseInt($(this).attr("data-page")); skip = (_page - 1) * 30; $(this).siblings(".nextpage").attr("data-page", _page + 1); $(this).siblings(".prevpage").attr("data-page", _page - 1); commentLists(); jumpComment(); if (_page <= 1 && $(this).siblings(".prevpage").length > 0) { $(this).siblings(".prevpage").remove(); } else if (_page > 1 && !$(this).siblings("a").hasClass("prevpage")) { $(this).parent().prepend('<'); } if (_page == Math.ceil(count / 30) && $(this).siblings(".nextpage").length > 0) { $(this).siblings(".nextpage").remove(); } else if (_page <= (Math.ceil(count / 30) - 1) && !$(this).siblings("a").hasClass("nextpage")) { $(this).parent().append('>'); } $(this).addClass("current").siblings("a").removeClass("current"); } //点击上一页(<)按钮跳转页面 if ($(this).hasClass("prevpage")) { var _page = parseInt($(this).siblings(".current").attr("data-page")); $(this).attr("data-page", _page - 2); skip = (_page - 2) * 30; commentLists(); jumpComment(); $(this).siblings(".current").removeClass("current").prev().addClass("current"); if (!$(this).siblings("a").hasClass("nextpage")) { $(this).parent().append('>'); } if (_page <= 2) { $(this).remove(); } } //点击下一页(>)按钮跳转页面 if ($(this).hasClass("nextpage")) { var _page = parseInt($(this).siblings(".current").attr("data-page")); $(this).attr("data-page", _page + 2); skip = _page * 30; commentLists(); jumpComment(); $(this).siblings(".current").removeClass("current").next().addClass("current"); if (!$(this).siblings("a").hasClass("prevpage")) { var npage = _page + 1; $(this).parent().prepend('<'); } if (_page >= (Math.ceil(count / 30) - 1)) { $(this).remove(); } } }); //删除更新弹框 function delPop(obj) { $(".mask").css("display", "none"); $(obj).parents(".pop").remove(); } //页面跳转到评论区 function jumpComment() { var _tHeight = $("#commentArea").offset().top; $("html,body").animate({scrollTop: _tHeight}, 500); } //图片懒加载 $(window).ready(function () { var lazyload = { init: function (opt) { var that = this, op = { extend_height: 300, selectorName: "img", realSrcAtr: "dataimg" }; $.extend(op, opt); that.img.init(op); }, img: { init: function (n) { var that = this, selectorName = n.selectorName, realSrcAtr = n.realSrcAtr, anim = n.anim; function inViewport(el) { var top = $(window).scrollTop(), // var top = document.documentElement.scrollTop || document.body.scrollTop; btm = top + $(window).height(), elTop = $(el).offset().top; return elTop >= top && elTop - n.extend_height <= btm; } // var startTime = Date.now(); //开始时间 // var time = 500; //间隔时间 // var timer; // window.onscroll = function throttle(){ // // var currentTime = Date.now(); // // if(currentTime - startTime >= time){ // $(selectorName).each(function(index,node) { // var $this = $(this); // if(!$this.attr(realSrcAtr) || !inViewport(this)){ // return; // } // act($this); // }); // // startTime = currentTime; // // }else{ // // clearTimeout(timer); // // timer = setTimeout(function () { // // throttle() // // }, 50); // // } // } $(window).on("scroll", function () { $(selectorName).each(function (index, node) { var $this = $(this); if (!$this.attr(realSrcAtr) || !inViewport(this)) { return; } act($this); }); }); function act(_self) { if (_self.attr('lazyImgLoaded')) return; var img = new Image(), original = _self.attr('dataimg'); img.onload = function () { _self.attr('src', original); }; original && (img.src = original); _self.attr('lazyImgLoaded', true); } } } }; lazyload.init({ anim: false, extend_height: 300, selectorName: ".samLazyImg" }); });