var thisWrapper=null; var thisPageIndex = 1; var thisRow = 30; var thisItem = $(".zxzlxq-itemlist.active").data("item"); var thisType = $(".zxzlxq-itemlist.active").data("type"); var thisIcon = $("#micon").val(); $(function () { init(); // setTimeout(wrapperScroll, 1000); setTimeout(initScroll, 500); $(".back").click(function () { var origin = window.location.origin; //console.log(origin); window.location.href = origin + "/zx/index.html"; }) $(".news-item").click(function () { localStorage.href = window.location.href; }) $(".zxzlxq-itemlist").click(function () { thisWrapper.destroy(); var index = $(".zxzlxq-itemlist").index(this); $(".zxzlxq-itemlist").removeClass("active").eq(index).addClass("active"); thisItem = $(".zxzlxq-itemlist.active").data("item"); thisType = $(".zxzlxq-itemlist.active").data("type"); changeItem(); }) }) function init() { var search = window.location.pathname.split(".")[0].split("/")[3]; if (search != undefined) { if (search.indexOf("cstzm") > -1) { $(".zxzlxq-itemlist").each(function (i, e) { if ($(e).data("type") == "彩神通字谜") { $(".zxzlxq-itemlist").removeClass("active").eq(i).addClass("active"); thisItem = $(e).data("item"); thisType = $(e).data("type"); changeItem(); } }) } } } function changeItem() { var load = layer.load(2, { shade: [0.3, '#000'] }); $.ajax({ url: "/ZX/ZXLXGD", type: "post", async: false, data: { c: thisType, m: thisIcon, i: thisItem }, success: function (res) { layer.close(load); if (res != "") { thisPageIndex = 1; $(".zxzlxq-newslist-wrapper").html(res); setTimeout(initScroll,100); } else { layer.msg("没有更多数据了!") } }, error: function (err) { console.log(err) layer.close(load); } }) } function getMore() { var load = layer.load(2, { shade: [0.3, '#000'] }); $.ajax({ url: "/ZX/ZXZLXQList", type: "post", async: false, data: { c: thisIcon, i: thisItem, p: thisPageIndex + 1, r: thisRow }, success: function (res) { layer.close(load); if (res != "") { thisPageIndex++; $("#v-morezx-wrapper .content").append(res); thisWrapper.refresh(); } else { layer.msg("没有更多数据了!") } } }) } //function wrapperScroll() { // var wrapper = $("#v-morezx-wrapper")[0]; // wrapper.addEventListener("scroll", function () { // var ch = wrapper.clientHeight; // var st = wrapper.scrollTop; // var sh = wrapper.scrollHeight; // if (st + ch - sh >= -20) { // getMore(); // } // }) //} function initScroll() { var wrapper = document.getElementById("v-morezx-wrapper"); thisWrapper = new BScroll(wrapper, { probeType: 1, click:true }); thisWrapper.on("scroll", function (pos) { var h = $("#v-morezx-wrapper .content")[0].clientHeight; var h2 = $("#v-morezx-wrapper")[0].clientHeight; if (h-120< Math.abs(pos.y) + h2) { getMore(); } }) }