453 lines
15 KiB
PHP
453 lines
15 KiB
PHP
|
<?
|
||
|
$ftid = trim($_GET['ftid']);
|
||
|
//if($ftid <= 0) $ftid = 1;
|
||
|
|
||
|
$a = explode('_', $ftid);
|
||
|
$ftid2 = intval($a[0]);
|
||
|
$channelid = intval($a[1]);
|
||
|
|
||
|
$qs = $_SERVER['QUERY_STRING'];
|
||
|
$qs = preg_replace('/&ftid=[^&]+/', '', $qs);
|
||
|
$qs = preg_replace('/ftid=[^&]+(&|$)/', '', $qs);
|
||
|
|
||
|
if(!$ftid) {
|
||
|
die("not ftid!");
|
||
|
}
|
||
|
|
||
|
|
||
|
$iscomplete = $_GET['iscomplete'];
|
||
|
if(!$iscomplete && !$_GET['code']) {
|
||
|
header("Location: ?".$_SERVER['QUERY_STRING']."&iscomplete=1");
|
||
|
exit;
|
||
|
}
|
||
|
?>
|
||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<title>取货</title>
|
||
|
<style type="text/css">
|
||
|
html, body {
|
||
|
border: none;
|
||
|
}
|
||
|
<? include("css/normalize.css");?>
|
||
|
</style>
|
||
|
<script type="text/javascript" src="js/func.js"></script>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<script type="text/javascript">
|
||
|
var isGetting = false;
|
||
|
|
||
|
function test(code) {
|
||
|
if(code.toLowerCase().indexOf("shift") != -1) return ;
|
||
|
//code = code.replace("Num ", "").replace("num ", "");
|
||
|
if(code.toLowerCase() == 'backspace') code = '[back]';
|
||
|
if(code.toLowerCase() == 'enter') code = '[enter]';
|
||
|
dealKey('2', code);//document.getElementById("div1").innerHTML = code;
|
||
|
//tt += code+"";
|
||
|
}
|
||
|
|
||
|
function fromKeyCode(code) {
|
||
|
if((code >= 48 && code <= 57) || (code >= 65 && code <= 90)) return String.fromCharCode(code);
|
||
|
var keys = {186: ';', 188: ',', 189: '-', 190: '.', 191: '/', 222: "'", 219: '[', 221: ']', 187: '=',
|
||
|
96:'Num 0', 97:'Num 1', 98:'Num 2', 99:'Num 3', 100:'Num 4', 101:'Num 5', 102:'Num 6', 103:'Num 7', 104:'Num 8', 105:'Num 9',
|
||
|
111:'Num /', 106:'Num *', 109:'Num -', 111:'Num /', 107:'Num +',13:'[enter]',8:'[back]',110:'Num .'
|
||
|
//,45:'0', 35:'1', 40:'2', 34:'3', 37:'4', 12:'5', 39:'6', 36:'7', 38:'8', 33:'9'
|
||
|
};
|
||
|
if(keys[code]) return keys[code];
|
||
|
return '*err*';
|
||
|
}
|
||
|
function hashCode(strKey)
|
||
|
{
|
||
|
var hash = 0;
|
||
|
if(strKey != null && strKey != "")
|
||
|
{
|
||
|
for (var i = 0; i < strKey.length; i++)
|
||
|
{
|
||
|
hash = hash * 31 + strKey.charCodeAt(i);
|
||
|
hash = intValue(hash);
|
||
|
}
|
||
|
}
|
||
|
return hash;
|
||
|
}
|
||
|
|
||
|
function intValue(num)
|
||
|
{
|
||
|
var MAX_VALUE = 0x7fffffff;
|
||
|
var MIN_VALUE = -0x80000000;
|
||
|
if(num > MAX_VALUE || num < MIN_VALUE)
|
||
|
{
|
||
|
return num &= 0xFFFFFFFF;
|
||
|
}
|
||
|
return num;
|
||
|
}
|
||
|
|
||
|
document.onkeydown = function() {
|
||
|
var code = event.keyCode; //alert(code+","+fromKeyCode(code));return;
|
||
|
//[st]sduf87fjsdfysd78,526976123;
|
||
|
if(code == 16) return ;
|
||
|
dealKey('1', fromKeyCode(code));//document.getElementById("div1").innerHTML += fromKeyCode(code);
|
||
|
//document.getElementById("div1").innerHTML += fromKeyCode(code)+"|";
|
||
|
}
|
||
|
var maxInputTime = 10;
|
||
|
var kb_status = {'1':'1','2':'1'};
|
||
|
var kb_readStr = {'1':'','2':''};
|
||
|
var kb_timeOut = {'1':'','2':''};
|
||
|
var last1time = 0;
|
||
|
var nowInput = false;
|
||
|
var inputCode = '';
|
||
|
var closeTime = 0;
|
||
|
var closeItv;
|
||
|
var nowInputFrom = '1';
|
||
|
var nowLaseInput = 0;
|
||
|
var lastCloseInput = 0;
|
||
|
var lastInput1 = 0;
|
||
|
var lastSucTime = 0;
|
||
|
var lastErrTime = 0;
|
||
|
var lastddh = '';
|
||
|
|
||
|
//[st]a7nd823sd,-235435454;
|
||
|
function dealInput(c) {
|
||
|
if(new Date().getTime() - lastInput1 < 50) return ;
|
||
|
lastInput1 = new Date().getTime();
|
||
|
c = c.replace("Num ", "").replace("num ", "");
|
||
|
if(c.toLowerCase() == 'enter') c = '[enter]';
|
||
|
if(c >= '0' && c <= '9') {
|
||
|
inputCode += c;
|
||
|
$("qcm_"+inputCode.length).innerHTML = c;
|
||
|
if(inputCode.length >= 9) {
|
||
|
nowInput = false;
|
||
|
kb_status['1'] = '1';
|
||
|
kb_status['2'] = '1';
|
||
|
getOrderInfo(inputCode, '<?=$ftid?>');
|
||
|
closeInput();
|
||
|
|
||
|
return ;
|
||
|
}
|
||
|
closeTime = maxInputTime;
|
||
|
$("close_time").innerHTML = closeTime;
|
||
|
return ;
|
||
|
} else if(c == '[back]') {
|
||
|
if(inputCode != '') {
|
||
|
$("qcm_"+inputCode.length).innerHTML = ' ';
|
||
|
inputCode = inputCode.substr(0, inputCode.length-1);
|
||
|
|
||
|
}
|
||
|
return ;
|
||
|
} else if(c == '/' || c == '*' || c == '-' || c == '+' || c == '[enter]' || c == '.'){
|
||
|
closeInput();
|
||
|
return ;
|
||
|
}
|
||
|
//alert(c+","+c.length);
|
||
|
}
|
||
|
function showCloseTime() {
|
||
|
closeTime--;
|
||
|
if(closeTime <= 0) {
|
||
|
closeInput();
|
||
|
return ;
|
||
|
}
|
||
|
$("close_time").innerHTML = closeTime;
|
||
|
}
|
||
|
function startInput() {
|
||
|
nowInput = true;
|
||
|
closeTime = maxInputTime;
|
||
|
$("close_time").innerHTML = maxInputTime;
|
||
|
try{clearInterval(closeItv);}catch(e){}
|
||
|
closeItv = setInterval(showCloseTime, 1000);
|
||
|
showInput();
|
||
|
}
|
||
|
function dealKey(from, c) {
|
||
|
if(isGetting) {
|
||
|
kb_status[from] = '1';
|
||
|
readErr(from, 9);
|
||
|
return ;
|
||
|
}
|
||
|
if(nowInput) {
|
||
|
if(from == nowInputFrom) dealInput(c);
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
if(c == '[back]' || c == '[enter]') return ;
|
||
|
if(from == '1') last1time = new Date().getTime();//alert(from);
|
||
|
if(kb_status[from] == '1') { //开始
|
||
|
/*if(from == '2' && c.match(/^Num \d$/) && new Date().getTime() - lastCloseInput > 200) {
|
||
|
nowInputFrom = '2';
|
||
|
startInput();
|
||
|
dealInput(c);
|
||
|
return ;
|
||
|
}*/
|
||
|
if(c.substr(0, 4) == 'Num ' && (new Date().getTime() - lastCloseInput > 200)) {
|
||
|
if(from == '1') {
|
||
|
nowInputFrom = '1';
|
||
|
nowLaseInput = new Date().getTime();
|
||
|
startInput();
|
||
|
if(c.match(/^Num \d$/)) dealInput(c);
|
||
|
} else if(from == '2') {
|
||
|
setTimeout(function() {
|
||
|
if(new Date().getTime() - nowLaseInput > 500) {
|
||
|
nowInputFrom = '2';
|
||
|
startInput();
|
||
|
if(c.match(/^Num \d$/)) dealInput(c);
|
||
|
}
|
||
|
}, 200);
|
||
|
}
|
||
|
|
||
|
return ;
|
||
|
}
|
||
|
if(c == '[') {
|
||
|
kb_timeOut[from] = setTimeout("readErr('"+from+"', 1);", 2000);
|
||
|
kb_status[from] = '2';
|
||
|
}
|
||
|
else readErr(from, 2);
|
||
|
} else if(kb_status[from] == '2') { //读取s
|
||
|
if(c == 'S') kb_status[from] = '3';
|
||
|
else {
|
||
|
kb_status[from] = '1';
|
||
|
readErr(from, 3);
|
||
|
}
|
||
|
} else if(kb_status[from] == '3') { //读取t
|
||
|
if(c == 'T') kb_status[from] = '4';
|
||
|
else {
|
||
|
kb_status[from] = '1';
|
||
|
readErr(from, 4);
|
||
|
}
|
||
|
} else if(kb_status[from] == '4') { //读取]
|
||
|
if(c == ']') {
|
||
|
kb_status[from] = '5';
|
||
|
kb_readStr[from] = '';
|
||
|
} else {
|
||
|
kb_status[from] = '1';
|
||
|
readErr(from, 5);
|
||
|
}
|
||
|
} else if(kb_status[from] == '5') { //读取内容
|
||
|
if(c == ';') {
|
||
|
try{clearTimeout(kb_timeOut[from]);} catch(e){}
|
||
|
kb_status[from] = '1';
|
||
|
var a = kb_readStr[from].split(",");
|
||
|
if(a.length == 2) {
|
||
|
var s1 = a[0].toLowerCase();
|
||
|
var hcode = a[1];
|
||
|
if(hashCode(s1) == hcode) {
|
||
|
if(from == '1') {
|
||
|
readContent(from, s1);
|
||
|
} else {
|
||
|
setTimeout(function() {
|
||
|
if(new Date().getTime() - last1time > 1000) {
|
||
|
readContent(from, s1);
|
||
|
}
|
||
|
}, 300);
|
||
|
}
|
||
|
} else {
|
||
|
//alert(s1+","+hcode+","+hashCode(s1));
|
||
|
readErr(from, 6);
|
||
|
}
|
||
|
} else {
|
||
|
readErr(from, 7);
|
||
|
}
|
||
|
|
||
|
kb_readStr[from] = '';
|
||
|
} else {
|
||
|
if(c == '*err*') {
|
||
|
kb_status[from] = '1';
|
||
|
readErr(from, 8);
|
||
|
} else {
|
||
|
kb_readStr[from] += c;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//document.getElementById("div1").innerHTML += c+"|"+kb_status[from]+"$";
|
||
|
}
|
||
|
function readErr(from, rs) {
|
||
|
kb_status[from] = '1';
|
||
|
kb_readStr[from] = '';
|
||
|
try{clearTimeout(kb_timeOut[from]);} catch(e){}
|
||
|
//alert(from+":读取错误!"+rs);
|
||
|
if(rs != 9 && new Date().getTime() - lastErrTime > 1000 && new Date().getTime() - lastSucTime > 1000) {
|
||
|
lastErrTime = new Date().getTime();
|
||
|
lastddh = '';
|
||
|
setMsg('<div style="text-align:center;font-size:50px;padding-top:200px; color:red">无效二维码!</div>');
|
||
|
}
|
||
|
|
||
|
}
|
||
|
function setMsg(str) {
|
||
|
$("div1").innerHTML = str;
|
||
|
}
|
||
|
function readContent(from, str) {
|
||
|
//document.getElementById("div1").innerHTML += from+": "+str + '<br />';
|
||
|
if(lastddh == str && new Date().getTime() - lastSucTime < 30000) return ;
|
||
|
|
||
|
lastSucTime = new Date().getTime();
|
||
|
getOrderInfo(str, '<?=$ftid?>');
|
||
|
|
||
|
//alert(str);
|
||
|
//document.getElementById("div1").innerHTML += str;
|
||
|
}
|
||
|
function isnull(s) {
|
||
|
return (typeof(s) == 'undefined');
|
||
|
}
|
||
|
function getOrderInfo(oid, fid) {
|
||
|
setMsg("正在查询..");
|
||
|
$("hasDiv").style.display = 'none';
|
||
|
isGetting = true;
|
||
|
lastddh = '';
|
||
|
$G.ajax("/show/mall.php?act=take", {'take_code': oid, 'dining_hall_id': fid}, function(rs) {
|
||
|
try {
|
||
|
if(isnull(rs) || isnull(rs.status)) {
|
||
|
setMsg('<div style="text-align:center;font-size:50px;padding-top:200px; color:red">系统错误!</div>');
|
||
|
} else if(rs.status == '1') {
|
||
|
|
||
|
if(isnull(rs.data) || isnull(rs.data.order_detail)) {
|
||
|
setMsg('<div style="text-align:center;font-size:50px;padding-top:200px; color:red">未知错误</div>');
|
||
|
} else {
|
||
|
|
||
|
lastddh = oid;
|
||
|
var str = '';
|
||
|
var ustr = '';
|
||
|
|
||
|
if(rs.data.user) ustr = ' <span style="font-size:30px; color:#666666">('+rs.data.user.deptname+'/'+rs.data.user.username+"/"+rs.data.user.cellphone+')</span>';
|
||
|
|
||
|
var color = '';
|
||
|
|
||
|
if(!isnull(rs.data.take_status) && rs.data.take_status == 0) {
|
||
|
//str += '<span style="color:red">该二维码已取过餐!</span><br />';
|
||
|
//str += '<h2 style="color:red;font-size:30px;">该二维码已取过餐!</h2>';
|
||
|
//$("hasDiv").style.display = '';
|
||
|
color = 'color:red;';
|
||
|
}
|
||
|
//str += '<br />';
|
||
|
//str += '<table bgcolor="#000000" class="" cellpadding="0" cellspacing="1" border="0" style="'+color+'"><tr bgcolor="#ffffff"><th>类型</th><th>菜名</th><th>价格</th><th>份数</th></tr>';
|
||
|
var msgstr = ustr+'<br />订单号:'+ rs.data.order_info.code + ' <span style="color:#009900">供应商:'+rs.data.order_info.supply_name+'</span>';
|
||
|
if(rs.data.order_info.take_goods_time && rs.data.order_info.take_goods_time != null && rs.data.order_info.take_goods_time != 'null') msgstr += '<br /><span style="color:red">首次取货时间:'+ rs.data.order_info.take_goods_time+'</span>';
|
||
|
if(rs.data.user.company_id == 58 && rs.message){
|
||
|
msgstr += '<br><span style="color:red">'+rs.message+'</span>';
|
||
|
}
|
||
|
str += '<div style="width:90%; text-align:left; margin-bottom:20px;font-size:25px; line-height:1.8; color:blue">'+ msgstr +' </div>';
|
||
|
str += '<table border="2" width="90%" bgcolor="#ffffff"><tbody><tr><th class="x3">货物图片</th><th class="x2">类型</th><th class="x3">货物名称</th><th class="x2">价格</th><th class="x2">份数</th></tr>';
|
||
|
var len = rs.data.order_detail.length;
|
||
|
var height = 120;
|
||
|
if(len > 3) height = 50;
|
||
|
if(len > 6) height = 25;
|
||
|
for(var i = 0; i < len; i++) {
|
||
|
var info = rs.data.order_detail[i];
|
||
|
//str += '<tr bgcolor="#ffffff"><td width="150">'+info.type_name + '</td><td width="300">' + info.dish_name + '</td><td width="200">' + info.dish_price + '元</td><td width="100">' + info.dish_amount + "</td></tr>"
|
||
|
str += '<tr><td class="x3"><img src="'+info.pic+'" height="'+height+'"></td><td class="x2"><nobr>'+info.type_name + '</nobr></td><td class="x3" style="line-height:1.2">' + info.name + '</td><td class="x2"><nobr>' + info.goods_price + '元</nobr></td><td class="x2"><nobr>' + info.goods_amount + '</nobr></td></tr>';
|
||
|
}
|
||
|
str += '</tbody></table>';
|
||
|
|
||
|
setMsg(str);
|
||
|
flashPage(color==''?'suc':'err');
|
||
|
}
|
||
|
} else {
|
||
|
if(rs.message) setMsg('<div style="text-align:center;font-size:50px;padding-top:200px; color:red">'+rs.message+'</div>');
|
||
|
else setMsg('<div style="text-align:center;font-size:50px;padding-top:200px; color:red">未知错误</div>');
|
||
|
}
|
||
|
}
|
||
|
catch (e){}
|
||
|
isGetting = false;
|
||
|
|
||
|
}, 'json', 'POST');
|
||
|
}
|
||
|
|
||
|
function showInput() {
|
||
|
inputCode = '';
|
||
|
for(var i = 1; i <= 9; i++) {
|
||
|
$("qcm_" + i).innerHTML = ' ';
|
||
|
}
|
||
|
$G.show_div("fdiv", 500, 150);
|
||
|
}
|
||
|
function closeInput() {
|
||
|
lastCloseInput = new Date().getTime();
|
||
|
try{clearInterval(closeItv);}catch(e){}
|
||
|
nowInput = false;
|
||
|
kb_status['1'] = '1';
|
||
|
kb_status['2'] = '1';
|
||
|
inputCode = '';
|
||
|
for(var i = 1; i <= 9; i++) {
|
||
|
$("qcm_" + i).innerHTML = ' ';
|
||
|
}
|
||
|
$G.hide_div("fdiv");
|
||
|
}
|
||
|
function playVoice() {
|
||
|
try {
|
||
|
$("voice").URL = "images/di.mp3";
|
||
|
$("voice").controls.play();
|
||
|
} catch (e) {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
var flashN = 0;
|
||
|
var flashColor = 0;
|
||
|
function flashPage(type) {
|
||
|
flashN = 3;
|
||
|
if(type == 'err') flashColor = '#E27A7B';
|
||
|
else flashColor = "#DFEFD9";
|
||
|
doFlashPage();
|
||
|
}
|
||
|
function doFlashPage() {
|
||
|
document.body.style.backgroundColor = flashN%2==0?"#ffffff":flashColor;
|
||
|
flashN--;
|
||
|
if(flashN<0) {
|
||
|
document.body.style.backgroundColor = "#ffffff";
|
||
|
return ;
|
||
|
}
|
||
|
setTimeout(doFlashPage, 100);
|
||
|
}
|
||
|
window.onload = function() {
|
||
|
<? if($_GET['code']) { ?>
|
||
|
var s = '<?=$_GET['code']?>';//[st]40440368,1620547585;
|
||
|
for(var i = 0; i < s.length; i++) {
|
||
|
dealKey('1', s.substr(i, 1).toUpperCase());
|
||
|
}
|
||
|
<? } ?>
|
||
|
//
|
||
|
//alert(hashCode("80438842"));
|
||
|
//getOrderInfo('72899475', '1');
|
||
|
var width = document.documentElement.clientWidth;
|
||
|
var height = document.documentElement.clientHeight;
|
||
|
var owidth = $("qiehuan").offsetWidth;
|
||
|
var oheight = $("qiehuan").offsetHeight;
|
||
|
$("qiehuan").style.top = (height - oheight - 25) + 'px';
|
||
|
$("qiehuan").style.left = (width - owidth - 25) + 'px';
|
||
|
}
|
||
|
|
||
|
</script>
|
||
|
<div id="div1" style="font-size:30px; font-weight:bold; text-align:center">
|
||
|
<div style="text-align:center;font-size:50px;padding-top:200px">请刷取货二维码</div>
|
||
|
</div>
|
||
|
<div id="hasDiv" style="position:absolute; left:40% ; top:100px; display:none"><img src="images/has.png?r=<?=time()?>" /></div>
|
||
|
|
||
|
|
||
|
<div id="fdiv" style="position:absolute; z-index:15; width:500px; height:150px; display:none; background:#FFF; border:1px solid #dddddd;">
|
||
|
<div style="border-bottom:1px solid #dddddd; height:28px; background:#f5f5f5">
|
||
|
<div style="float:left; padding:5px 5px"><span style="color:#666666">输入取货码</span></div>
|
||
|
<div style="float:right; padding:5px 5px; font-size:13px; color:#666666"><span id="close_time" style="color:#666666"></span> 秒后或按*号关闭</div>
|
||
|
</div>
|
||
|
|
||
|
<div style="height:110px; overflow:hidden;text-align:center;width:400px;">
|
||
|
|
||
|
|
||
|
<div style="border:1px solid #dddddd;width:370px; height:40px; font-size:30px; margin-top:30px; padding:0px">
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_1"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_2"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_3"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_4"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_5"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_6"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_7"> </div>
|
||
|
<div style="border-right:1px solid #dddddd; width:40px; height:40px; float:left;text-align:center" id="qcm_8"> </div>
|
||
|
<div style=" width:40px; height:40px; float:left;text-align:center" id="qcm_9"> </div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<div id="qiehuan" style="position:absolute; z-index:4;width:200px; height:70px; top:500px; left:700px"><input type="button" style="width:200px; height:70px;font-size:30px;font-weight:bold;color:blue" value="取餐" onclick="location.href = 'qc.php?<?=$qs?>&ftid=<?=$ftid2?>&channelid=<?=$channelid?>';" /></div>
|
||
|
</body>
|
||
|
</html>
|