193 lines
7.8 KiB
HTML
193 lines
7.8 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>模拟扫描端</title>
|
||
<script type="text/javascript" src="{$Think.CONSOLE_STATIC_DOMAIN}static/console/js/jquery-2.1.0.min.js"></script>
|
||
<script type="text/javascript" src="{$Think.CONSOLE_STATIC_DOMAIN}static/online/layer-v3.1.1/layer.js"></script>
|
||
<script type="text/javascript">
|
||
var TableId = "{$table.id}";
|
||
var websocketUrl="{$websocketUrl}";
|
||
var ludan = false;
|
||
var t;
|
||
var c = "{$table.wait_time}";
|
||
</script>
|
||
</head>
|
||
<body>
|
||
起始牌:<input name="start" id="start" value="101"><button id="start_1" onclick="submitResult('start_1')">提交</button><br>
|
||
<br/>
|
||
1:<input name="banker_1" id="card1" value="102" ><button id="sub_1" onclick="submitResult('sub_1')">提交</button><br>
|
||
2:<input name="banker_2" id="card2" value="103"><button id="sub_2" onclick="submitResult('sub_2')">提交</button><br>
|
||
3:<input name="banker_3" id="card3" value="104"><button id="sub_3" onclick="submitResult('sub_3')">提交</button><br>
|
||
4:<input name="banker_4" id="card4" value="105"><button id="sub_4" onclick="submitResult('sub_4')">提交</button><br>
|
||
5:<input name="banker_5" id="card5" value="106"><button id="sub_5" onclick="submitResult('sub_5')">提交</button><br>
|
||
<br/>
|
||
6:<input name="player_1" id="card6" value="107"><button id="sub_6" onclick="submitResult('sub_6')">提交</button><br>
|
||
7:<input name="player_2" id="card7" value="108"><button id="sub_7" onclick="submitResult('sub_7')">提交</button><br>
|
||
8:<input name="player_1" id="card8" value="109"><button id="sub_8" onclick="submitResult('sub_8')">提交</button><br>
|
||
9:<input name="player_2" id="card9" value="110"><button id="sub_9" onclick="submitResult('sub_9')">提交</button><br>
|
||
10:<input name="player_1" id="card10" value="111"><button id="sub_10" onclick="submitResult('sub_10')">提交</button><br>
|
||
<br/>
|
||
11:<input name="player_1" id="card11" value="112"><button id="sub_11" onclick="submitResult('sub_11')">提交</button><br>
|
||
12:<input name="player_2" id="card12" value="113"><button id="sub_12" onclick="submitResult('sub_12')">提交</button><br>
|
||
13:<input name="player_1" id="card13" value="201"><button id="sub_13" onclick="submitResult('sub_13')">提交</button><br>
|
||
14:<input name="player_2" id="card14" value="202"><button id="sub_14" onclick="submitResult('sub_14')">提交</button><br>
|
||
15:<input name="player_1" id="card15" value="203"><button id="sub_15" onclick="submitResult('sub_15')">提交</button><br>
|
||
<br/>
|
||
16:<input name="player_1" id="card16" value="204"><button id="sub_16" onclick="submitResult('sub_16')">提交</button><br>
|
||
17:<input name="player_2" id="card17" value="205"><button id="sub_17" onclick="submitResult('sub_17')">提交</button><br>
|
||
18:<input name="player_1" id="card18" value="206"><button id="sub_18" onclick="submitResult('sub_18')">提交</button><br>
|
||
19:<input name="player_2" id="card19" value="207"><button id="sub_19" onclick="submitResult('sub_19')">提交</button><br>
|
||
20:<input name="player_1" id="card20" value="208"><button id="sub_20" onclick="submitResult('sub_20')">提交</button><br>
|
||
<br/>
|
||
是否最后一张牌:<input type="radio" id="endCard_Y" name="endCard">是 <input type="radio" id="endCard_N" name="endCard">否
|
||
</body>
|
||
<input type="hidden" id="online_token" value="{$online_token}">
|
||
<input type="hidden" id="account" value="{$user.username}">
|
||
<input type="hidden" id="userid" value="{$user.id}">
|
||
<input type="hidden" id="number_tab_status">
|
||
<input type="hidden" id="table_id" value="{$table.id}">
|
||
<input type="hidden" id="number_tab_id" value="">
|
||
<input type="hidden" id="game_id" value="{$table.game_id}">
|
||
<input type="hidden" id="is_scavenging" value="{$table.is_scavenging}">
|
||
<input type="hidden" id="endNumber" value="0">
|
||
<script>
|
||
// WebSocket 数据交互
|
||
if(window.WebSocket){
|
||
var webSocket = new WebSocket(websocketUrl);
|
||
webSocket.onerror = function(event){
|
||
layer.alert('与服务器连接断开,正在重连。。。',{icon:2,closeBtn:0});
|
||
}
|
||
webSocket.onopen = function (event) {
|
||
var userid = $('#userid').val();
|
||
var account = $('#account').val();
|
||
var online_token = $('#online_token').val();
|
||
var table_id = $('#table_id').val();
|
||
if(parseInt(userid) > 0 && account != '' && online_token != ''){
|
||
webSocket.send('{"connect":"scan","mode":"onlineLogin","appid":"80001","appsecret":"123456","table_id":"'+table_id+'"}');
|
||
}else{
|
||
webSocket.close();
|
||
layer.alert('与服务器连接断开,正在重连。。。',{icon:2,closeBtn:0});
|
||
}
|
||
};
|
||
|
||
webSocket.onmessage = function (event) {
|
||
var data = $.parseJSON(event.data);
|
||
console.log(data)
|
||
if(data.sendMode == 'onlineLogin'){
|
||
if(data.status === true){
|
||
|
||
//登录成功
|
||
setNumberInfo(data); // 设置铺信息
|
||
}else{
|
||
//登录失败
|
||
webSocket.close();
|
||
layer.alert(data.msg,{icon:2,closeBtn:0});
|
||
}
|
||
}else if(data.sendMode == 'sendScanResult'){
|
||
console.log(data);
|
||
}
|
||
};
|
||
|
||
// 设置铺信息
|
||
var setNumberInfo = function(data){
|
||
$('#number_tab_id').val(data.round.number_tab_id); // 铺ID
|
||
$('#number_tab_status').val(data.round.number_tab_status.betStatus); // 铺状态
|
||
$('#boot_num').val(data.round.boot_num);//靴数
|
||
$('#number').val(data.round.number_tab_number);// 局数
|
||
};
|
||
|
||
// 点击提交结果
|
||
var submitResult = function(id){
|
||
var query = new Object();
|
||
query.connect = "scan";
|
||
query.mode = "sendScanResult";
|
||
query.number_tab_id = parseInt($('#number_tab_id').val());
|
||
query.table_id = parseInt($('#table_id').val());
|
||
// query.is_start = 0;
|
||
if(id == 'start_1'){
|
||
query.card = $('#start').val();
|
||
query.position = '0';
|
||
}
|
||
if(id == "sub_1"){
|
||
query.card = $('#card1').val();
|
||
query.position = "1";
|
||
}else if(id == "sub_2"){
|
||
query.card = $('#card2').val();
|
||
query.position = "2";
|
||
}else if(id == "sub_3"){
|
||
query.card = $('#card3').val();
|
||
query.position = "3";
|
||
}else if(id == "sub_4"){
|
||
query.card = $('#card4').val();
|
||
query.position = "4";
|
||
}else if(id == "sub_5"){
|
||
query.card = $('#card5').val();
|
||
query.position = "5";
|
||
}else if(id == "sub_6"){
|
||
query.card = $('#card6').val();
|
||
query.position = "6";
|
||
}else if(id == "sub_7"){
|
||
query.card = $('#card7').val();
|
||
query.position = "7";
|
||
}else if(id == "sub_8"){
|
||
query.card = $('#card8').val();
|
||
query.position = "8";
|
||
}else if(id == "sub_9"){
|
||
query.card = $('#card9').val();
|
||
query.position = "9";
|
||
}else if(id == "sub_10"){
|
||
query.card = $('#card10').val();
|
||
query.position = "10";
|
||
}else if(id == "sub_11"){
|
||
query.card = $('#card11').val();
|
||
query.position = "11";
|
||
}else if(id == "sub_12"){
|
||
query.card = $('#card12').val();
|
||
query.position = "12";
|
||
}else if(id == "sub_13"){
|
||
query.card = $('#card13').val();
|
||
query.position = "13";
|
||
}else if(id == "sub_14"){
|
||
query.card = $('#card14').val();
|
||
query.position = "14";
|
||
}else if(id == "sub_15"){
|
||
query.card = $('#card15').val();
|
||
query.position = "15";
|
||
}else if(id == "sub_16"){
|
||
query.card = $('#card16').val();
|
||
query.position = "16";
|
||
}else if(id == "sub_17"){
|
||
query.card = $('#card17').val();
|
||
query.position = "17";
|
||
}else if(id == "sub_18"){
|
||
query.card = $('#card18').val();
|
||
query.position = "18";
|
||
}else if(id == "sub_19"){
|
||
query.card = $('#card19').val();
|
||
query.position = "19";
|
||
}else if(id == "sub_20"){
|
||
query.card = $('#card20').val();
|
||
query.position = "20";
|
||
}
|
||
var endCard_Y = $('#endCard_Y').is(':checked');
|
||
if(endCard_Y){
|
||
query.is_end = 1;
|
||
}else{
|
||
query.is_end = 0;
|
||
}
|
||
console.log(query);
|
||
if(query.card.length <= 0){
|
||
layer.alert("扫牌失败,请重新扫牌!");
|
||
return false;
|
||
}
|
||
query = JSON.stringify(query);
|
||
webSocket.send(query);
|
||
// location.reload();
|
||
}
|
||
}else{
|
||
layer.alert('您的浏览器不支持WebSocket',{icon:2,closeBtn:0});
|
||
};
|
||
</script>
|
||
</html>
|