web版收银系统,支持支付宝,微信扫描枪支付,数字输入

Web版收银系统

这是一款web版的系统,可以在PC,平板,手机等多平台使用,支持微信,支付宝扫码支付,对接小程序订单,界面简洁明了,而且支持键盘输入。
web版收银系统,支持支付宝,微信扫描枪支付,数字输入_第1张图片
在线测试地址:https://admin.zjhn.top/cashi/
用户名:在管理平台注册后创建雇员,或者使用:demo demo登录
如果有扫描仪,可以扫描微信,支付宝支付二维码进行支付。
代码


DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0">
<meta name="Cache-control" content="no-tranform">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="Author" content="web_author">
<meta name="apple-mobile-web-app-title" content="">
<meta name="screen-orientation" content="portrait">
<meta name="x5-orientation" content="portrait">
<meta name="browsermode" content="application">
<meta name="x5-page-mode" content="app">
<meta name="HandheldFriendly" content="true">
<meta name="msapplication-tap-highlight" content="no">
<meta name="description" content="$description">
<meta name="keywords" content="">
<title>羲云科技 收银系统title>
<script src="./jquery.js">script>
<script src="../fun.js?t=1651034247">script>
<script src="./chart.js?t=">script>
<link type="text/css" rel="stylesheet" href="../style.css?t=1651034247">

head>

<style>
body{background:#fff;font-size:14px}
main{float:left;width:100%;z-index:100;height:100vh;padding-left:350px;padding-right:340px;}
order{position:fixed;width:300px;left:50px;top:0;height:100vh;background:#efefef;z-index:100;padding:10px;padding-top:36px;padding-bottom:80px;}
pros{float:left;width:100%;height:100vh;background:#f6f6f6;padding-top:36px;padding-bottom:30px;}
jiesuan{padding-top:36px;position:fixed;width:340px;right:0;top:0;z-index:100;height:100vh;background:#efefef;z-index:100;padding-left:10px;padding-right:10px;}
main handle{width:100%;height:36px;position:absolute;background:#f9f9f9;left:0;text-align:center;line-height:36px;font-weight:bold;font-size:16px;top:0;z-index:100;padding-left:10px;}
main handle .bt{font-weight:normal;float:left;height:28px;line-height:28px;padding-left:10px;padding-right:10px;background:#feb101;color:#fff;border-radius:5px;margin-top:4px;font-size:12px;margin-right:10px;z-index:100;}
jiesuan desk{float:left;width:100%;height:40px;line-height:40px;}
jiesuan desk text{float:left;color:#feb101;font-weight:bold;margin-right:5px;}
jiesuan tx{float:left;width:100%;font-size:13px;text-align:center;color:#999}
jiesuan need_pay{float:left;width:100%;height:40px;line-height:40px;text-align:center;font-size:30px;font-weight:bold;color:#feb101}
jiesuan  c{font-size:13px;font-weight:normal;}
jiesuan ss{float:left;width:50%;}
jiesuan ss price{float:left;width:100%;height:30px;line-height:30px;text-align:center;font-size:24px;font-weight:bold;}

c_index{float:left;width:100%;height:28px;margin-top:4px;}
c_index a{float:left;font-weight:normal;font-size:13px;width:70px;text-align:center;overflow:hidden;height:28px;line-height:28px;}
c_index_box{float:left;width:100%;height:36px;overflow:hidden;overflow-x:auto;}
c_index_box::-webkit-scrollbar{height:0px;}
c_index .select{color:#feb101;font-weight:bold;}
pro_list{float:left;width:100%;height:100%;overflow-y:auto;padding:5px;background:#eee;}
pro_list::-webkit-scrollbar{width:0px;}
pro_item{float:left;width:50%;height:120px;padding:5px;}
pro_item item{float:left;width:100%;height:100%;background:#fff;border-radius:10px;overflow:hidden;padding-left:130px;padding-top:5px;padding-bottom:5px;padding-right:5px;box-shadow:0px 5px 5px 0px #ccc}
pro_item pro_img{position:absolute;width:120px;height:110px;left:0;top:0;}
pro_item pro_title{float:left;width:100%;line-height:20px;font-size:14px;font-weight:bold;overflow:hidden;max-height:40px;}

pro_item pro_c{float:left;font-size:12px;color:#999}
pro_price{position:absolute;bottom:5px;width:100%;padding-left:130px;left:0;font-size:22px;font-weight:bold;color:crimson;}
pro_price c{font-size:12px;font-weight:normal;}
pro_item pro_title b{color:crimson;margin-right:3px;}
num_bt{position:absolute;right:5px;bottom:5px;z-index:100;cursor:pointer;}
num_bt a{float:right;font-size:32px !important;color:#feb101;}
num_bt bt{float:right;height:28px;line-height:28px;background:#feb101;color:#fff;font-size:12px;padding-left:14px;padding-right:14px;bottom:3px;border-radius:15px;box-shadow:1px 1px 3px 0 rgba(0,0,0,0.2);}

pro_item buy_num{display:none;position:absolute;width:18px;height:18px;line-height:18px;border-radius:50%;background:crimson;color:#fff;font-size:10px;text-align:center;top:5px;right:5px;box-shadow:1px 1px 3px 0 rgba(0,0,0,0.2);z-index:100;}

pro_min_item{float:left;width:20%;height:180px;padding:5px;min-width:150px;}
pro_min_item item{float:left;width:100%;height:100%;background:#fff;border-radius:10px;overflow:hidden;box-shadow:0px 5px 5px 0px #ccc}
pro_min_item pro_img{float:left;width:100%;height:100px;}
pro_min_item pro_title{float:left;width:100%;height:18px;line-height:18px;overflow:hidden;margin-top:3px;padding-left:5px;padding-right:5px;font-weight:bold;}
pro_min_item pro_c{float:left;width:100%;height:18px;line-height:18px;font-size:12px;color:#666;padding-left:5px;}
pro_min_item pro_price{padding-left:5px}
pro_min_item buy_num{position:absolute;width:16px;font-size:10px;text-align:center;top:-2px;right:0px;height:16px;border-radius:50%;background:crimson;color:#fff;line-height:16px;display:none}
pro_min_item bt buy_num{top:-3px}



cart_box{float:left;width:100%;height:100%;overflow-y:auto;padding-bottom:10px}
cart_c{float:left;width:100%;margin-top:10px;font-size:13px;color:#666}
cart_c b{color:crimson;}
cart_box::-webkit-scrollbar{width:0px;}
cart_item{float:left;width:100%;height:90px;margin-top:10px;background:#fff;border-radius:10px;overflow:hidden;padding-left:100px;padding-top:5px;padding-bottom:5px;padding-right:5px;box-shadow:0px 5px 5px 0px #ccc,-1px -1px 0 0 #eee}
cart_item pro_img{position:absolute;width:90px;height:90px;left:0;top:0;background:#f44;}

cart_item pro_title{float:left;width:100%;line-height:20px;font-size:13px;font-weight:bold;max-height:40px;overflow:hidden;}
cart_item pro_title b{color:crimson !important;}
cart_item pro_price{padding-left:95px;}
cart_item cart_num_box{position:absolute;right:5px;bottom:5px;z-index:100}
cart_num_box .icon{float:right;font-size:26px;color:#feb101;}
cart_num_box input{float:right;height:28px;line-height:28px;width:20px;text-align:center;font-size:15px;}
cart_num_box .icon-minus-circle-outline{color:#ccc;font-size:26px}

data_title{float:left;width:100%;height:20px;line-height:20px;color:#999;font-size:13px;}
data_item{float:left;width:25%;padding:5px;}
data_item item{float:left;width:100%;height:36px;line-height:36px;text-align:center;font-size:13px;padding-left:10px;padding-right:10px;border-radius:16px;box-shadow:1px 1px 1px 0 rgba(0,0,0,0.2);background:#ccc;overflow:hidden;}
data_item .select{background:crimson;color:#fff;}
pro_data_box{float:left;width:100%;margin-top:10px;height:40px;line-height:40px;}
pro_data_box text{float:left;color:#666;font-size:12px;}
pro_data_box c{float:left;font-size:12px;color:crimson;}
pro_data_box price{float:left;font-size:22px;font-weight:bold;color:crimson;}
pro_data_box bt{margin-top:2px;float:right;height:36px;line-height:36px;background:#feb101;padding-left:20px;padding-right:20px;border-radius:18px;color:#fff;font-size:14px;}
pro_info{float:left;width:100%;line-height:18px;font-size:12px;font-weight:bold;color:#feb101;}
pro_info xx{color:#999;}

order_info_box{position:absolute;width:100%;bottom:0;left:0;padding:5px;height:80px;background:#e9e9e9;padding-left:10px;}
order_info_box price_box{float:left;width:100%;height:24px;line-height:24px;}
order_info_box c{font-size:12px;float:left;line-height:27px;color:crimson;}
order_info_box total{float:left;font-size:24px;font-weight:bold;color:crimson;}
order_info_box hui{float:left;margin-left:10px;font-size:13px;color:#666}
order_info_box x{color:crimson;font-weight:bold;padding-left:2px;padding-right:2px;}
order_info_box cart_info{float:left;width:100%;height:16px;line-height:16px;font-size:13px;overflow:hidden;display:none;}
order_info_box bts{float:left;width:100%;margin-top:10px;}
order_info_box bts a{float:right;height:32px;line-height:32px;padding-left:20px;padding-right:20px;background:#feb101;color:#fff;font-size:13px;margin-left:5px;margin-right:5px;border-radius:5px;}
order_info_box bts a:hover{background:crimson;}
.bt_red{background:crimson !important;color:#fff;}

pros handle icon{position:absolute;right:15px;z-index:100;}
search_box{position:absolute;width:200px;top:2px;height:32px;line-height:32px;background:#fff;right:-300px;z-index:100;}
search_box input{float:left;width:100%;padding-left:10px;padding-right:10px;height:32px;line-height:32px;}
.js_select text{background:#feb101 !important;}

style>
<body>
<style>
nav{background:#35374c;width:50px;height:100vh;left:0;top:0;z-index:10000;position:fixed;color:#feb101;padding-top:15px;}
nav a{float:left;width:100%;height:60px;line-height:60px;text-align:center;font-size:28px !important;}
nav a:hover{color:#7ebeec}
nav logo{float:left;width:32px;height:32px;margin-left:9px;border-radius:5px;margin-bottom:10px;}
nav .select{color:#7ebeec;}
left_win{position:fixed;width:100vw;height:100vh;left:0;top:0;z-index:1000;padding-left:50px;display:none;}
left_win win_box{max-width:80vw;background:#efefef;height:100%;min-width:200px;position:absolute;left:-100vw;top:0;z-index:100;padding-top:40px;padding-bottom:10px;}
left_win bg{position:absolute;width:100%;height:100%;z-index:1;background:rgba(0,0,0,0.5);display:block;z-index:0;}
.left_show{display:block;}
left_win_handle{position:absolute;width:100%;height:40px;line-height:40px;background:#ccc;top:0;left:0;padding-left:10px;padding-right:50px;}
left_main{float:left;width:100%;height:100%;overflow-y:auto;}
left_win_handle bts{float:right;}
left_win_handle bts a{margin-top:4px;float:right;height:32px;line-height:32px;margin-left:10px;background:#ccc;color:#666;font-size:13px;padding-left:10px;padding-right:10px;border-radius:5px;}
left_win_handle bts a:hover{background:crimson;color:#fff;}
left_win_handle .blue{background:#00c8dc;color:#fff;}
left_win_handle .red,left_win_handle .select{background:crimson;color:#fff;}
left_win_handle close_bt{position:absolute;width:40px;height:40px;font-size:25px !important;right:0;top:0;z-index:100;text-align:center;}
left_win_handle close_bt:hover{color:#f44;}
left_main::-webkit-scrollbar{width:0px;}

no_data{float:left;width:100%;display:flex;flex-direction:row;justify-content:center;align-items:center;margin-top:30px;}
no_data_text{float:left;width:100%;margin-top:10px;text-align:center;}

scan_win{display:none;position:fixed;width:100vw;height:100vh;z-index:1000;padding-left:50%;background:rgba(0,0,0,0.5);}
scan_box{float:left;width:360px;padding:10px;background:#fff;border-radius:10px;margin-left:-180px;margin-top:15vh;}
scan_box handle{float:left;width:100%;height:30px;line-height:25px;text-align:center;border-bottom:1px solid #eee;}
scan_box icon{position:absolute;right:0;top:0;font-size:24px !important;z-index:100;}
scan_box scan_icon{float:left;width:100%;font-size:200px !important;text-align:center;margin-top:10px;color:#999}
scan_box text{float:left;width:100%;height:24px;line-height:24px;color:crimson;text-align:center;}
scan_box bt{float:left;width:70%;margin-left:15%;text-align:center;height:50px;line-height:50px;color:#fff;background:#00c8dc;border-radius:5px;font-size:14px;}


js_time_win{position:fixed;width:100vw;height:100vh;z-index:1000;padding-left:50%;background:rgba(0,0,0,0.5);display:none;}
js_time_box{float:left;width:600px;padding:10px;background:#fff;border-radius:10px;margin-left:-300px;margin-top:15vh;}
js_time_box handle{float:left;width:100%;height:30px;line-height:25px;text-align:center;border-bottom:1px solid #eee;}
js_time_box icon{position:absolute;right:0;top:0;font-size:24px !important;z-index:100;}
js_time_bt bt{float:left;width:200px;text-align:center;height:46px;line-height:46px;color:#fff;background:#00c8dc;border-radius:5px;font-size:14px;margin-left:10px;margin-right:10px}
js_time_bt{float:left;width:100%;margin-top:10px;display:flex;justify-content:center;align-content:center;}
js_time_main{float:left;width:100%;margin-top:10px;}
nav num{display:none;position:absolute;width:20px;height:20px;background:crimson;color:#fff;font-size:12px;text-align:center;border-radius:50%;line-height:20px;top:8px;right:5px;overflow:hidden;}

style>
<nav>
<logo style="background:url(https://img8.zjhn.com/logo.jpg) no-repeat center;">logo>
<a class="icon icon-diannao select" onclick="left_close($(this))">a>
<a class="icon icon-order" onclick="left_win({title:'订单管理',url:'./order.php?t=1651034247',width:'50vw',bt:'待支付已完成已付款'})">
<num id="app_order_num">num>
a>
<a class="icon icon-caidan" onclick="select_desk($(this))">a><a class="icon icon-naozhong" onclick="left_win({title:'预订列表',url:'./time.php',width:'500px',bt:'新预订'})">
    <num id="time_num">num>
    
a>
<a class="icon icon-xuanzhonghaoyou" onclick="left_win({title:'会员管理',url:'./member.php',width:'500px',bt:'开卡'})">a>

<a class="icon icon-shouyi" onclick="left_win({title:'订单统计&交接班',url:'./data.php?t='+(new Date).getTime(),width:'800px'})">a>
<a class="icon icon-shezhi" onclick="left_win({title:'系统设置',url:'./set.php',width:'500px'})">a>
<a class="icon icon-help-circle-outline" style="bottom:60px;position:absolute;left:0;font-size:26px !important;" onclick="left_win({title:'帮助中心',url:'./help.php?c=收银系统',width:'800px'})">a>
<a class="icon icon-mb_zhuxiao" style="bottom:10px;position:absolute;left:0;font-size:26px !important;" onclick="loginout($(this))">a>
nav>


<left_win class="m"><win_box class="m">
<left_win_handle><text>text><bts>bts><close_bt class="icon icon-close" onclick="left_close($(this))">close_bt>left_win_handle>
<left_main>left_main>
win_box><bg onclick="left_close($(this))">bg>left_win>

<scan_win onclick="scan_win_close();">
<scan_box>
<handle>等待扫描二维码<icon class="icon icon-close">icon>handle>
<scan_icon class="icon icon-saoyisao">scan_icon>
<text>text>
<bt >关闭窗口bt>
scan_box>
scan_win>

<js_time_win>
<js_time_box>
<handle>初始化结算handle>
<js_time_main>

js_time_main>
<js_time_bt>
<bt onclick="js_time_submit($(this))" c="submit">确定bt>
<bt style="background:#999" onclick="js_time_submit($(this))" c="close">取消bt>
js_time_bt>
js_time_box>
js_time_win><main>
<order>
<handle style="text-align:left;">
<a class="bt" onclick="clean_cart($(this))">清空a>
<a class="bt cart_cache" onclick="cache_cart($(this))">暂存a>早餐店handle>
<cart_box>cart_box>
<order_info_box>
<price_box><c>合计¥c><total>0.00total><hui><x>10x>件商品hui>price_box>
<cart_info>共100件商品cart_info>
<bts>
<a class="m desk" onclick="select_desk($(this))">餐桌a>
<a class="m cart_cache" onclick="cache_cart($(this))">暂存a>
<a class="m" onclick="clean_cart($(this))">清空a>
bts>
order_info_box>
order>

<pros>
<handle style="padding-right:50px;"><icon class="icon icon-Search" onclick="search_open($(this))">icon>
<c_index_box><search_box class="m"><input placeholder="请输入关键词" onkeyup="search_it($(this))">search_box>
<c_index style="width:420px">
<a class="select" onclick="pro_load_all($(this))">全部a>
<a onclick="load_c($(this))" c="特产">特产a><a onclick="load_c($(this))" c="包子">包子a><a onclick="load_c($(this))" c="西点">西点a><a onclick="load_c($(this))" c="混沌水饺">混沌水饺a>c_index>    
c_index_box>
handle>

<pro_list>pro_list>

pros>

<jiesuan>
<handle>结 算handle>
<desk onclick="select_desk($(this))"><text >餐牌号:text><x>x>desk><tx>应收tx>
<need_pay><c>c><total>0.00total>need_pay>
<ss>
<tx>实收tx>
<price class="need_pay" id="need_pay"><c>c><text>0.00text>price>
ss>
<ss>
<tx>找零tx>
<price style="color:crimson;" id="lingqian"><c>c><text>0.00text>price>
ss>

<ss>
<tx>折扣tx>
<price class="zk" style="font-size:16px ">-price>
ss>
<ss>
<tx>会员IDtx>
<price class="huiyuan" style="font-size:16px ">-price>
ss>


<users>

users>

<input id="input" placeholder="卡号" >
<audio_obj>audio_obj>

<style>
jp{position:absolute;width:100%;bottom:20px;z-index:100;padding-left:80px;left:6px;text-align:center;}
jp view{float:left;width:60px;height:60px;padding:5px;}
jp text{float:left;width:100%;height:100%;background:#eee;;line-height:50px;border-radius:10px;font-size:28px;font-weight:bold;box-shadow: -0.316666666666667vw -0.316666666666667vw 0.95vw #fff, 0.316666666666667vw 0.316666666666667vw 0.633333333333333vw #ccc;    }
jp .keydown{box-shadow: inset -0.316666666666667vw -0.316666666666667vw 0.95vw -0.158333333333333vw #fff, inset 0.316666666666667vw 0.316666666666667vw 0.633333333333333vw #ccc;  color: #000 !important;background:#eee !important;}
jp .money{font-size:18px;line-height:60px}
jp c{font-size:10px}
jp .icon{font-size:22px !important}
jp .js_bt{width:120px;}
jp .js_bt text{font-size:16px;background:#53c7a0;color:#fff}
jp how_pay{position:absolute;width:75px;bottom:0;left:5px;z-index:100;}
jp how_pay view{width:100%;}
jp how_pay text{background:#7ebeec;font-size:16px;color:#fff;;}
jp how_pay .select{background:#feb101}


style>

<jp>

<view ><text class="m" onclick="num_click($(this))" val="1" id="keynum_1">1text>view>
<view><text class="m" onclick="num_click($(this))" val="2" id="keynum_2">2text>view>
<view><text class="m" onclick="num_click($(this))" val="3" id="keynum_3">3text>view>
<view ><text class="money m" onclick="num_click($(this))" val="100"><c>c>100text>view>

<view><text class="m" onclick="num_click($(this))" val="4" id="keynum_4">4text>view>
<view><text class="m" onclick="num_click($(this))" val="5" id="keynum_5">5text>view>
<view><text class="m" onclick="num_click($(this))" val="6" id="keynum_6">6text>view>
<view ><text class="money m" onclick="num_click($(this))" val="50"><c>c>50text>view>

<view><text class="m" onclick="num_click($(this))" val="7" id="keynum_7">7text>view>
<view><text class="m" onclick="num_click($(this))" val="8" id="keynum_8">8text>view>
<view><text class="m" onclick="num_click($(this))" val="9" id="keynum_9">9text>view>
<view ><text class="money m" onclick="num_click($(this))" val="20"><c>c>20text>view>

<view><text class="m" onclick="num_click($(this))" val="0" id="keynum_0">0text>view>
<view><text class="m" style="font-size:22px;line-height:60px;" onclick="num_click($(this))" val="db0">00text>view>
<view><text class="m" onclick="num_click($(this))" val="." id="keynum_">.text>view>
<view ><text class="money m" onclick="num_click($(this))" val="10"><c>c>10text>view>


<view><text class=" m" style="font-size:22px;" onclick="num_click($(this))" val="ac">ACtext>view>
<view><text class="icon icon-backdelete m" onclick="num_click($(this))" val="del" id="del_bt">text>view>
<view class="js_bt"><text onclick="jiesuan($(this));keydown($(this));" val="enter">结 算text>view>

<how_pay>
<view><text class="" id="use_cashi" onclick="num_click($(this));keydown($(this));" val="cashi">现 金text>view>
<view><text class=" " id="use_weixin" onclick="num_click($(this));keydown($(this));" val="weixin">微 信text>view>
<view><text class="" id="use_alipay" onclick="num_click($(this));keydown($(this));" val="alipay">支付宝text>view>
<view><text class="" id="use_member" onclick="num_click($(this));keydown($(this));" val="member">会 员text>view>
<view><text class="" id="use_zk" onclick="num_click($(this));keydown($(this));" val="hx">核 销text>view>
how_pay>
jp><style>
*{box-sizing:border-box;}
msg_win{position:fixed;width:50%;left:25%;top:10vh;z-index:1000000;color:#000;border-radius:10px;background:#fff;overflow:hidden;display:none;}
bg{position:fixed;width:100%;height:100vh;left:0;top:0;z-index:10000;}
msg_title{float:left;width:100%;height:48px;line-height:48px;text-align:center;font-size:20px;background:#00c8dc;color:#fff;}
msg_title icon{position:absolute;right:10px;font-size:24px !important;z-index:100;top:-5px;z-index:100}
order_num{float:left;width:100%;height:20px;line-height:20px;font-size:16px;}
order_num text{float:right;color:#999;font-size:13px;}
msg_box{float:left;width:100%;padding:10px;}
order_price{float:left;width:100%;height:40px;line-height:40px;font-size:30px;font-weight:bold;margin-top:10px;}
order_price hh{float:left;width:50%}
order_price c{float:left;font-size:13px;font-weight:normal;line-height:55px;}
order_price text{margin-left:5px;float:left;}
order_price submit_bt{float:left;height:50px;margin-right:10px;line-height:50px;background:#00c8dc;color:#fff;padding-left:50px;padding-right:50px;border-radius:5px;font-size:17px;font-weight:normal;}
order_price .gay{background:#999}
order_price .red{color:crimson;}
style>


<msg_win>
msg_win>
<bg>bg>jiesuan>

main>

<script>
window.pros={"\u6df7\u6c8c\u6c34\u997a":{"item_130":{"id":"130","title":"\u7c89\u6761","img":"https:\/\/img1.zjhn.top\/1\/22_240.jpg","price":"6.80","total":"-1","c":"\u6df7\u6c8c\u6c34\u997a","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_20":{"id":"20","title":"\u6c34\u997a","img":"https:\/\/img2.zjhn.top\/1\/59_240.jpg","price":"8.80","total":"-1","c":"\u6df7\u6c8c\u6c34\u997a","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_6":{"id":"6","title":"\u65b0\u5efa\u5546\u54c1","img":"https:\/\/img1.zjhn.top\/1\/53_240.jpg","price":"25.80","total":"-1","c":"\u6df7\u6c8c\u6c34\u997a","data_id":"0","is_new":"0","is_hot":"1","sku":null,"isbn":null,"daiwei":null},"item_5":{"id":"5","title":"\u65b0\u5efa\u5546\u54c1","img":"https:\/\/img1.zjhn.top\/1\/52_240.jpg","price":"22.25","total":"-1","c":"\u6df7\u6c8c\u6c34\u997a","data_id":"0","is_new":"0","is_hot":"1","sku":null,"isbn":null,"daiwei":null}},"\u5c0f\u9f99\u867e":{"item_129":{"id":"129","title":"\u9ebb\u8fa3\u5c0f\u9f99\u867e","img":"https:\/\/img1.zjhn.top\/1\/31_240.jpg","price":"22.00","total":"-1","c":"\u5c0f\u9f99\u867e","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null}},"\u7279\u4ea7":{"item_128":{"id":"128","title":"\u9e21\u7fc5","img":"https:\/\/img1.zjhn.top\/1\/21_240.jpg","price":"18.80","total":"-1","c":"\u7279\u4ea7","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_127":{"id":"127","title":"\u82b1\u83dc","img":"https:\/\/img1.zjhn.top\/1\/32_240.jpg","price":"6.80","total":"-1","c":"\u7279\u4ea7","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null}},"\u5305\u5b50":{"item_26":{"id":"26","title":"\u65b0\u5546\u54c1","img":"https:\/\/img2.zjhn.top\/1\/55_240.jpg","price":"2.55","total":"-1","c":"\u5305\u5b50","data_id":"1","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_25":{"id":"25","title":"\u7cbd\u5b50","img":"https:\/\/img2.zjhn.top\/1\/29_240.jpg","price":"3.50","total":"-1","c":"\u5305\u5b50","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_24":{"id":"24","title":"\u65b0\u5546\u54c1","img":"https:\/\/img1.zjhn.top\/1\/61_240.jpg","price":"2.00","total":"-1","c":"\u5305\u5b50","data_id":"0","is_new":"1","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_23":{"id":"23","title":"\u65b0\u5546\u54c1","img":"https:\/\/img1.zjhn.top\/1\/33_240.jpg","price":"3.00","total":"-1","c":"\u5305\u5b50","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null},"item_22":{"id":"22","title":"\u65b0\u5546\u54c1","img":"https:\/\/img2.zjhn.top\/1\/57_240.jpg","price":"2.50","total":"-1","c":"\u5305\u5b50","data_id":"0","is_new":"0","is_hot":"0","sku":null,"isbn":null,"daiwei":null}},"\u897f\u70b9":{"item_7":{"id":"7","title":"\u65b0\u5efa\u5546\u54c1","img":"https:\/\/img2.zjhn.top\/1\/58_240.jpg","price":"2.50","total":"-1","c":"\u897f\u70b9","data_id":"0","is_new":"1","is_hot":"0","sku":null,"isbn":null,"daiwei":null}}};
window.pro_data={"item_1":{"id":"1","data":{"\u53e3\u5473":{"min":"1","max":"1","item":{"item_8806263":{"title":"\u52a0\u8fa3","price":"0","dft":"1"},"item_1647323071055":{"title":"\u4e0d\u52a0\u8fa3","price":"0","dft":0}}},"\u5c5e\u6027":{"min":"1","max":"1","item":{"item_8806309":{"title":"\u5927\u53f7","price":"1","dft":0},"item_1647323090659":{"title":"\u4e2d\u53f7","price":"0","dft":"1"},"item_1647323098504":{"title":"\u5c0f\u53f7","price":"-1","dft":0}}}}},"item_3":{"id":"3","data":{"\u53e3\u5473":{"min":"1","max":"1","item":{"item_8925801":{"title":"\u52a0\u8fa3","price":0},"item_8925811":{"title":"\u4e0d\u52a0\u8fa3","price":0,"dft":1},"item_8925820":{"title":"\u5fae\u8fa3","price":0}}}}},"item_4":{"id":"4","data":{"\u5c3a\u5bf8":{"max":"1","min":"1","item":{"item_1639988477841":{"title":"\u4e2d\u85af","price":"0","dft":"1"},"item_1639988491429":{"title":"\u5927\u85af","price":"2","dft":"0"},"item_1639988499581":{"title":"\u5c0f\u85af","price":"-1","dft":0}}},"\u53e3\u5473":{"max":"1","min":"1","item":{"item_1645503397028":{"title":"\u52a0\u8fa3","price":"0","dft":"1"},"item_1645503405406":{"title":"\u4e0d\u52a0\u8fa3","price":"1","dft":"0"},"item_1645503412932":{"title":"\u975e\u5e38\u8fa3","price":"-1","dft":0}}}}}};
window.cart={};
window.jp_ac='search';//键盘默认输入
window.cart_data={pay:'weixin',total:0,cashi:0,lq:0,qr:'',zk:0,member:'',desk_id:0,desk_name:''};//订单信息 lq零钱 qr二维码信息 member会员信息
window.cache_cart_num=0;//是否存在暂存订单
window.input_key='';
window.need_desk='true';

$(document).ready(function(){
pro_load_all();
var cart_d=d('cart');//缓存的订单数据
if(cart_d){
window.cart=json(cart_d,1);
format_cart();
}

how_pay_bt($('#use_'+window.cart_data.pay));//购买按钮
has_cache();//是否存在咱存订单
});

function pro_load_all(ac){//全部商品
if(!window.pros){msg('没有找到商品');return;}
var html='';
$.each(window.pros,function(i,n){
html+=pro_load(i);
});
$('pro_list').scrollTop(0)
$('pro_list').html(html);
if(ac){format_cart();}
}

function load_c(o){//加载商品分类
var c=o.attr('c');
var html=pro_load(c);
$('pro_list').scrollTop(0)
$('pro_list').html(html);
format_cart();
o.parent().find('a').removeClass('select');
o.addClass('select')
}

function pro_load(c){//加载商品
var html='';
var pro=window.pros[c];
$.each(pro,function(i,n){
var h=pro_min_html(i,n);//var h=pro_min_html(i,n);
html+=h;
});

return html;
}

function search_it(o){//搜索关键词
var val=o.val();var html='';var h='';
if(!val){pro_load_all();return;}
$.each(window.pros,function(k,pro){
$.each(pro,function(i,n){
var title=n.title;
if(title.indexOf(val)!=-1){
html+=pro_min_html(i,n);
}

})
})
$('pro_list').scrollTop(0)
$('pro_list').html(html);
}

function pro_item_html(i,n){var html='';
html+='+n.id+'">+n.img+') no-repeat center;background-size:cover;">';
html+='';
if(n.c=='tc'){html+='[套餐]';}
html+=n.title+'';
html+=''+(n.c=='tc'?'套餐':n.c)+'';

html+=''+n.price+'';
html+='';
if(n.data_id>0){
html+='+(n.sku?'sku_'+n.sku:'')+' '+(n.isbn?'sku_'+n.isbn:'')+'" x="select" οnclick="select_data($(this))" i="'+i+'" c="'+n.c+'">选规格';
}else{
html+='+(n.sku?'sku_'+n.sku:'')+' '+(n.isbn?'sku_'+n.isbn:'')+'" x="bt" οnclick="cart_add($(this))" i="'+i+'" c="'+n.c+'">';  
}
html+='';
html+='';
html+='';
return html;
}

function pro_min_html(i,n){var html='';
html+='+n.id+'">+n.img+') no-repeat center;background-size:cover;">';
html+='';
if(n.c=='tc'){html+='[套餐]';}
html+=n.title+'';
html+=''+(n.c=='tc'?'套餐':n.c)+'';

html+=''+n.price+'';
html+='';
if(n.data_id>0){
html+='+(n.sku?'sku_'+n.sku:'')+' '+(n.isbn?'sku_'+n.isbn:'')+'" x="select" οnclick="select_data($(this))" i="'+i+'" c="'+n.c+'">选规格';
}else{
html+='+(n.sku?'sku_'+n.sku:'')+' '+(n.isbn?'sku_'+n.isbn:'')+'" x="bt" οnclick="cart_add($(this))" i="'+i+'" c="'+n.c+'">';  
}
html+='';
html+='';
html+='';
return html;
}




function cart_add(o){//添加商品到购物车
var c=o.attr('c');
var i=o.attr('i');
var pro=window.pros[c][i];//商品
console.log(pro);
if(!window.cart[c]){window.cart[c]={}}
if(!window.cart[c]['item_'+pro.id]){window.cart[c]['item_'+pro.id]={id:pro.id,price:pro.pro_price,buy:0,c:'pro'};}
var cc='pro';
if(c=='tc'){cc='tc';}//套餐
var price=parseFloat(pro.price);
window.cart[c]['item_'+pro.id]['c']=cc;
window.cart[c]['item_'+pro.id]['price']=price.toFixed(2);//商品价格
window.cart[c]['item_'+pro.id]['buy']++;
var total=window.cart[c]['item_'+pro.id]['buy']*price;
window.cart[c]['item_'+pro.id]['total']=total.toFixed(2);
//保存购物车到缓存
format_cart();//更新数据
}


function data_cart_add(o){//加入购物车
var c=o.attr('c');
var i=o.attr('i');
var pro=window.pros[c][i];//商品
if(!window.cart[c]){window.cart[c]={}}
var pro_price=parseFloat(pro.price);
if(!window.cart[c]['item_'+pro.id]){window.cart[c]['item_'+pro.id]={id:pro.id,price:pro_price.toFixed(2),buy:0,c:'select',item:{}};
    
}
//查找数据
var price=pro_price;var info={};var select={};var key='';
$('#win_select_data data_item').each(function(){
var is_select=$(this).find('item').hasClass('select');
if(is_select){
var cc=$(this).attr('c');
var ii=$(this).attr('i');
var val=$(this).attr('val');
key=key+ii.replace('item_','');//id链接
if(!info[cc]){info[cc]={};}
if(!select[cc]){select[cc]={};}
select[cc][ii]=1;
info[cc][ii]=val;
var p=parseFloat($(this).attr('price'));if(!p){p=0;}//价格
price+=p;//对于点餐,则价格为增加
}

});

if(!window.cart[c]['item_'+pro.id]['item'][key]){
window.cart[c]['item_'+pro.id]['item'][key]={buy:0,pro_price:pro_price.toFixed(2),info:info,select:select,price:price.toFixed(2)};}

window.cart[c]['item_'+pro.id]['item'][key]['buy']++;
var cart_total=window.cart[c]['item_'+pro.id]['item'][key]['buy']*window.cart[c]['item_'+pro.id]['item'][key]['price'];
window.cart[c]['item_'+pro.id]['item'][key]['total']=cart_total.toFixed(2);

var cart_temp=format_data_cart(window.cart[c]['item_'+pro.id]);//对总统进行分析
window.cart[c]['item_'+pro.id]=cart_temp;
console.log(window.cart);
format_cart();
}

function format_data_cart(cart){//对购物车进行分析
if(!cart){return;}
if(!cart['item']){return;}
var total=0;var buy=0;
$.each(cart['item'],function(i,n){
if(n.buy==0){//没有数据
delete cart['item'][i];//删除
}else{
var price=parseFloat(n.price);
var num=parseInt(n.buy);
total+=price*num;
buy+=num;
}
});

cart['buy']=buy;
cart['total']=total.toFixed(2);
return cart;
}


function cart_num_add(o){//购物车数据增加减少
var c=o.attr('c');
var i=o.attr('i');
var val=parseInt(o.attr('val'));if(!val){val=1;}
var cart_temp=window.cart[c][i];
var price=parseFloat(cart_temp.price);
var buy=parseInt(cart_temp.buy);
var total=0;
buy+=val;
if(buy==0){//是否删除商品
if(!confirm("是否删除购物车商品?")){return;}
}
cart_temp['buy']=buy;
total=buy*price;
cart_temp['total']=total.toFixed(2);
window.cart[c][i]=cart_temp;
format_cart();
}

function data_cart_num(o){//有参数的购物数据更新
var c=o.attr('c');
var i=o.attr('i');
var val=parseInt(o.attr('val'));if(!val){val=1;}
var j=o.attr('j');
var cart_temp=window.cart[c][i]['item'][j];
var price=parseFloat(cart_temp.price);
var buy=parseInt(cart_temp.buy);
var total=0;
buy+=val;
if(buy==0){//是否删除商品
if(!confirm("是否删除购物车商品?")){return;}
}
cart_temp['buy']=buy;
total=buy*price;
cart_temp['total']=total.toFixed(2);
window.cart[c][i]['item'][j]=cart_temp;
var tt=format_data_cart(window.cart[c][i]);
window.cart[c][i]=tt;
format_cart();
}

function format_cart(){
if(!window.cart){return;}
var html='';var total=0;var cart_pro_num=0;
$.each(window.cart,function(c,m){
var c_text=c;
if(c=='tc'){c_text='套餐';}
html+='+c+'">'+c_text+'';
$.each(m,function(i,n){
var pro_c_list=window.pros[c];
if(!pro_c_list || Object.keys(pro_c_list).length==0){//不存在商品分类
delete window.cart[c];//删除订单商品分类

}else{//存在商品分类
var pro=window.pros[c]['item_'+n.id];//获取商品

if(!pro){n.buy=0;}//没有商品 则删除商品
if(n.buy<=0){
$('#pro_'+n.id+' buy_num').html('');
$('#pro_'+n.id+' buy_num').hide();
delete(window.cart[c][i]);//删除数据
//是否删除整体数据
if(Object.keys(window.cart[c]).length==0){
delete window.cart[c];
}

}else{//存在数据

$('#pro_'+n.id+' buy_num').html(n.buy);$('#pro_'+n.id+' buy_num').show();

console.log(pro);
if(n.c=='select'){//如果存在数据
if(n.item){
$.each(n.item,function(j,k){
var info='';
$.each(k.info,function(x,y){
info+=''+x+':';
$.each(y,function(m,h){
info+=h+' ';
});
})

total+=parseFloat(k.total);
cart_pro_num+=parseInt(k.buy);

html+='+pro.img+') no-repeat center;background-size:cover;">';
html+=''+pro.title+'';
html+=''+info+'';
html+=''+k.total+'';
html+='';
html+='+c+'" i="'+i+'" j="'+j+'" val="1">';
html+='+k.buy+'">';
html+='+c+'" i="'+i+'" j="'+j+'" val="-1">';
html+='';
html+='';
    

})

}
}else{//不是选择性订单
//订单进行创建
total+=parseFloat(n.total);
cart_pro_num+=parseInt(n.buy);

html+='+pro.img+') no-repeat center;background-size:cover;">';
html+=''+(pro.c=='tc'?'[套餐]':'')+pro.title+'';
html+=''+n.total+'';
html+='';
html+='+c+'" i="'+i+'" val="1">';
html+='+n.buy+'">';
html+='+c+'" i="'+i+'" val="-1">';
html+='';
html+='';
}
}

}//pro_c
})


});
if(!html){
html='您的购物车中还没有商品';
}
jiesuan_clean();
$('cart_box').html(html);
total=total.toFixed(2);
$('total').html(total);
$('hui x').html(cart_pro_num);
window.cart_data.total=total;//总金额
$('#need_pay text,#lingqian text').html('0.00');
window.cart_total=total;//总金额
window.cart_num=cart_pro_num;//商品数量
d('cart',json(window.cart));//缓存

//如果存在餐厅
if(window.cart_data['desk_id']>0){
$('desk x').html(window.cart_data['desk_name']);
}else{
$('desk x').html('');
}

}



function cache_cart(o){//暂存订单,对现有订单进行缓存,老订单出现
var cache=d('cart_cache');
var l=Object.keys(window.cart).length;
if(cache){//存在缓存
if(l>0){//存在购物车
//if(!confirm("是否切换购物车数据?")){return;}
d('cart_cache',json(window.cart));has_cache();
}
window.cart=json(cache,1);
$('buy_num').html('');$('buy_num').hide();
format_cart();

}else{//不存在缓存,则查找商品数据
if(!window.cart){msg('您的购物车中没有商品');return;}
if(l==0){msg('您的购物车中没有商品');return;}
d('cart_cache',json(window.cart));
msg('缓存成功');
has_cache();
}}

function has_cache(){//检查是否存在暂存订单
var cache=d('cart_cache');
if(cache){window.cache_cart_num=1;
$('.cart_cache').addClass('bt_red');

}else{
window.cache_cart_num=0;
$('.cart_cache').removeClass('bt_red');
}
}

function d(key,val){//缓存数据
if(val){localStorage.setItem(key,val);
}else{return localStorage.getItem(key);
}
}


function select_data(o){//选择参数
var id=o.attr('i');
var c=o.attr('c');
var pro=window.pros[c][id];
var the_pro_data=window.pro_data['item_'+pro.data_id];
if(!the_pro_data){msg('没有找到参数信息,如有问题,请联系管理员');return;}
var html='';
//对参数进行设置
$.each(the_pro_data.data,function(j,k){
html+=''+j+'';
$.each(k.item,function(i,n){

html+='+pro.data_id+'" c="'+j+'" price="'+n.price+'" i="'+i+'" dft="'+n.dft+'" val="'+n.title+'">';
html+='+n.price+'">'+n.title+(n.price!=0?'('+n.price+')':'')+'';
html+='';

})
html+='';
})

html+='商品单价'+pro.price+'';
html+='+c+'" i="'+id+'">确定';
html+='';
window.need_select_data_pro=pro;
win({id:'select_data',html:html,width:600,title:'选择商品属性'});
//alert(json(the_pro_data));
//必选项初始化
$('#win_select_data data_item').each(function(){
var dft=$(this).attr('dft');
if(dft==1){
    select_this_data($(this))
}
});


}

function select_this_data(o){//选择这个参数
var c=o.attr('c');
var i=o.attr('i');
var d=o.attr('d');
var data=window.pro_data[d]['data'][c];
var max=parseInt(data.max);if(!max){max=1;}
var min=parseInt(data.min);if(!min){min=1;}//选择最多很最少项目
var item=data['item'][i];//项目
var price=parseFloat(item.price);
var is_select_num=o.parent().find('.select').length;//已经选择的项目数量
var is_select=o.find('item').hasClass('select');//是否已经选择

if(is_select){//已经选择了
if(is_select_num<=min && min>0){//如果已经选择项目,必选项少于了,则不被取消
return;
}else{//取消选择
o.find('item').removeClass('select');
}

}else{//未选择项目

if(is_select_num==max && max>0){//如果再选择超过数量,则无法在选择
if(max==1){//必选选择一项
o.parent().find('item').removeClass('select');
o.find('item').addClass('select');
}else{

msg('超过选择项目');return;}

}else{
o.find('item').addClass('select');
}

}
//计算所需的价格
data_pro_price();
}

function data_pro_price(){
var price=parseFloat(window.need_select_data_pro.price);

$('#win_select_data item').each(function(){
var is_select=$(this).hasClass('select');
if(is_select){
var p=parseFloat($(this).attr('price'));
price+=p;
}
});

if(price<=0){price=0;}
$('#win_select_data price').html(price.toFixed(2));


}

function clean_cart(ac){
if(ac){if(!confirm("是否情况购物车?")){return;}}
window.cart={}
format_cart();
$('buy_num').hide();
}

//$('#input').focus();
window.key_down=(new Date()).getTime();
window.is_jiesuan=0;//时间开启结算

$(document).keypress(function(e){//输入文字
if(window.is_jiesuan==1){//如果已经打开结算页面
if(e.keyCode==13 || e.which==13){
if(window.pay_successful==1){//点击enter按钮,如果支付成功,则进行关闭订单
order_ok();
}
}

return;}//结算后,按键将无反应
var key_start=(new Date()).getTime();
var key_time=key_start-window.key_down;
if(key_time>=30){//由按键
console.log('时间',key_time,window.key_down,key_start);
if(e.keyCode>=48 && e.keyCode<=57){//数字
var num=e.keyCode-48;
num_click({val:num.toString()});
}else{//其他按键
if(e.keyCode==46 || e.which==46){num_click({val:'.'});}//按键.

if(e.keyCode==13 || e.which==13){//打开结算页面
//结算
keydown($('.js_bt text'));
jiesuan();
}
console.log(e.keyCode);
}
}
window.key_down=(new Date()).getTime();
});

$(document).keydown(function(e){//按ctrl键
if(e.keyCode==17){window.is_ctrl=1;}
if(window.is_ctrl==1){
if(e.keyCode==88){scan_win_show();}//ctrl+x 打开核销窗口
if(e.keyCode==90){clean_cart(1);}//ctrl+z
if(e.keyCode==67){left_win({title:'订单管理',url:'./order.php?t=1647353615',width:'50vw',bt:'待支付已完成已付款'})}//ctrl+c
}
});



$(document).keyup(function(e){//输入文字
window.is_ctrl=0;
if(window.is_jiesuan==1){//如果结算中,按esc按钮
if(e.keyCode==27 || e.which==27){//按键esc
if(window.pay_successful==1){order_ok();return;}//支付成功
//关闭窗口
js_close();return;
}
}

if(!window.key_down){key_time=0;}else{
var key_start=(new Date()).getTime();
var key_time=key_start-window.key_down;
}
if(key_time>=30){//由按键
console.log('时间',key_time,window.key_down,key_start);
if(e.keyCode==8 || e.which==8){//退格
num_click({val:'del'});
keydown($('#del_bt'));
}
}else{//如果时间非常短
console.log(key_time,'aaa',e.keyCode,window.input_key);
if(e.keyCode==13 || e.which==13){
//输入enter后,扫描输入完成
if(window.is_jiesuan==1){//结算 扫描支付
var val=$('#input').val();console.log('支付',val,window.input_key);
if(window.input_key){pay(window.input_key);window.input_key='';return;}//扫描支付
}
if(window.is_wait_scan==1){//如果扫描 核销
console.log('核销码',window.input_key);
order_hexiao(window.input_key);
window.input_key='';return;
}//扫描核销订单


if(window.scan_input==1){//扫码输入到输入框
if(window.input_key){
window.scan_obj.val(window.input_key);
window.scan_input=0;
window.input_key='';return;
}
}


//最后搜索
if(window.input_key){//如果有关键词 则进行点击
var obj=$('.sku_'+window.input_key);
if(!obj){obj=$('.isbn_'+window.input_key);}
var key=window.input_key;window.input_key='';
if(!obj.length){msg('没有找到商品');return;}
var x=obj.attr('x');
if(x=='select'){select_data(obj);}else{cart_add(obj);}//进行点击
}

/**
if(window.is_jiesuan==1){//结算
var val=$('#input').val();console.log('支付',val,window.input_key);
if(window.input_key){pay(window.input_key);window.input_key='';}//扫描支付
}else{
if(window.is_wait_scan==1){//如果扫描 核销
console.log('核销码',window.input_key);
order_hexiao(window.input_key);

}else{ 
 
//搜索
if(window.input_key){//如果有关键词 则进行点击
var obj=$('.sku_'+window.input_key);
if(!obj){obj=$('.isbn_'+window.input_key);}
var key=window.input_key;window.input_key='';
if(!obj.length){msg('没有找到商品');return;}
var x=obj.attr('x');
if(x=='select'){select_data(obj);}else{cart_add(obj);}//进行点击
}
}//搜索
}
*/

window.input_key='';
}else{
window.input_key+=String.fromCharCode(e.keyCode);

}
}
window.key_down=(new Date()).getTime();
});


function sacn_input_creat(o,ac){
if(ac!=1){window.scan_obj=null;window.scan_input=0;return;}//扫描输入关闭
window.scan_obj=o;window.scan_input=1;//开启扫描输入数据
}



function keydown(o){//按键效果
o.addClass('keydown');
setTimeout(function(){o.removeClass('keydown');},100);
}




function num_click(o){if(!o){return;}
var from=0;//从按键
var payment=0;//选择支付方式 
var val=o.val;val=val.toString();
if(val.length>30){val='';}
if(!val){val=o.attr('val');if(val){keydown(o);from=1;}}
if(!val){return;}

//console.log(val);
var this_val=parseFloat($('#'+window.jp_ac+' text').html());
if(this_val==0){this_val='';} 
if(window.need_xs==1){this_val+='.';}
window.need_xs=0;
switch(val){
case '1':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '2':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '3':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '4':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '5':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '6':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '7':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '8':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '9':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case '0':this_val+=val;payment=1;if(from==0){keydown($('#keynum_'+val));}break;
case 'db0':this_val+='00';payment=1;break;
case '100':this_val=val;payment=1;break;
case '20':this_val=val;payment=1;break;
case '50':this_val=val;payment=1;break;
case '10':this_val=val;payment=1;break;
case '.':
if(from==0){keydown($('#keynum_'));}
var num=parseFloat(this_val);
if(num%1 === 0) {// num是整数
window.need_xs=1;

}else{return;}
break;
case 'ac':this_val=0;break;
case 'del':
this_val=this_val.toString();
this_val=this_val.slice(0,-1);
break;
case 'cashi'://支付方式
how_pay_bt(o);
window.cart_data.pay='cashi';
break;
case 'weixin'://微信
how_pay_bt(o);
window.cart_data.pay='weixin';
break;

case 'alipay'://微信
how_pay_bt(o);
window.cart_data.pay='alipay';
break;

case 'member'://打开会员页面

break;
case 'zk'://打开折扣选择页面

break;
case 'hx'://核销
scan_win_show();
break;

}

this_val=parseFloat(this_val);
if(!this_val){this_val=0;}


$('#'+window.jp_ac+' text').html(this_val.toFixed(2));
if(window.jp_ac=='need_pay'){//需要找零
var total=parseFloat(window.cart_total);if(!total){total=0;}
var money=parseFloat(this_val);
if(money==0){payment=0;}
var lq=money-total;//零钱
if(lq<=0){lq=0;}
window.cart_data.cashi=money;
window.cart_data.lq=lq;
$('#lingqian text').html(lq.toFixed(2));
}

if(payment==1){
window.cart_data.pay='cashi';//现金支付优先
how_pay_bt($('#use_cashi'))
}


}


function scan_win_show(){//打开扫描窗口
$('scan_win').fadeIn(300);
window.scan_time=120;window.is_wait_scan=1;
window.scan_win_time=setInterval(function(){
window.scan_time--;
if(window.scan_time==0){scan_win_close();}
$('scan_win text').html('顾客扫描核销码 请稍后('+window.scan_time+')');},1000);
}
function scan_win_close(){
$('scan_win').fadeOut(300);
window.is_wait_scan=0;
clearInterval(window.scan_win_time);
}

function order_hexiao(code){//订单核销
if(!code){msg('请输入核销码');return;}
$.post('server.php',{ac:'hexiao',code:code},function(res){
var d=json(res,1);
if(d.err=='ok'){msg('核销成功');scan_win_close();}else{msg(d.err);}
});

}



function how_pay_bt(o){//按键选择
$('how_pay text').removeClass('select');
o.addClass('select');
}


function jiesuan_clean(){///取消结算
window.is_jiesuan=0;
window.cart_data.cashi=0;
window.cart_data.qr='';
window.cart_data.lq=0;
window.cart_data.zk=0;
clearInterval(window.check_order_time);
window.pay_time=0;
window.pay_state='';
window.input_key='';
window.jp_ac='search';
$('.js_bt').removeClass('js_select');
}


function jiesuan(o){//结算
console.log(window.cart_data,window.cart);
var cart_pro_num=Object.keys(window.cart).length;
if(cart_pro_num==0){msg('您没有添加商品,请先添加商品继续');return;}
var total=parseFloat(window.cart_data.total);
if(total==0){//购物车金额为空
if(!confirm("购物车金额为0.00元,是否继续?")){return;}
}
if(window.need_desk=='true' && !window.cart_data.desk_id){
msg('您必须选择一个餐桌');
select_desk();return;
}
if(window.jp_ac=='search'){window.jp_ac='need_pay';
$('.js_bt').addClass('js_select');
return;}//可以输入零钱
//提交数据
$.post('./server.php',{ac:'order_submit',cart:JSON.stringify(window.cart),data:JSON.stringify(window.cart_data)},function(res){
var d=json(res,1);
if(d.err=='ok'){//打开结算页面
window.is_jiesuan=1;
window.need_pay=parseFloat(d.need_pay);
window.order_id=d.id;
window.pay_state=d.state;//订单状态
window.pay_successful=0;
window.key_down=0;
window.input_key='';
//打开结算页面
$('msg_win').html(d.html);
$('msg_win,bg').show();
$('msg_win,bg').click(function(){
$('#input').focus();
});

if(d.state=='use_cashi'){//仅适用现金

$('#pay_info').html('支付成功');
$('#order_ok_bt').html('支付完成');
$('#js_close').remove();

}else{
$('#input').focus();
$('#input').val('');
}
//win({title:'支付',id:'need_pay',html:d.html});
}else{
if(d.err=='no_js_time'){js_time_show();msg('您输入您结算的初始金额');return;}
msg(d.err);}

});

}

function js_close(){//关闭结算页面
$('msg_win').html('');
$('msg_win,bg').hide();
window.is_jiesuan=0;
$('#input').val('');
$('#input').blur();
jiesuan_clean();
format_cart();
window.pay_successful=0;
}

function pay(code){//支付
if(!window.order_id){msg('抱歉,订单数据错误');return;}
if(window.need_pay==0 || !window.need_pay){msg('您的订单无需再支付');return;}

$.post('./server.php',{id:window.order_id,code:code,ac:'pay'},function(res){
var d=json(res,1);
if(d.err=='ok'){
window.pay_time=(new Date()).getTime();//支付开始时间
window.check_order_time=setInterval('check_order();',1000);

}else{msg(d.err)}

});

}


function check_order(){//检查订单是否已经支付
if(!window.order_id){return;}
var time=(new Date()).getTime();
var sec=60-Math.ceil((time-window.pay_time)/1000);
if(!sec || sec<0){sec=0;}
if(sec==0){
    clearInterval(window.check_order_time);
     $('#pay_info').html('支付超时');
    if(confirm("支付超时,是否关闭窗口?")){//关闭窗口
    window.order_id=0;
   // clean_cart();
    js_close();
    }
    return;
}//支付超时
$('#pay_info').html('支付扫码成功 剩余'+sec+'秒');

$.post('server.php',{ac:'order_is_pay',id:window.order_id},function(res){
    var d=json(res,1);
    if(d.err=='ok'){
    if(d.pay_state=='ok' || d.pay_state=='notpay'){//停止轮训
clearInterval(window.check_order_time);
window.pay_time=0;
    if(d.pay_state=='ok'){
        //msg('支付成功');
        if(d.how_pay=='weixin'){audio();}//微信支付成功
        window.pay_successful=1;
        $('#pay_info').html('支付成功');
        $('#order_ok_bt').html('支付完成');
        $('#js_close').remove();
    }
    }else{
        //继续进行轮训
        
    }
    
    }else{
    msg(d.err);
    }
});
}


function order_ok(o){//订单完成
if(!window.order_id){
var id=o.attr('i');if(!id){    
msg('没有找到订单');return;}else{window.order_id=id;}}
$.post('server.php',{ac:'order_ok',id:window.order_id},function(res){
    var d=json(res,1);
    if(d.err=='ok'){
    window.cart_data['desk_id']=0;
    window.cart_data['desk_name']='';
    window.order_id=0;
    clean_cart();
    js_close();
    format_cart();
    }else{msg(d.err);}
    
});
}


function order_finish(o){
var id=o.attr('i');if(!id){msg('请指定订单');return;}
if(!confirm("是否将订单标记为完成状态,此操作无法撤回,是否继续?")){return;}
$.post('server.php',{ac:'order_finish',id:id},function(res){
    var d=json(res,1);
    if(d.err=='ok'){
    left_flash();
    msg('订单成功标记为完成状态');
    }else{msg(d.err);}
    
})
}


function audio(){
var h='';
$('audio_obj').html(h);
}


function msg(text){
alert(text)
}

function loginout(){//登出
if(!confirm("是否退出登录?")){return;}
$.post('server.php',{ac:'loginout'},function(res){
var d=json(res,1);
if(d.err=='ok'){
 clean_cart();
 js_close();
location.href="login.php"}
});

}

//left_win({title:'',width:'50vw',bt:'aaabbb'})
function left_win(d){
if(!d.title){d.title='新窗口';}
if(d.width){$('left_win win_box').css('width',d.width);}    
$('left_win left_win_handle text').html(d.title);
$('left_win left_win_handle bts').html('');
if(d.bt){$('left_win left_win_handle bts').html(d.bt);}//按钮
$('left_win win_box left_main').html('')
if(d.html){$('left_win win_box left_main').html(d.html);}
if(d.url){$('left_win win_box left_main').load(d.url);window.left_url=d.url;}
$('left_win').addClass('left_show');
$('bg').show();
setTimeout(function(){$('left_win win_box').css('left','50px');},100);
}

function left_flash(){if(window.left_url){$('left_win win_box left_main').load(window.left_url);}}


function left_close(){
$('left_win win_box').css('left','-100vw');
setTimeout(function(){$('left_win').removeClass('left_show');},100);
$('left_win win_box left_main').html('');$('left_win left_win_handle bts').html('');
$('bg').hide();
}

function left_go(o){
var url=o.attr('url');
if(!url){return;}
window.left_url=url;
left_flash();
}

function no_login(){location.href="login.php"}

function select_desk(o){//查看选择餐桌
left_win({id:'select_desk',title:'查看和选择餐桌',url:'./desk_list.php?t='+(new Date()).getTime(),width:'70vw'});
}

function search_open(o){
var c=o.attr('c');
if(!c){$('search_box').css('right','0px');o.attr('c','show');}else{
$('search_box').css('right','-300px');o.attr('c','');pro_load_all();
$('search_box input').val('');
}
}

function js_time_show(){
$('js_time_win').fadeIn(200);
$('js_time_main').load('js_time.php');
}


function check_last_order(){//查找app订单
$.post('server.php',{ac:'get_app_order'},function(res){
    var d=json(res,1);
    if(d.err=='ok'){
    if(d.num>0){
    $('#app_order_num').html(d.num);
    $('#app_order_num').show();}else{
    $('#app_order_num').hide();
    }
    }else{
    $('#app_order_num').hide();
    }
    setTimeout('check_last_order()',15000);
});
}

function check_time_num(){
$.post('server.php',{ac:'check_time_num'},function(res){
    var d=json(res,1);
    if(d.err=='ok'){if(d.num>0){
    $('#time_num').html(d.num);
    $('#time_num').show();}else{$('#time_num').hide();}
    }else{
    $('#time_num').hide();
    }
    setTimeout('check_time_num()',60000);
});
}



check_last_order();check_time_num();

script>
body>
html>

你可能感兴趣的:(收银系统,微信小程序,javascript,php)