var setBetStatus = function (number_tab_status){ if(number_tab_status.type == 1){ //桌子停台状态或者洗牌状态 Maskplay(number_tab_status.msg,number_tab_status.in_checkout); }else if(number_tab_status.type == 2){ Maskplay(); $('#number_tab_status').val(number_tab_status.betStatus); } }; var setNumberInfo = function (round){ $('#table_id').val(round.tid); $('#boot_dt_id').val(round.boot_id); $('#boot_num').html(round.boot_num); $('#number_tab_dt_id').val(round.number_tab_id); $('#number').html(round.number_tab_number); getResultToatl(TableId,round.boot_id); //getLastBet(TableId); //获取最后3盘的下注记录 }; /* 桌子为停台中获知洗牌中的页面状态 */ function Maskplay(msg, state){ if(state == 1 || state == 2){ var table_state = 'table_status_' + state; $('#Toph').append('
'+lang[table_state]+''+'
'); }else{ $('#Toph').find(".Maskplay").remove(); } } /* 获取会员输赢 */ var user_bet = function (previous_number_tab_id){ var user_id = parseInt($('#userid').val()); if(user_id > 0 && previous_number_tab_id > 0){ var query = new Object; query.user_id = user_id; query.number_tab_id = previous_number_tab_id; query.table_id = TableId; $.ajax({ url:"/dt/user_bet", type:"POST", dataType:"JSON", data:query, async:false, success:function(data){ if(data.win_total<0){ var text_total='输 '+data.win_total+'' }else{ var text_total='赢 +'+data.win_total+'' } if(data.code == 1){ var str = '
'; $.each(data.data,function (i,e){ str += ''; }) str += '
下注 '+e.amount+' '+e.name+''+e.win+'
合计结算-'+text_total+'
'; layer.open({ type: 1, title:'结算结果', area: ['480px', 'auto'], btn: ['确定'], yes: function(){ layer.closeAll(); }, content: str }); } } }); } } /* 声音提示 */ var audioShow = function (statusType,result,previous_number_tab_id){ var audio = $("#audio").get(0); var audioStartBetPath = "/static/online/mp3/start.mp3"; var audioStopBetPath = "/static/online/mp3/stop_2.mp3"; var audioBankerWinPath = "/static/online/mp3/dragon_win.mp3"; var audioPlayerWinPath = "/static/online/mp3/tiger_win.mp3"; var audioTieWinPath = "/static/online/mp3/tie.mp3"; if(statusType == 'startBet'){ $('#audio').attr('src',audioStartBetPath); audio.play(); } if(statusType == 'stopBet'){ $('#audio').attr('src',audioStopBetPath); audio.play(); } if(statusType == 'openingDtResult' && result > 0){ if(result == 1){ //$(".play .maskResult .banker-card").addClass("win"); $('#audio').attr('src',audioBankerWinPath); audio.play(); } if(result == 2){ //$(".play .maskResult .player-card").addClass("win"); $('#audio').attr('src',audioPlayerWinPath); audio.play(); } if(result == 3){ // $(".play .maskResult .tie-card").show(); $('#audio').attr('src',audioTieWinPath); audio.play(); } // var thisResult=setTimeout(function(){ // $(".play .maskResult .item").animate({"top":"0","opacity":"0"},function(){ // $(".play .maskResult").fadeOut(100); // $(".play .maskResult .banker-card").removeClass("win"); // $(".play .maskResult .player-card").removeClass("win"); // $(".play .maskResult .tie-card").hide(); // }) // clearTimeout(thisResult); // },2200); // setTimeout(function(){ // user_bet(previous_number_tab_id); // },2300); } } /* 声音提示 end */ var setShowBet = function (showBet){ var old_now_player = parseInt($('#now_player').html()) > 0 ? parseInt($('#now_player').html()) : 0; var old_now_tie = parseInt($('#now_tie').html()) > 0 ? parseInt($('#now_tie').html()) : 0; var old_now_banker = parseInt($('#now_banker').html()) > 0 ? parseInt($('#now_banker').html()) : 0; showBet.player_amount = showBet.player_amount > 0 ? showBet.player_amount : 0; showBet.tie_amount = showBet.tie_amount > 0 ? showBet.tie_amount : 0; showBet.banker_amount = showBet.banker_amount > 0 ? showBet.banker_amount : 0; $('#now_player').html(showBet.player_amount + old_now_player); $('#now_tie').html(showBet.tie_amount + old_now_tie); $('#now_banker').html(showBet.banker_amount + old_now_banker); } var clearShowBet = function (){ $('#now_banker').html('0'); $('#now_tie').html('0'); $('#now_player').html('0'); } //庄问路 var getLudanBanker = function(){ var next = new Object; next.game_id = $('#game_id').val(); next.boot_id = $('#boot_dt_id').val(); next.forecast = 1; var returnData = false; $.ajax({ url:'/index/waybill', type:"POST", dataType:"JSON", data:next, async:false, success:function(data){ returnData = data; } }); return returnData } //闲问路 var getLudanPlayer = function(){ var next = new Object; next.game_id = $('#game_id').val(); next.boot_id = $('#boot_dt_id').val(); next.forecast = 2; var returnData = false; $.ajax({ url:'/index/waybill', type:"POST", dataType:"JSON", data:next, async:false, success:function(data){ returnData = data; } }); return returnData } var getLudan = function (TableId){ var ludan = false; var query = new Object(); query.game_id = $('#game_id').val(); query.boot_id = $('#boot_dt_id').val(); $.ajax({ url:'/index/waybill', data:query, dataType:"json", type:"POST", async:false, success:function(data){ console.log(data) if(data.code == 1){ ludan = data.data; } } }); return ludan; } var getResultToatl = function (TableId,BootId){ var query = new Object(); query.table_id = TableId; query.boot_id = BootId; $.ajax({ url:'/dt/get_result_total', data:query, dataType:"json", type:"POST", async:false, success:function(data){ if(data.code == 1){ var resultToatl = data.data; $('#result_total_player').html(resultToatl.player); $('#result_total_banker').html(resultToatl.banker); $('#result_total_tie').html(resultToatl.tie); } } }); } /* 获取游戏桌子路单列表 */ var getTableBigpath = function (game){ var returnData = false; var query = new Object(); query.game = game; $.ajax({ url:'/dt/get_table_ludan', data:query, dataType:"json", type:"POST", async:false, success:function(data){ if(data.code == 1 && data.data){ returnData = data.data; } } }); return returnData; } var tabObj=null; $(function(){ requestData(ludan); $(window).resize(function(){ requestData(ludan); if(tabObj!=null){ TabRoadcanvas(tabObj); } }) requestData(ludan); // 滚动广告 var roll=0; LiWidth=0; $(".single .notice ul li").each(function(){ LiWidth+=$(this).innerWidth() }) $(".single .notice ul").append($(".single .notice ul").html()) var timer = setInterval(notice, 20); $(".notice .roll-box").hover(function() { clearInterval(timer); },function() { timer = setInterval(notice, 20); }) function notice(){ if (roll == -LiWidth) { roll = 0; } roll -= 1; $(".notice .scroll").css({ left: roll }) } // 庄问路 $(".bankerask").click(function(){ var olddata =$.data(Obj) var requestdata=getLudanBanker(); var solo={ctb:olddata.solo.ctb,TabHeight:olddata.solo.TabHeight,CanvasWidht:olddata.solo.CanvasWidht,CanvasHeight:olddata.solo.CanvasHeight,rows:olddata.solo.rows,cols:olddata.solo.cols,Id:olddata.solo.Id,thisdata:requestdata.showRoad.show_location} var bigpath={ctb:olddata.bigpath.ctb,TabHeight:olddata.bigpath.TabHeight,CanvasWidht:olddata.bigpath.CanvasWidht,CanvasHeight:olddata.bigpath.CanvasHeight,rows:olddata.bigpath.rows,cols:olddata.bigpath.cols,Id:olddata.bigpath.Id,thisdata:requestdata.bigRoad.show_location} var bigeyepath={ctb:olddata.bigeyepath.ctb,TabHeight:olddata.bigeyepath.TabHeight,CanvasWidht:olddata.bigeyepath.CanvasWidht,CanvasHeight:olddata.bigeyepath.CanvasHeight,rows:olddata.bigeyepath.rows,cols:olddata.bigeyepath.cols,Id:olddata.bigeyepath.Id,thisdata:requestdata.bigEyeRoad.show_location} var littlepath={ctb:olddata.littlepath.ctb,TabHeight:olddata.littlepath.TabHeight,CanvasWidht:olddata.littlepath.CanvasWidht,CanvasHeight:olddata.littlepath.CanvasHeight,rows:olddata.littlepath.rows,cols:olddata.littlepath.cols,Id:olddata.littlepath.Id,thisdata:requestdata.pathway.show_location} var cockrochpath={ctb:olddata.cockrochpath.ctb,TabHeight:olddata.cockrochpath.TabHeight,CanvasWidht:olddata.cockrochpath.CanvasWidht,CanvasHeight:olddata.cockrochpath.CanvasHeight,rows:olddata.cockrochpath.rows,cols:olddata.cockrochpath.cols,Id:olddata.cockrochpath.Id,thisdata:requestdata.roach.show_location} var newdata={'solo':solo,'bigpath':bigpath,'bigeyepath':bigeyepath,'littlepath':littlepath,'cockrochpath':cockrochpath} ask(newdata,olddata); }) // 闲问路 $(".playerask").click(function(){ var olddata =$.data(Obj) var requestdata=getLudanPlayer(); var solo={ctb:olddata.solo.ctb,TabHeight:olddata.solo.TabHeight,CanvasWidht:olddata.solo.CanvasWidht,CanvasHeight:olddata.solo.CanvasHeight,rows:olddata.solo.rows,cols:olddata.solo.cols,Id:olddata.solo.Id,thisdata:requestdata.showRoad.show_location} var bigpath={ctb:olddata.bigpath.ctb,TabHeight:olddata.bigpath.TabHeight,CanvasWidht:olddata.bigpath.CanvasWidht,CanvasHeight:olddata.bigpath.CanvasHeight,rows:olddata.bigpath.rows,cols:olddata.bigpath.cols,Id:olddata.bigpath.Id,thisdata:requestdata.bigRoad.show_location} var bigeyepath={ctb:olddata.bigeyepath.ctb,TabHeight:olddata.bigeyepath.TabHeight,CanvasWidht:olddata.bigeyepath.CanvasWidht,CanvasHeight:olddata.bigeyepath.CanvasHeight,rows:olddata.bigeyepath.rows,cols:olddata.bigeyepath.cols,Id:olddata.bigeyepath.Id,thisdata:requestdata.bigEyeRoad.show_location} var littlepath={ctb:olddata.littlepath.ctb,TabHeight:olddata.littlepath.TabHeight,CanvasWidht:olddata.littlepath.CanvasWidht,CanvasHeight:olddata.littlepath.CanvasHeight,rows:olddata.littlepath.rows,cols:olddata.littlepath.cols,Id:olddata.littlepath.Id,thisdata:requestdata.pathway.show_location} var cockrochpath={ctb:olddata.cockrochpath.ctb,TabHeight:olddata.cockrochpath.TabHeight,CanvasWidht:olddata.cockrochpath.CanvasWidht,CanvasHeight:olddata.cockrochpath.CanvasHeight,rows:olddata.cockrochpath.rows,cols:olddata.cockrochpath.cols,Id:olddata.cockrochpath.Id,thisdata:requestdata.roach.show_location} var newdata={'solo':solo,'bigpath':bigpath,'bigeyepath':bigeyepath,'littlepath':littlepath,'cockrochpath':cockrochpath} ask(newdata,olddata); }) // 换桌 $(".play .game-tab .game-menu .item").click(function(){ $(this).addClass("active").siblings().removeClass("active"); var thisid = $(this).attr('id'); if(thisid == 'allTable') var game = 0; if(thisid == 'baccaratTable') var game = 1; if(thisid == 'dtTable') var game = 2; tabObj = getTableBigpath(game); TabRoadcanvas(tabObj); }) $("#road,.table_icon").click(function(){ $(".play .game-tab").show(); $(".mask-bg").show(); tabObj = getTableBigpath(0); TabRoadcanvas(tabObj); }) $(".mask-bg").click(function(){ $(".play .game-tab").hide(); $(".mask-bg").hide(); }) var setbox=true; $(".play .header .setbox").click(function(){ var right=$(".play .header .tab-control").attr("right") if(setbox==true){ $(".play .header .tab-control").animate({"right":"60px"},800) setbox=false }else{ $(".play .header .tab-control").animate({"right":"-600px"},800) setbox=true } }) // 静音 var voiced_icon=true; $(".play .control-btn .voiced_icon").click(function(){ if(voiced_icon==true){ $(this).children("i").css("backgroundImage","url('/static/online/img/silent_icon.png')") $("#audio").get(0).muted = true voiced_icon=false }else{ $(this).children("i").css("backgroundImage","url('/static/online/img/voiced_icon.png')") $("#audio").get(0).muted = false voiced_icon=true } }) //拖拽效果 window.addEventListener("load", function() { var addEventListener = 'addEventListener'; var elems = document.getElementsByClassName('dragscroll'); for (var i = 0; i < elems.length;) { (function(elem, lastClientX, lastClientY, pushed) { elem[addEventListener]('mousedown', function(e) { pushed = 1; lastClientX = e.clientX; lastClientY = e.clientY; e.preventDefault(); e.stopPropagation(); }, 0); window[addEventListener]('mousemove', function(e) { if (pushed) { elem.scrollLeft -= (- lastClientX + (lastClientX=e.clientX)); elem.scrollTop -= (- lastClientY + (lastClientY=e.clientY)); } }, 0); window[addEventListener]('mouseup', function(){ pushed = 0; }, 0); })(elems[i++]); } }, 0); }) var Vh=0,Vw=0; // 问路方法 function ask(newdata,olddata){ var time=8; var nums=setInterval(function(){ time--; var num=time%2; if(time<0){ clearInterval(nums); }else{ if(num==1){ $.each(newdata,function(index){ DateSingle(newdata[index].ctb,newdata[index].TabHeight,newdata[index].CanvasWidht,newdata[index].CanvasHeight,newdata[index].rows,newdata[index].cols,newdata[index].Id,newdata[index].thisdata,"ask"); }) }else{ $.each(olddata,function(index){ DateSingle(olddata[index].ctb,olddata[index].TabHeight,olddata[index].CanvasWidht,olddata[index].CanvasHeight,olddata[index].rows,olddata[index].cols,olddata[index].Id,olddata[index].thisdata,"ask"); }) } } },200); } function countDown(time) { $("#second").html(time); if(time == 4){ $(".play .bet-box .bet-tab .countdown").addClass("slow"); } } function stopTheTime(){ audioShow('stopBet'); $(".play .bet-box .bet-tab .countdown").removeClass("slow"); $(".play .bet-box .bet-tab .countdown").hide(); $(".play .begincard").fadeIn(100,function(){ $(".play .begincard .box").animate({"bottom":"20","opacity":"1"}) }); } var Obj={}; var SoloWidth=0,BigPathWidth=0,SmallPathWidth=0;canvasFil=0; function requestData(ludan){ Vh=$(window).height(), Vw=$(window).width(); if(Vw>1480){ $(".play .header .tab-control").css("right","45px") }else{ $(".play .header .tab-control").css("right","-600px") } if(Vw<1270){ $(".play .game-logo").hide() }else{ $(".play .game-logo").show() } var Toph=Vh*0.66 var Footh=Vh*0.32-20 var Mainh=Toph-$(".play .header").outerHeight(true); $(".play .main").css("marginTop",$(".play .header").outerHeight(true)) var Topw=$(".play .visual").width(); $("#single").height(Footh) $(".play .visual .item.bet-box").width(Topw*0.35) var Chipw=$(".play .visual .item.bet-box").outerWidth(true); $(".play .visual .item.video-box").width((Topw-Chipw)*0.65) $(".play .visual .control-box").width((Topw-Chipw)*0.35) $(".play .main").height(Mainh) $(".play .video-mini").height(Mainh*0.52) // 计算扑克的宽高 var Bleft=$(".play .visual .item.video-box").offset().left $("#begincard .box").css('min-width',(Topw-Chipw)*0.65-30) $("#begincard .box").css('left',Bleft) $("#begincard .list .card").height(Footh/2) $("#begincard .list .card").width(Footh*13/36) $("#begincard .list .draw").height(Footh*13/36) $("#begincard .list .draw .card").height(Footh*13/36) $("#begincard .list .draw .card").width(Footh*169/648) var Beth= $(".play .bet-box .line").outerHeight(true) $(".bet-view").height(Mainh-Beth) $(".play .bet-box .chip-box").height(Mainh-Beth-90) var BigPath=Math.abs((Footh-35-30)/10), SmallPath=Math.abs((BigPath*4)/6), Solo=Math.abs((Footh-8-20-30)/6) var SingleWidth=$(".play .main").width(); SoloWidth=(SingleWidth/50)*20 BigPathWidth=SingleWidth/50*30 SmallPathWidth=(SingleWidth/50*30-16)/3 $(".single .left").width(SoloWidth); $(".single .right").width(BigPathWidth); $(".single .right .small-path .item").width(SmallPathWidth); $("#control-btn").css("bottom",Toph*0.22) if(Toph<500){ $(".play .control-btn").css("display","none") }else{ $(".play .control-btn").css("display","block") } if(ludan){ if(ludan.showRoad){ CanvasTable("#solo",Solo,6,200,ludan.showRoad.show_location); }else{ CanvasTable("#solo",Solo,6,200); } if(ludan.bigRoad){ CanvasTable("#big-path",BigPath,6,100,ludan.bigRoad.show_location); }else{ CanvasTable("#big-path",BigPath,6,100); } if(ludan.bigEyeRoad){ CanvasTable("#bigeye-path",SmallPath,6,100,ludan.bigEyeRoad.show_location); }else{ CanvasTable("#bigeye-path",SmallPath,6,100); } if(ludan.pathway){ CanvasTable("#little-path",SmallPath,6,100,ludan.pathway.show_location); }else{ CanvasTable("#little-path",SmallPath,6,100); } if(ludan.roach){ CanvasTable("#cockroch-path",SmallPath,6,100,ludan.roach.show_location); }else{ CanvasTable("#cockroch-path",SmallPath,6,100); } }else{ CanvasTable("#solo",Solo,6,200); CanvasTable("#big-path",BigPath,6,100); CanvasTable("#bigeye-path",SmallPath,6,100); CanvasTable("#little-path",SmallPath,6,100); CanvasTable("#cockroch-path",SmallPath,6,100); } $(".prev").click(function(){ var MoveRecord=parseFloat($(this).siblings("canvas").css("marginLeft")), TypeId=$(this).siblings("canvas").attr("id"), Move=0; if(TypeId=="solo"){ Move=Solo }else if(TypeId=="big-path"){ Move=BigPath }else{ Move=SmallPath } if(parseInt(MoveRecord)<0){ MoveRecord= MoveRecord+Move $(this).siblings("canvas").css({marginLeft:MoveRecord}) }else{ $(this).siblings("canvas").css({marginLeft:0}) } }) $(".next").click(function(){ var MoveRecord=parseFloat($(this).siblings("canvas").css("marginLeft")), TypeId=$(this).siblings("canvas").attr("id"), Move=0; if(TypeId=="solo"){ Move=Solo }else if(TypeId=="big-path"){ Move=BigPath }else{ Move=SmallPath } MoveRecord= MoveRecord-Move $(this).siblings("canvas").css({marginLeft:MoveRecord}) }) } function CanvasTable(Id,tabHeight,row,col,path){ var TabHeight=Math.abs(tabHeight), TabWidth=TabHeight, rows=row, //排 cols=col, //列 thisdata=path, CanvasWidht=TabWidth*cols, //画布宽 CanvasHeight=TabHeight*rows, //画布高 canvasId=$(Id), ctb=canvasId[0].getContext('2d'); $(Id).attr("width",CanvasWidht) $(Id).attr("height",CanvasHeight) if(Id=="#solo"){ $.data(Obj,{"solo":{'ctb':ctb,'TabHeight':TabHeight,'CanvasWidht':CanvasWidht,'CanvasHeight':CanvasHeight,'rows':rows,'cols':cols,'Id':Id,'thisdata':thisdata}}) }else if(Id=="#big-path"){ $.data(Obj,{"bigpath":{'ctb':ctb,'TabHeight':TabHeight,'CanvasWidht':CanvasWidht,'CanvasHeight':CanvasHeight,'rows':rows,'cols':cols,'Id':Id,'thisdata':thisdata}}) }else if(Id=="#bigeye-path"){ $.data(Obj,{"bigeyepath":{'ctb':ctb,'TabHeight':TabHeight,'CanvasWidht':CanvasWidht,'CanvasHeight':CanvasHeight,'rows':rows,'cols':cols,'Id':Id,'thisdata':thisdata}}) }else if(Id=="#little-path"){ $.data(Obj,{"littlepath":{'ctb':ctb,'TabHeight':TabHeight,'CanvasWidht':CanvasWidht,'CanvasHeight':CanvasHeight,'rows':rows,'cols':cols,'Id':Id,'thisdata':thisdata}}) }else if(Id=="#cockroch-path"){ $.data(Obj,{"cockrochpath":{'ctb':ctb,'TabHeight':TabHeight,'CanvasWidht':CanvasWidht,'CanvasHeight':CanvasHeight,'rows':rows,'cols':cols,'Id':Id,'thisdata':thisdata}}) } DateSingle(ctb,tabHeight,CanvasWidht,CanvasHeight,row,col,Id,thisdata) } function DateSingle(ctb,TabHeight,CanvasWidht,CanvasHeight,rows,cols,Id,path,ask){ switch(true){ case Id=="#solo": ctb.clearRect(0, 0, TabHeight*200, TabHeight*6) Drawline(ctb,TabHeight,CanvasWidht,CanvasHeight,rows,cols) if(path){ $.each(path,function (i,n){ SoloPath(ctb,TabHeight,n.show_x,n.show_y,n.result,n.pair) }) } canvasFill=SoloWidth; break; case Id=="#big-path": ctb.clearRect(0, 0, TabHeight*100, TabHeight*6) Drawline(ctb,TabHeight,CanvasWidht,CanvasHeight,rows,cols) if(path){ $.each(path,function (i,n){ // console.log(i); // console.log(n); if(i == 0 && n.result == 'tie'){ BigPathTie(ctb,TabHeight,n.tie_num); }else{ BigPath(ctb,TabHeight,n.show_x,n.show_y,n.result,n.tie_num); } }) } canvasFill=BigPathWidth; break; case Id=="#bigeye-path": ctb.clearRect(0, 0, TabHeight*100, TabHeight*6) Drawline(ctb,TabHeight,CanvasWidht,CanvasHeight,rows,cols) if(path){ $.each(path,function (i,n){ BigeyePath(ctb,TabHeight,n.show_x,n.show_y,n.result); }) } canvasFill=SmallPathWidth; break; case Id=="#little-path": ctb.clearRect(0, 0, TabHeight*100, TabHeight*6) Drawline(ctb,TabHeight,CanvasWidht,CanvasHeight,rows,cols) if(path){ $.each(path,function (i,n){ LittlePath(ctb,TabHeight,n.show_x,n.show_y,n.result); }) } canvasFill=SmallPathWidth; break; case Id=="#cockroch-path": ctb.clearRect(0, 0, TabHeight*100, TabHeight*6) Drawline(ctb,TabHeight,CanvasWidht,CanvasHeight,rows,cols) if(path){ $.each(path,function (i,n){ CockrochPath(ctb,TabHeight,n.show_x,n.show_y,n.result); }) } canvasFill=SmallPathWidth; break; } if(path!=undefined){ var canvasmove=path[path.length-1].show_x*TabHeight if(canvasFill