Socket/app/handle/view/scan/nn_sb.html
2026-01-28 23:48:20 +08:00

249 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模拟牛牛识别端</title>
<script src="/static/handle/js/socket.io-1.4.4.js"></script>
<script src="/static/handle/js/md5.min.js"></script>
<script src="/static/handle/js/jquery-2.1.0.min.js"></script>
</head>
<body>
<div>
台桌号: <input type="text" id="tableCode" name="tableCode"><br/>
接收:<br/>
1. 启动识别: startScanEvent<br/>
2. 停止识别: stopScanEvent<br/>
3. 指定下标识别: scanIndexEvent<br/>
4. 多个位置识别: scanAllEvent<br/>
5. 停止发送数据: stopSendingDataEvent<br/>
<p></p>
发送:<br/>
1. 连接: <button onclick="join()">join</button>响应joinEvent<br/>
<!--
2. 发送数据:<button onclick="sendScan()">sendScan</button>响应sendScanEvent<br/>
3. 发送指定下标数据:<button onclick="sendScanIndex()">sendScanIndex</button>响应sendScanIndexEvent<br/>
4. 发送多个标框数据:<button onclick="sendScanAll()">sendScanAll</button>响应sendScanAllEvent<br/>
-->
起始牌:<input name="start" id="start" value="as"><button id="start_1" onclick="submitResult('start_1')">提交</button><br>
<br/>
1<input name="banker_1" id="card1" value="2s" ><button id="sub_1" onclick="submitResult('sub_1')">提交</button><br>
2<input name="banker_2" id="card2" value="3s"><button id="sub_2" onclick="submitResult('sub_2')">提交</button><br>
3<input name="banker_3" id="card3" value="4s"><button id="sub_3" onclick="submitResult('sub_3')">提交</button><br>
4<input name="banker_4" id="card4" value="5s"><button id="sub_4" onclick="submitResult('sub_4')">提交</button><br>
5<input name="banker_5" id="card5" value="6s"><button id="sub_5" onclick="submitResult('sub_5')">提交</button><br>
<br/>
6<input name="player_1" id="card6" value="7s"><button id="sub_6" onclick="submitResult('sub_6')">提交</button><br>
7<input name="player_2" id="card7" value="8s"><button id="sub_7" onclick="submitResult('sub_7')">提交</button><br>
8<input name="player_1" id="card8" value="9s"><button id="sub_8" onclick="submitResult('sub_8')">提交</button><br>
9<input name="player_2" id="card9" value="ts"><button id="sub_9" onclick="submitResult('sub_9')">提交</button><br>
10<input name="player_1" id="card10" value="js"><button id="sub_10" onclick="submitResult('sub_10')">提交</button><br>
<br/>
11<input name="player_1" id="card11" value="qs"><button id="sub_11" onclick="submitResult('sub_11')">提交</button><br>
12<input name="player_2" id="card12" value="ks"><button id="sub_12" onclick="submitResult('sub_12')">提交</button><br>
13<input name="player_1" id="card13" value="ah"><button id="sub_13" onclick="submitResult('sub_13')">提交</button><br>
14<input name="player_2" id="card14" value="2h"><button id="sub_14" onclick="submitResult('sub_14')">提交</button><br>
15<input name="player_1" id="card15" value="3h"><button id="sub_15" onclick="submitResult('sub_15')">提交</button><br>
<br/>
16<input name="player_1" id="card16" value="4h"><button id="sub_16" onclick="submitResult('sub_16')">提交</button><br>
17<input name="player_2" id="card17" value="5h"><button id="sub_17" onclick="submitResult('sub_17')">提交</button><br>
18<input name="player_1" id="card18" value="6h"><button id="sub_18" onclick="submitResult('sub_18')">提交</button><br>
19<input name="player_2" id="card19" value="7h"><button id="sub_19" onclick="submitResult('sub_19')">提交</button><br>
20<input name="player_1" id="card20" value="8h"><button id="sub_20" onclick="submitResult('sub_20')">提交</button><br>
<p></p>
</div>
<hr/>
<script>
var localSbServer="{$localSbServer}";
var socket = io(localSbServer,{transports: ['websocket']});
var token = '';
var tableCode = "B01";
var key = "tntpokeraisyn";
var stop = false;
var biz = 0;
var submitResult = function(id){
var query = new Object();
if(id == 'start_1'){
query.card = $('#start').val();
query.position = '21';
}
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";
}
if(query.card.length <= 0){
layer.alert("扫牌失败,请重新扫牌!");
return false;
}
sendScanIndex(query);
}
function join() {
tableCode = $('#tableCode').val();
var timestamp = new Date().getTime();
timestamp = Math.floor(timestamp / 1000);
var sign = md5(tableCode + key + timestamp);
console.log("发送 join 数据");
console.log('socket.emit("join",{"tableCode":"' + tableCode + '", "timestamp":"' + timestamp + '","sign":"' + sign + '"})');
socket.emit('join', {'tableCode': tableCode, 'timestamp': timestamp, 'sign': sign});
}
function sendScan() {
if (token == '') {
alert('须先join');
return ;
}
tableCode = $('#tableCode').val();
console.log("发送 sendScan 数据");
console.log('socket.emit("sendScan",{"tableCode":"' + tableCode + '", "token":"' + token + '","tableType":"ONE", "count":6, "biz":"abcd", "data":[{"index":1, "card":"3d"},{"index":2, "card":"5h"}]})');
socket.emit('sendScan', {'tableCode': tableCode, 'token': token, 'tableType':'ONE', 'count':6, 'biz': 'abcd', 'data':[{'index':1, 'card':'3d'},{'index':2, 'card':'5h'}]});
}
function sendScanIndex(data) {
if (token == '') {
alert('须先join');
return ;
}
tableCode = $('#tableCode').val();
console.log("发送 sendScanIndex 数据");
socket.emit('sendScanIndex', {'tableCode': tableCode, 'token': token, 'tableType':'ONE','biz':biz,'data':[{'index':data.position, 'card':data.card}]});
}
function sendScanAll() {
if (token == '') {
alert('须先join');
return ;
}
tableCode = $('#tableCode').val();
console.log("发送 sendScanAll 数据");
console.log('socket.emit("sendScanAll",{"tableCode":"' + tableCode + '", "token":"' + token + '","tableType":"ONE","biz":"abcd", "data":[{"index":1, "card":"3d"},{"index":2, "card":"5h"},{"index":3, "card":"5h"},{"index":4, "card":"5h"},{"index":5, "card":"kd"},{"index":6, "card":"None"}]})');
socket.emit('sendScanAll', {'tableCode': tableCode, 'token': token, 'tableType':'ONE', 'biz':'abcd', 'data':[{'index':1, 'card':'3d'},{'index':2, 'card':'5h'},{'index':3, 'card':'5h'},{'index':4, 'card':'5h'},{'index':5, 'card':'kd'},{'index':6, 'card':'None'}]});
}
// 设备
socket.on('startScanEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备接收到启动识别事件 startScanEvent');
console.log('data',data);//你好浏览器
sendScan();
});
socket.on('stopScanEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备接收到停止识别事件 stopScanEvent');
console.log('data',data);//你好浏览器
stop = true;
});
socket.on('stopSendingDataEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备接收到停止识别事件 stopSendingDataEvent');
console.log('data',data);//你好浏览器
stop = true;
});
socket.on('scanIndexEvent',(data)=>{
//监听浏览器通过msg事件发送动的信息
console.log('设备接收到识别指定下标请求事件 scanIndexEvent');
console.log('data',data);//你好浏览器
if (data.tableCode == tableCode) {
biz = data.biz;
}
});
socket.on('scanAllEvent',(data)=>{
//监听浏览器通过msg事件发送动的信息
console.log('设备接收到识别多个标框请求事件 scanAllEvent');
console.log('data',data);//你好浏览器
sendScanAll();
});
socket.on('joinEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备接收到加入响应 joinEvent');
console.log('data',data);//你好浏览器
if(data.code == 200) {token = data.token;}
});
socket.on('sendScanEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备发送识别数据后,接收到响应 sendScanEvent');
console.log('data',data);//你好浏览器
});
socket.on('sendScanIndexEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备发送指定下标识别数据后,接收到响应 sendScanIndexEvent');
console.log('data',data);//你好浏览器
});
socket.on('sendScanAllEvent',(data)=>{
//监听浏览器通过msg事件发送的信息
console.log('设备发送多标框识别数据后,接收到响应 sendScanAllEvent');
console.log('data',data);//你好浏览器
});
</script>
</body>
</html>