(function ($) { window.CI = {}; var CM = CI.Model = function (opt) { var me = this; me.page = opt.page || 0; me.pageSize = opt.pageSize || 5; me.endId = opt.endId || 0; me.lastTime = opt.lastTime || ""; me.loading = 0; me.url = opt.url; me.$container = $("#" + opt.containerId); me.lastCode = 0; me.tplName = opt.tplName; me.tagModelFunc = opt.tagModelFunc; me.containerId = opt.containerId; me.onload = opt.onload; me.emptyMsg = opt.emptyMsg; me.onDataInit = opt.onDataInit; me.onNoData = opt.onNoData; me.onRender = opt.onRender; me.preAppend = opt.preAppend; me.isStop = false; me.btn = opt.btn; me.isPreAppend = opt.isPreAppend; }; CM.prototype.more = function () { var me = this; if (me.isStop) return; var url = buildTags(me.url, { p1: (me.page), p2: (me.page + 1), p3: (me.endId), p4: (me.pageSize), p5: (me.lastTime) }); if (me.loading == 0) me.loading = 1; else return; $.ajax({ context: me, type: "Get", contentType: "application/json", url: url, dataType: "json", beforeSend: me.beforeAjax, success: me.append, error: me.ajaxError }); }; CM.prototype.append = function (data) { var me = this; if (me.page != data.PreviousPage) return; me.tplContent = me.tplContent || _$(me.tplName).innerHTML; var html = new Array(); if (data.DataList.length) { if (me.onDataInit) { me.onDataInit(); } else { //empty list return if (me.onRender) me.onRender(data.DataList.length); return; } if (data.DataList.length < 5 || !data.HasNext && !me.preAppend) { me.btn.hide(); if (me.containerId == "fixtureTable") { if (!$("#fixtureTable").hasClass("PT10")) { $("#fixtureTable").addClass("PT10"); } } } } else { me.isStop = true; me.btn.hide(); if (me.containerId == "fixtureTable") { if (!$("#fixtureTable").hasClass("PT10")) { $("#fixtureTable").addClass("PT10"); } } } for (var i = 0; i < data.DataList.length; i++) { if (me.tagModelFunc) { me.tagModelFunc(data.DataList[i]); } if (me.isPreAppend) { if (data.DataList[i].SclassId == me.$container.find("[data-SclassId]").first().attr("data-SclassId")) { me.$container.find("[data-SclassId]").first().after(buildTags(me.tplContent, data.DataList[i], true)); } else { me.$container.prepend(buildTags(me.tplContent, data.DataList[i], true)); } } else { html.push(buildTags(me.tplContent, data.DataList[i], true)); } } if (me.isPreAppend) { //me.$container.prepend(html.join('')); } else { me.$container.append(html.join('')); } me.loading = 0; if (data.RequestPage > 0) me.page = data.RequestPage; //me.endId = data.LastId; //me.lastTime = data.lastTime; if (me.onRender) me.onRender(data.DataList.length); if (typeof (refreshLazyImg) == "function") { refreshLazyImg() } } CM.prototype.beforeAjax = function () { //this.$container.append(_$("tplLoading").innerHTML); if (this.preAppend) { this.preAppend(); } } CM.prototype.ajaxError = function () { var me = this; me.loading = 0; } $(function () { var flag = true; var divName = "resultTable"; var _leaTpl = ""; var sidList = $("#" + divName).find("[data-sid]"); var btnShowMore = $("#ftShowMore"); var _teamId = dbConfig.Id; var _lastSclassId = btnShowMore.attr("data-lastSclass"); var _lastSchid = sidList.last().attr("data-sid"); var _pageSize = 5; var _lastTime = sidList.last().attr("data-lt"); var ScheModel = new CI.Model({ endId: 0, lastTime: _lastTime, page: 0, pageSize: _pageSize, type: 1, url: "/soccerinfo/teamresultsappending?teamid=" + _teamId + "&page={$p1}&req_page={$p2}&lastid={$p3}&pagesize={$p4}&lastmatchtime={$p5}", containerId: divName, tplName: "mtTpl", btn: btnShowMore, tagModelFunc: function (rItem) { rItem.homeRedCss = (rItem.MatchState == -1 && parseInt(rItem.HomeRed) > 0 ? "" : "none"); rItem.homeRed = (rItem.HomeRed && parseInt(rItem.HomeRed) > 1 ? rItem.HomeRed : ""); rItem.hrByNumb = (rItem.HomeRed && parseInt(rItem.HomeRed) > 1 ? "" : "none"); rItem.hrByNoNumb = (parseInt(rItem.HomeRed) > 1 ? "none" : ""); rItem.guestRedCss = (rItem.MatchState == -1 && parseInt(rItem.GuestRed) > 0 ? "" : "none"); rItem.guestRed = (rItem.GuestRed && parseInt(rItem.GuestRed) > 1 ? rItem.GuestRed : ""); rItem.grByNumb = (rItem.GuestRed && parseInt(rItem.GuestRed) > 1 ? "" : "none"); rItem.grByNoNumb = (parseInt(rItem.GuestRed) > 1 ? "none" : ""); var t2 = getTimeByUtcStr(rItem.MatchTimeStr); rItem.time1 = timeToText(t2, "6"); rItem.time2 = timeToText(t2, "3"); var t3 = rItem.MatchTimeStr.split(","); rItem.lastMatchTime = new Date(new Date(t3[0], t3[1], t3[2], t3[3], t3[4], t3[5]).getTime() + 8 * 60 * 60 * 1000).Format("yyyy-MM-dd HH:mm:ss"); rItem.hScorecss = parseInt(rItem.HomeScore) < parseInt(rItem.GuestScore) ? "lose" : ""; rItem.gScorecss = parseInt(rItem.GuestScore) < parseInt(rItem.HomeScore) ? "lose" : ""; // rItem.lea = ""; if (rItem.SclassId != _lastSclassId) { rItem.T_HT = _locModel.T.T_HT; rItem.T_FT = _locModel.T.T_FT; _leaTpl = _leaTpl || _$("leaTpl").innerHTML; rItem.sclassUrl = rItem.IfShow && showDbLink(rItem.SclassId) ? `/football/league-${rItem.SclassId}` : "#"; rItem.countryPic = getCountryImg(rItem.countryId); rItem.lea = buildTags(_leaTpl, rItem); _lastSclassId = rItem.SclassId; } rItem.ybIcon = ""; if (rItem.ybUrl) { rItem.ybIcon = ''; } rItem.homeFlag = _teamImgFormat.format(rItem.HomeTeamId); rItem.guestFlag = _teamImgFormat.format(rItem.GuestTeamId); rItem.expCss = (rItem.ExplainCode != "" ? "" : "none"); if (rItem.ExplainCode != "") { rItem.expExCss = " pd0"; rItem.explainContent = explainLocalize(explainList(rItem.ExplainCode, rItem.HomeName, rItem.GuestName)); } if (rItem.MatchState < -1) rItem.wrCss = "none"; }, preAppend: function () { }, onDataInit: function () { }, onNoData: function () { }, onRender: function () { } }); btnShowMore.click(function () { ScheModel.more(); }); $(".content [data-num]").click(function () { var tObj = $(this).addClass("on"); tObj.siblings(".on").removeClass("on"); var num = parseInt(tObj.attr("data-num")); $("#resultsList [data-index]").each(function (i, dom) { var oObj = $(dom); if (oObj.attr("data-index") < num) oObj.show(); else oObj.hide(); }); }); //欧美V1.4新增,其他版本可能没有 $("#teamTabs .item").click(function () { var tObj = $(this).addClass("on"); tObj.siblings(".on").removeClass("on"); var t = tObj.attr("data-t"); $(".teamContent").hide(); $("#" + t).show(); }); //目前都是按钮 //if ($("#ftShowMore").length == 0) { // $(window).scroll(function () { // var scrollTop = Number($(document).scrollTop()); // var documentHeight = $(document).height(); // var winHeight = $(window).height(); // var listHeight = $('#resultsList').height(); // // 滚动加载更多 // if (scrollTop >= listHeight - winHeight) { // ScheModel.more(); // } // }); //} var flag = true; var FixdivName = "fixtureTable"; var FixsidList = $("#" + FixdivName).find("[data-sid]"); var FixbtnShowMore = $("#fixShowMore"); var _teamId = dbConfig.Id; var _FixlastSclassId = FixbtnShowMore.attr("data-lastSclass"); var _FixlastSchid = FixsidList.first().attr("data-sid"); var _FixpageSize = 5; var _FixlastTime = FixsidList.first().attr("data-lt"); var FixScheModel = new CI.Model({ endId: 0, lastTime: _FixlastTime, page: 0, pageSize: _FixpageSize, type: 1, url: "/soccerinfo/teamfixturesappending?teamid=" + _teamId + "&page={$p1}&req_page={$p2}&lastid={$p3}&pagesize={$p4}&lastmatchtime={$p5}", containerId: FixdivName, tplName: "mtTpl", btn: FixbtnShowMore, isPreAppend: true, tagModelFunc: function (rItem) { rItem.homeRedCss = "none"; rItem.guestRedCss = "none"; rItem.HomeScore = rItem.GuestScore = ""; var t2 = getTimeByUtcStr(rItem.MatchTimeStr); rItem.time1 = timeToText(t2, "6"); rItem.time2 = timeToText(t2, "3"); var t3 = rItem.MatchTimeStr.split(","); rItem.lastMatchTime = new Date(new Date(t3[0], t3[1], t3[2], t3[3], t3[4], t3[5]).getTime() + 8 * 60 * 60 * 1000).Format("yyyy-MM-dd HH:mm:ss"); // rItem.lea = ""; if (rItem.SclassId != _FixlastSclassId) { rItem.T_HT = _locModel.T.T_HT; rItem.T_FT = _locModel.T.T_FT; _leaTpl = _leaTpl || _$("leaTpl").innerHTML; rItem.sclassUrl = rItem.IfShow && showDbLink(rItem.SclassId) ? `/football/league-${rItem.SclassId}` : "#"; rItem.countryPic = getCountryImg(rItem.countryId); rItem.lea = buildTags(_leaTpl, rItem); _FixlastSclassId = rItem.SclassId; } rItem.winResultCss = "none"; rItem.homeFlag = _teamImgFormat.format(rItem.HomeTeamId); rItem.guestFlag = _teamImgFormat.format(rItem.GuestTeamId); rItem.expCss = (rItem.ExplainCode != "" ? "" : "none"); }, preAppend: function () { }, onDataInit: function () { }, onNoData: function () { }, onRender: function () { } }); FixbtnShowMore.click(function () { FixScheModel.more(); }); }); })(jQuery); function _callback(json) { window._locModel = window._locModel || { T: {} }; for (var i in json) { _locModel.T[i] = json[i]; } };