forked from legendtang/ezsoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wtf.php
204 lines (202 loc) · 6.21 KB
/
wtf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
//本网站是为了模拟用户点餐,用于讲电话短信点餐用户统一归入网站调度管理
require_once './php/linkDB.php';
session_start();
$temp_order = mysql_query("SELECT * FROM temp_order ORDER BY ID DESC LIMIT 1");
if($last_order = mysql_fetch_array($temp_order)){
$last_id = $last_order["ID"];
}else{
$last_id = 0;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WT快捷模拟下单</title>
<script src="./js/jquery.js" type="text/javascript"></script>
<script src="./js/bootstrap.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css"/>
<style>
body *{
font-family: "Microsoft Yahei UI Light", "Microsoft JhengHei", STheiti, WenQuanYi Micro Hei, helvetica, arial, sans-serif;
}
.food{
float:left;
padding-left: 10px;
width: 215px !important;
height: 50px;
font: 18px/50px "Microsoft Yahei UI Light", "Microsoft JhengHei", STheiti, WenQuanYi Micro Hei !important;
cursor:pointer;
}
.order{
cursor:pointer;
}
.food:hover,.order:hover{
background:#c0c0c0;
}
p{
float:left;
clear:both;
width:100%;
font: 36px/50px "Microsoft Yahei UI Light", "Microsoft JhengHei", STheiti, WenQuanYi Micro Hei !important;
border-bottom:1px solid #c0c0c0;
}
#infoBox{
position:fixed;
bottom:0;
background:#c0c0c0;
padding:20px;
width:100%;
}
#sendInfo{
float:left;
width:50%;
}
#orderList{
float:left;
margin-left:5%;
width:40%;
height:100px;
background:#fff;
overflow:auto;
}
</style>
</head>
<body>
<div style="margin:0 5%;margin-bottom:200px;">
<h1>模拟用户下单(附中) 当前订单号:<?php echo ($last_id+1);?></h1>
<?php
echo '<ul class="nav nav-tabs">';
$sql = mysql_query("SELECT * FROM restaurant ORDER BY ID");
while($row = mysql_fetch_array($sql)){
$shop_id = $row["ID"];
$shop_name = $row["name"];
echo '<li><a href="#shop'.$shop_id.'" data-toggle="tab">'.$shop_name.'</a></li>';
}
echo '</ul><div class="tab-content">';
$sql_fuck = mysql_query("SELECT * FROM restaurant ORDER BY ID");
while($row = mysql_fetch_array($sql_fuck)){
$shop_id = $row["ID"];
$shop_type = explode(";",$row["type"]);
echo '<div class="tab-pane" id="shop'.$shop_id.'">';
$product = mysql_query("SELECT * FROM product WHERE shop_id='$shop_id' ORDER BY type");
$type_before = '';
while($row = mysql_fetch_array($product)){
$food_id = $row["ID"];
$food_name = $row["name"];
$food_type = $row["type"];
if(trim($food_type) != trim($type_before)){
echo '<p>'.$shop_type[$food_type].'</p>';
$type_before = $food_type;
}
echo '<div class="food" id="food'.$food_id.'" name="'.$food_id.'">'.$food_name.'</div>';
}
echo '</div>';
}
echo '</div>';
?>
<div style="clear:both;"></div>
</div>
<div id="infoBox">
<div id="sendInfo">
<select id="sendTime">
<?php
date_default_timezone_set("Asia/Shanghai");
$hour = Date("G");
$min = intval(Date("i"))>30?1:0;
$timeSection = $hour*2+$min;
$timeArray = array('<option value = "21">10:30</option>','<option value = "22">11:00</option>','<option value = "23">11:30</option>','<option value = "24">12:00</option>','<option value = "25">12:30</option>','<option value = "26">13:00</option>','<option value = "27">13:30</option>','<option value = "28">14:00</option>','<option value = "29">14:30</option>','<option value = "30">15:00</option>','<option value = "31">15:30</option>','<option value = "32">16:00</option>','<option value = "33">16:30</option>','<option value = "34">17:00</option>','<option value = "35">17:30</option>','<option value = "36">18:00</option>','<option value = "37">18:30</option>','<option value = "38">19:00</option>','<option value = "39">19:30</option>','<option value = "40">20:00</option>');
for($i = ($timeSection-20);$i < count($timeArray);$i++){
echo $timeArray[$i];
}
?>
</select>
<select id="zone">
<option>华科附中</option>
<option>华科韵苑</option>
<option>光谷创业街</option>
</select>
<input type="text" id="address" placeholder="送餐地址" x-webkit-speech x-webkit-grammar="bUIltin:search" value="门口"/>
<input type="text" id="phone" placeholder="电话号码" x-webkit-speech x-webkit-grammar="bUIltin:search"/>
<button type="button" id="submitOrder">模拟下单</button>
</div><!--end of sendInfo-->
<div id="orderList">
</div>
</div>
<script language="javascript">
var cart = new Array();
$(document).ready(function(){
$(".food").on("click",function(){
var id = $(this).attr("name");
$.ajax({
type: "POST",
url: "./php/order.php",
data: "&order="+id,
success:
function(returnKey){
cart = eval(returnKey);//array
showOrderList(cart);
}
});
});
$("#submitOrder").on("click",function(){
if(cart.length > 0){
var sendTime = $("#sendTime").val();
var phone = $("#phone").val();
var sendAdd,zone;
sendAdd = $("#zone").val()+$("#address").val();
switch($("#zone").val()){
case "华科韵苑":
zone = 0;
break;
case "华科附中":
zone = 1;
break;
case "光谷创业街":
zone = 2;
break;
}
$.ajax({
type: "POST",
url: "./php/imitate_deal.php",
data:"&time="+sendTime+"&address="+sendAdd+"&zone="+zone+"&phone="+phone,
success:
function(returnKey){
if(returnKey == 1){
alert("已下单");
window.location.href = "./wtf.php";
}else{
alert(returnKey);
}
}
});
}else{
alert("无订单");
}
});
$("#orderList").on("click",".order",function(){
var id = $(this).attr("name");
$.ajax({
type: "POST",
url: "./php/order.php",
data: "&del_order="+id,
success:
function(returnKey){
cart = eval(returnKey);//array
showOrderList(cart);
}
});
});
});
function showOrderList(list){
var str = "";
for(var i = 0;i<list.length;i++){
str += '<div class="order" name="'+list[i][0]+'">'+list[i][1]+"×"+list[i][2]+'</div>';
}
$("#orderList").html(str);
$("#orderList").animate({scrollTop:$("#orderList").offset().top},500);
}
</script>
</body>
</html>