$(function () { $('.select li a').each(function () { var url = window.location.pathname; var href = $(this).attr('href'); if (url.includes(href)) { $(this).parent().addClass('active').siblings().removeClass('active') } }) $('.header-top-container li a').each(function () { var url = window.location.pathname; var href = $(this).attr('href'); if (url.includes(href)) { $(this).parent().addClass('header-top-actived').siblings().removeClass('header-top-actived') } }) $('.zhusa-xwye li a').each(function () { var url = window.location.pathname; var href = $(this).attr('href'); if (url.includes(href)) { $(this).parent().addClass('erji-active').siblings().removeClass('erji-active') } }) }) function matchinfo(typeid,matchid) { $.ajax({ url: "https://api.sportsdatacdn.com/match_info", type: 'GET', data:{ "type_id":typeid, "matchid":matchid }, contentType: "application/x-www-form-urlencoded; charset=utf-8", success: function(res){ console.log(res); const list = res.data; //console.log(list); var htmlContent=""; var bask_qiuyuan=""; var text_zhibo=""; $("#matchinfo_zd_bf").text(res.data["match_info"]["matchinfo"]["score"].split("-")[0]); $("#matchinfo_kd_bf").text(res.data["match_info"]["matchinfo"]["score"].split("-")[1]); //console.log(res.data["match_info"]["matchinfo"]["status"]); if(res.data["match_info"]["matchinfo"]["type"] =="2" && res.data["match_info"]["matchinfo"]["status"]!="1"){ try{ htmlContent += "
关键数据
"; htmlContent += "
"; }catch (e) { // 这里是处理错误的代码 console.log(e); // 打印错误信息 } } if(res.data["match_info"]["matchinfo"]["type"] =="1" && res.data["match_info"]["matchinfo"]["status"]=="0" && res.data["zhibo"].hasOwnProperty("stats")){ try{ htmlContent += "
关键数据
技术数据
"; }catch (e) { //console.log(e); // 打印错误信息 } } if(res.data["match_info"]["matchinfo"]["type"] =="1" && res.data["match_info"]["matchinfo"]["status"]=="2" && res.data["tongji"].hasOwnProperty("stats")){ try{ htmlContent += "
关键数据
技术数据
"; }catch (e) { // 这里是处理错误的代码 console.log(e); // 打印错误信息 } } $("#gjsj").append(htmlContent); /**比分百分比**/ $(".boxC ul li").each(function(){ const zd_current = $(this).find(".num_zd").text(); const kd_current = $(this).find(".num_kd").text(); if(zd_current == ""){ $(this).find(".num_zd").text(0); } if(kd_current == ""){ $(this).find(".num_kd").text(0); } const total = parseInt(zd_current) + parseInt(kd_current); const zd_percentage = (zd_current / total) * 100; const kd_percentage = (kd_current / total) * 100; $(this).find(".progress_zd .van-progress").css("width",zd_percentage + "%"); $(this).find(".progress_kd .van-progress").css("width",kd_percentage + "%"); }); /**比分百分比结束**/ if(res.data["match_info"]["matchinfo"]["type"] =="2" && res.data["tongji"].hasOwnProperty("players")){ bask_qiuyuan += "
"+res.data["match_info"]["matchinfo"]["hteam_name"]+""+res.data["match_info"]["matchinfo"]["ateam_name"]+"
"; bask_qiuyuan += "
球员
时间投篮三分罚球得分篮板助攻抢断盖帽失误犯规
"; const list = res.data["tongji"]["players"][0]; //console.log(list); $.each(list,function(i, item) { //console.log(item.teamName); bask_qiuyuan += "
"+ item[1] +"
"+item[6].split("^")[0]+""+item[6].split("^")[1]+""+item[6].split("^")[2]+""+item[6].split("^")[3]+""+item[6].split("^")[5]+"+"+item[6].split("^")[4]+""+item[6].split("^")[6]+""+item[6].split("^")[7]+""+item[6].split("^")[8]+""+item[6].split("^")[9]+""+item[6].split("^")[10]+""+item[6].split("^")[11]+"
" }) bask_qiuyuan += "
"; bask_qiuyuan += "
球员
时间投篮三分罚球得分篮板助攻抢断盖帽失误犯规
"; const list2 = res.data["tongji"]["players"][1]; //console.log(list); $.each(list2,function(i, item) { //console.log(item.teamName); bask_qiuyuan += "
"+ item[1] +"
"+item[6].split("^")[0]+""+item[6].split("^")[1]+""+item[6].split("^")[2]+""+item[6].split("^")[3]+""+item[6].split("^")[5]+"+"+item[6].split("^")[4]+""+item[6].split("^")[6]+""+item[6].split("^")[7]+""+item[6].split("^")[8]+""+item[6].split("^")[9]+""+item[6].split("^")[10]+""+item[6].split("^")[11]+"
" }) bask_qiuyuan += "
"; } $("#bask_qiuyuan").append(bask_qiuyuan); /**文字直播**/ //console.log(res.data["zhibo"]["tlive"]); //console.log(res.data["match_info"]["matchinfo"]["type"]); if(res.data["match_info"]["matchinfo"]["type"] =="1" && res.data["zhibo"].hasOwnProperty("tlive")){ //console.log("足球"); text_zhibo += "
文字直播
"; $arr5 = res.data["zhibo"]["tlive"]; $.each($arr5,function(i, item) { text_zhibo += "

"+ item["data"] +"

"; }) text_zhibo += "
查看更多
"; } if(res.data["match_info"]["matchinfo"]["type"] =="2" && res.data["zhibo"].hasOwnProperty("tlive")){ //console.log("篮球"); text_zhibo += "
文字直播
第一节第二节第三节第四节
"; text_zhibo += "
"; $arr1 = res.data["zhibo"]["tlive"][0]; $.each($arr1,function(i, item) { text_zhibo += "

"+item.split("^")[2]+" "+item.split("^")[6]+"

"; }) text_zhibo += "
"; text_zhibo += "
"; $arr2 = res.data["zhibo"]["tlive"][1]; $.each($arr2,function(i, item) { text_zhibo += "

"+item.split("^")[2]+" "+item.split("^")[6]+"

"; }) text_zhibo += "
"; text_zhibo += "
"; $arr3 = res.data["zhibo"]["tlive"][2]; $.each($arr3,function(i, item) { text_zhibo += "

"+item.split("^")[2]+" "+item.split("^")[6]+"

"; }) text_zhibo += "
"; text_zhibo += "
"; $arr4 = res.data["zhibo"]["tlive"][3]; $.each($arr4,function(i, item) { text_zhibo += "

"+item.split("^")[2]+" "+item.split("^")[6]+"

"; }) text_zhibo += "
"; text_zhibo += "
查看更多
"; } $("#text_zhibo").append(text_zhibo); } }); } /**篮球直播内页直播切换**/ $(document).on("click", ".boxD .part span", function () { $(this).addClass("on").siblings().removeClass('on'); $(".boxD .partdetail").eq($(this).index()).addClass("show").siblings().removeClass('show'); }); $(document).on("click", ".item .textmore", function () { if ($('.textmore a').text() == '查看更多') { $(".textmore a").text("点击收起"); $(".boxD").addClass("autoheight"); }else{ $(".textmore a").text("查看更多"); $(".boxD").removeClass("autoheight"); } }) $(document).on("click", ".match_info_item .baskball_part span", function () { $(this).addClass("on").siblings().removeClass('on'); $(".baskball_partmain .baskball_part_qiuyuan_bifen").eq($(this).index()).addClass("show").siblings().removeClass('show'); }); /**首页球队排行**/ $(".team_rank_main .team_rank_match span").click(function() { $(this).addClass("on").siblings().removeClass('on'); $(".team_rank_main .team_rank_item").eq($(this).index()).addClass("on").siblings().removeClass('on'); $('.team_rank_score li').remove(); $(".team_rank_item.on .team_rank_match_saishi span:nth-child(1)").trigger("click"); }) $(".team_rank_item .team_rank_match_saishi span").click(function() { var dtype = $(this).attr('data-type'); var dtext = $(this).attr('data-text'); var dssid = $(this).attr('data-ssid'); $(this).addClass("on").siblings().removeClass('on'); $('.team_rank_score li').remove(); if (dtype == "1") { $.ajax({ type: "get", url: 'https://api.sportsdatacdn.com/app/matchTeam', contentType: "application/json; charset=utf-8", data: { type_id: dtype, competition_id: dssid }, dataType: "json", //data: JSON.stringify(person), success: function(data) { const list = data.list; $.each(list, function(i, item) { //console.log(item.teamName); var num = i + 1; if (i < 15) { $('.team_rank_score').append('
  • ' + num + '' + item.teamName + '' + item.sdf + '' + item.points + '
  • '); } }) } }); } if (dtext == "cba") { $(".team_rank_match_saishi_east_west").removeClass('on'); $('.team_rank_score li').remove(); $.ajax({ type: "get", url: 'https://api.sportsdatacdn.com/app/matchTeam', contentType: "application/json; charset=utf-8", data: { type_id: dtype, competition_id: dssid }, dataType: "json", //data: JSON.stringify(person), success: function(data) { const list = data.list; $.each(list, function(i, item) { //console.log(item.teamName); var num = i + 1; if (i < 15) { $('.team_rank_score').append('
  • ' + num + '' + item.teamName + '' + item.sdf + '' + item.wonRate + '
  • '); } }) } }); } if (dtext =="nba") { $(".team_rank_match_saishi_east_west").addClass("on"); $(".team_rank_match_saishi_east_west span").first().addClass("on").trigger("click"); $('.team_rank_score li').remove(); } }); $(".team_rank_item .team_rank_match_saishi_east_west span").click(function() { var dtype = $(this).attr('data-type'); var dtext = $(this).attr('data-text'); var dssid = $(this).attr('data-ssid'); $(this).addClass("on").siblings().removeClass('on'); $('.team_rank_score li').remove(); $.ajax({ type: "get", url: 'https://api.sportsdatacdn.com/app/liveTeamRanking', contentType: "application/json; charset=utf-8", data: { type_id: dtype, competitionId: dssid }, dataType: "json", //data: JSON.stringify(person), success: function(data) { const list = data.nbaData[dtext]; //console.log(list); $.each(list, function(i, item) { //console.log(item.teamName); var num = i + 1; if (i < 15) { $('.team_rank_score').append('
  • ' + num + '' + item.teamName + '' + item.ressult + '' + item.wonRate + '
  • '); } }) } }); }); /**首页球队切换**/ $(".section-tit-nav span").click(function(){ $(this).addClass("on").siblings().removeClass('on'); $(".section-hot-team-box").eq($(this).index()).addClass("on").siblings().removeClass('on').trigger("scroll"); }); $(".section-tit-nav2 span").click(function(){ $(this).addClass("on").siblings().removeClass('on'); $(".index_video_list_qh ul").eq($(this).index()).addClass("show").siblings().removeClass('show').trigger("scroll"); }); $(".match_top .swiper-wrapper .swiper-slide").click(function(){ $(this).show().siblings('.swiper-slide').hide(); swiper.slideTo($(this).index(), 1000, false); }); $('.match .lmsenav a').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.match .match_list .match_box').eq($(this).index()).show().siblings().hide().trigger("scroll"); }) /**头条新闻**/ $(".toutiaonews .titnav a").click(function(){ $(this).addClass('on').siblings().removeClass('on') $('.toutiaonewsmain ul').eq($(this).index()).show().siblings().hide(); }); /**录像推荐**/ $('.luxiangtuijian .tit-nav2 a').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.index_video_list_qh ul').eq($(this).index()).addClass("show").siblings().removeClass("show").trigger("scroll"); }) $('.hotqiudui .lmsenav a').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.hotqiuduimain .item').eq($(this).index()).show().siblings().hide().trigger("scroll"); }) $('.match_analysis .senav span').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.tabmain .item').eq($(this).index()).show().siblings().hide(); }) $('.match .matchlistsenav a').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.match .match_list .match_box').eq($(this).index()).show().siblings().hide().trigger("scroll"); }) $('.mobilemenu').on('click', function () { $(".header_menu").toggle(); }) $('.shaixuan').on('click', function () { $(".tit-nav2").toggleClass("autoheight"); }) $('.icooff').on('click', function () { $(".match_zhibo_nav").fadeOut(); $(".mobilenav_bg").fadeOut(); }) /**内页左侧栏目导航**/ $(".ny_leftside .navlist dl dt").click(function() { if ($(this).parent().hasClass("on")) { $(this).parent().removeClass('on'); $(this).find(".caret").removeClass('fa-angle-up').addClass("fa-angle-down"); } else { $(this).parent().addClass("on").siblings().removeClass('on'); $(".ny_leftside .navlist dl dt span").removeClass('fa-angle-up').addClass("fa-angle-down"); $(this).find(".caret").removeClass('fa-angle-down').addClass("fa-angle-up"); } }); /**比分百分比**/ $(".boxC ul li").each(function(){ const zd_current = $(this).find(".num_zd").text(); const kd_current = $(this).find(".num_kd").text(); if(zd_current == ""){ $(this).find(".num_zd").text(0); } if(kd_current == ""){ $(this).find(".num_kd").text(0); } const total = parseInt(zd_current) + parseInt(kd_current); const zd_percentage = (zd_current / total) * 100; const kd_percentage = (kd_current / total) * 100; $(this).find(".progress_zd .van-progress").css("width",zd_percentage + "%"); $(this).find(".progress_kd .van-progress").css("width",kd_percentage + "%"); }); /**篮球直播内页文字直播切换**/ $(".boxD .part span").click(function(){ $(this).addClass("on").siblings().removeClass('on'); $(".boxD .partdetail").eq($(this).index()).addClass("show").siblings().removeClass('show'); }); $(".item .textmore").click(function(){ if ($('.textmore a').text() == '查看更多') { $(".textmore a").text("点击收起"); $(".boxD").addClass("autoheight"); }else{ $(".textmore a").text("查看更多"); $(".boxD").removeClass("autoheight"); } }) $(document).on("click", ".baskball_part span", function () { $(this).addClass("on").siblings().removeClass('on'); $(".baskball_partmain .baskball_part_qiuyuan_bifen").eq($(this).index()).addClass("show").siblings().removeClass('show'); }); /**品牌专题页查看更多**/ $('#loadMoreBtn').click(function(){ if($('#loadMoreBtn').children("span").text()=="点击展开更多"){ $('#match_zt_jieshao').addClass("show"); $('#loadMoreBtn img').addClass("up"); $(this).children("span").text('点击收起'); }else{ $('#match_zt_jieshao').removeClass("show"); $(this).children("span").text('点击展开更多'); $('#loadMoreBtn img').removeClass("up"); } }) /**实时比分聚合查询**/ function get_all_match_source(){ var fulljson= ''; $('.match_view li').each(function() { var typeid = $(this).attr('data-typeid'); var matchid = $(this).attr('data-matchid'); fulljson +='{"type_id":'+typeid+',"match_id":'+matchid+'},' }); newjson = fulljson.replace(/,$/,''); //console.log(newjson); $.ajax({ type: "GET", url: 'https://jk.asdf7.cn/app/matchDetailLive', async: true, contentType: "application/json; charset=utf-8", data: { matches: '['+newjson+']' }, dataType: "json", //data: JSON.stringify(newjson), success: function(data){ //console.log(data); $('.match_view li').each(function(index) { if(data[index].type_id == 1 && typeof(data[index].score) != "undefined"){ $('[id="zd_'+data[index].score[0]+'"]').text(data[index].score[2][0]); $('[id="kd_'+data[index].score[0]+'"]').text(data[index].score[3][0]); }else if(data[index].type_id == 2 && typeof(data[index].score) != "undefined"){ $('[id="zd_'+data[index].score[0]+'"]').text(data[index].score[3][0]+data[index].score[3][1]+data[index].score[3][2]+data[index].score[3][3]+data[index].score[3][4]); $('[id="kd_'+data[index].score[0]+'"]').text(data[index].score[4][0]+data[index].score[4][1]+data[index].score[4][2]+data[index].score[4][3]+data[index].score[4][4]); }else{ $('[id="zd_'+data[index].score[0]+'"]').text(0); $('[id="kd_'+data[index].score[0]+'"]').text(0); } }); } }); } function yget_all_match_source(){ var fulljson= ''; $('.point_teamBox .liansai').each(function() { var typeid = $(this).attr('data-typeid'); var matchid = $(this).attr('data-matchid'); fulljson +='{"type_id":'+typeid+',"match_id":'+matchid+'},' }); newjson = fulljson.replace(/,$/,''); //console.log(newjson); $.ajax({ type: "GET", url: 'https://jk.asdf7.cn/app/matchDetailLive', async: true, contentType: "application/json; charset=utf-8", data: { matches: '['+newjson+']' }, dataType: "json", //data: JSON.stringify(newjson), success: function(data){ //console.log(data); $('.point_teamBox .liansai').each(function(index) { if(data[index].type_id == 1 && typeof(data[index].score) != "undefined"){ $('[id="zd_'+data[index].score[0]+'"]').text(data[index].score[2][0]); $('[id="kd_'+data[index].score[0]+'"]').text(data[index].score[3][0]); }else if(data[index].type_id == 2 && typeof(data[index].score) != "undefined"){ $('[id="zd_'+data[index].score[0]+'"]').text(data[index].score[3][0]+data[index].score[3][1]+data[index].score[3][2]+data[index].score[3][3]+data[index].score[3][4]); $('[id="kd_'+data[index].score[0]+'"]').text(data[index].score[4][0]+data[index].score[4][1]+data[index].score[4][2]+data[index].score[4][3]+data[index].score[4][4]); }else{ $('[id="zd_'+data[index].score[0]+'"]').text(0); $('[id="kd_'+data[index].score[0]+'"]').text(0); } }); } }); } function sget_all_match_source(){ var fulljson= ''; $('.contest_swiper li').each(function() { var typeid = $(this).attr('data-typeid'); var matchid = $(this).attr('data-matchid'); fulljson +='{"type_id":'+typeid+',"match_id":'+matchid+'},' }); newjson = fulljson.replace(/,$/,''); //console.log(newjson); $.ajax({ type: "GET", url: 'https://jk.asdf7.cn/app/matchDetailLive', async: true, contentType: "application/json; charset=utf-8", data: { matches: '['+newjson+']' }, dataType: "json", //data: JSON.stringify(newjson), success: function(data){ //console.log(data); $('.contest_swiper li').each(function(index) { if(data[index].type_id == 1 && typeof(data[index].score) != "undefined"){ $('[id="zd_'+data[index].score[0]+'"]').text(data[index].score[2][0]); $('[id="kd_'+data[index].score[0]+'"]').text(data[index].score[3][0]); }else if(data[index].type_id == 2 && typeof(data[index].score) != "undefined"){ $('[id="zd_'+data[index].score[0]+'"]').text(data[index].score[3][0]+data[index].score[3][1]+data[index].score[3][2]+data[index].score[3][3]+data[index].score[3][4]); $('[id="kd_'+data[index].score[0]+'"]').text(data[index].score[4][0]+data[index].score[4][1]+data[index].score[4][2]+data[index].score[4][3]+data[index].score[4][4]); }else{ $('[id="zd_'+data[index].score[0]+'"]').text(0); $('[id="kd_'+data[index].score[0]+'"]').text(0); } }); } }); } $('.match_saishi_info ul li').click(function(){ $(this).addClass('active').siblings('li').removeClass('active'); $('.saishi_item_main .saishi_item').eq($(this).index()).show().siblings().hide(); }) /**移动端二级栏目筛选**/ $('.shaixuan').on('click', function () { $(".navlist").toggle(); }) $(document).ready(function() { // 查找带有class="on"的a标签 $('.ny_leftside .navlist dl').each(function() { $(this).removeClass('on'); }); $('.ny_leftside .navlist dl a.on').each(function() { // 对于每个找到的a标签,找到它的父栏目dt并添加class="show" $(this).closest('dl').addClass('on'); }); $(".team_rank_item.on .team_rank_match_saishi span:nth-child(1)").trigger("click"); get_all_match_source(); yget_all_match_source(); sget_all_match_source(); });