-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
485 lines (482 loc) · 14.2 KB
/
index.html
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
<!DOCTYPE html>
<html lang="en" style="">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>道闸立体停车</title>
<link rel="stylesheet" href="css/index.css">
<script src="js/rem.js"></script>
</head>
<body>
<div class="header">
<ul>
<li class="carno">
<div class="active">
<img src="img/shuruxiugai.png" alt="">
</div>
<span>输入车牌</span>
</li>
<li class="payno">
<div>
<img src="img/wallet_icon.png" alt="">
</div>
<span>支付费用</span>
</li>
<li class="success">
<div>
<img src="img/dingdanyichenggong.png"alt="">
</div>
<span>付款成功</span>
</li>
</ul>
</div>
<!-- 车牌查询 -->
<div class="content">
<span>车牌号</span>
<div class="cartext">
<div class="area left">浙</div>
<div class="fake-box">
<div id="1" class="fake"></div>
<div id="2" class="fake"></div>
<div id="3" class="fake"></div>
<div id="4" class="fake"></div>
<div id="5" class="fake"></div>
<div id="6" class="fake last"></div>
<div class="fake fakenew">新能源</div>
</div>
</div>
<div class="query">
<button class="btn">查询停车费</button>
</div>
</div>
<!-- 消费金额显示 -->
<div class="amount" style="display: none">
<ul>
<li>
<span class="carno">车牌信息</span>
<span class="carnotext text"></span>
</li>
<li>
<span class="time">进场时间:</span>
<span class="timetext text"></span>
</li>
<li>
<span class="duration">已停时长:</span>
<span class="durationtext text"></span>
</li>
<li>
<span class="money">已消费金额:</span>
<span class="moneytext text"></span>
</li>
</ul>
<button class="paycost">缴费离场</button>
</div>
<!-- 缴费成功页面 -->
<div class="successto" style="display:none">
<img src="img/chenggong.png" alt="">
<span>缴费成功,请及时离场</span>
</div>
<!-- 省份选择键盘 -->
<div class="province" style="display: none">
<ul>
<li>京</li>
<li>沪</li>
<li>粤</li>
<li>浙</li>
<li>苏</li>
<li>津</li>
<li>冀</li>
<li>川</li>
<li>渝</li>
<li>鄂</li>
<li>闽</li>
<li>陕</li>
<li>鲁</li>
<li>湘</li>
<li>辽</li>
<li>皖</li>
<li>赣</li>
<li>豫</li>
<li>桂</li>
<li>晋</li>
<li>云</li>
<li>贵</li>
<li>黑</li>
<li>吉</li>
<li>琼</li>
<li>甘</li>
<li>蒙</li>
<li>新</li>
<li>青</li>
<li>宁</li>
<li>藏</li>
<li>台</li>
<li>港</li>
<li>澳</li>
</ul>
<div class="qx">取消</div>
</div>
<!-- 车牌选择虚拟键盘 -->
<div class="keyboard" style="display: none">
<!-- <div class="accomplish"
style="text-align: right;position:absolute;top:0.05rem;right:0.2rem;font-size:0.32rem;color: #fff">完成
</div> -->
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>0</li>
<li>Q</li>
<li>W</li>
<li>E</li>
<li>R</li>
<li>T</li>
<li>Y</li>
<li>U</li>
<li class="i" style="background: #ddd">I</li>
<li class="o" style="background: #ddd">O</li>
<li>P</li>
<li>A</li>
<li>S</li>
<li>D</li>
<li>F</li>
<li>G</li>
<li>H</li>
<li>J</li>
<li>K</li>
<li>L</li>
<li>Z</li>
<li>X</li>
<li>C</li>
<li>V</li>
<li>B</li>
<li>N</li>
<li>M</li>
<li>学</li>
</ul>
<div class="backdel">
<img src="img/tuige.png" alt="">
</div>
<div class="accomplish">
<span>完成</span>
</div>
</div>
<!-- 遮罩层 -->
<div class="mask" style="display: none">
<div class="maskPlate">
<span class="errPlate">请使用微信或支付宝扫描二维码</span>
</div>
</div>
</body>
<script src="js/jquery-3.4.0.min.js"></script>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.inc.min.js"></script>
<script>
if (!isMobile()) {
$(".errPlate").text("请使用微信或支付宝扫描二维码");
$(".errPlateBtn").remove();
$(".mask").show();
}
if(isMobile()&&!isWeiXin()&&!isAlipay()){
$(".errPlate").text("请使用微信或支付宝扫描二维码");
$(".errPlateBtn").remove();
$(".mask").show();
}
console.log(window.navigator.userAgent.match())
function isMobile() {
var ua = window.navigator.userAgent;
if (!!ua.match(/AppleWebKit.*Mobile.*/)) {
return true;
} else {
return false;
}
}
function isWeiXin() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
function isAlipay() {
var userAgent = window.navigator.userAgent.toLowerCase();
if (userAgent.match(/Alipay/i) == "alipay") {
return true;
} else {
return false;
}
}
var source = "wxjs";
var code = ''
var total_fee = '' //消费金额
var orderno = '' //订单编号
var isLogin = false
$(function(){
function parse_url(url) { //定义函数
var pattern = /(\w+)=(\w+)/ig; //定义正则表达式
var parames = {}; //定义数组
url.replace(pattern, function (a, b, c) {
parames[b] = c;
});
return parames; //返回这个数组.
}
//获取当前url 取到code
var url = window.location.href;
var params = parse_url(url);
//params.code 就是当前的code
isLogin = true
code = params.code
console.log(code)
if (isWeiXin()) {
source = "wxjs";
} else if (isAlipay()) {
source = "alipayjs";
} else {
$(".errPlate").text("请使用微信或支付宝扫描二维码");
$(".errPlateBtn").remove();
$(".mask").show();
return;
}
},
// 取消键隐藏省份键盘
$('.qx').click(function(){
$('.province').hide()
}),
// 查询车费
$('.btn').click(function(){
$('.province').hide();
$('.keyboard').hide();
let carNum = $(".area").text();
console.log(carNum)
let carcarNumSub;
var isEmpty = true;
$(".fake").each(function (index, e) {
carNumSub = $(e).text();
console.log(carNumSub);
if (carNumSub && carNumSub.length > 0 && !$(e).hasClass("fakenew")) {
carNum += carNumSub;
} else if (!$(e).hasClass("fakenew")) {
$(".errPlate").html("请填写完整车牌号");
$(".mask").show();
isEmpty = false;
return false;
}
console.log(carNum);
});
$.ajax({
type: "post",
url: "http://www.lcgxlm.com:13259/its/admin/pay/billig",
data: {
carNo: carNum
},
success: function (res) {
console.log(res)
if (res.success) {
if (!isEmpty) return;
$('.content').hide()
$('.carno div').removeClass('active')
$('.payno div').addClass('active')
$('.amount').show()
$('.carnotext').html(carNum)
$('.timetext').html(res.data.data.startTime)
$('.durationtext').html(res.data.data.parkTime)
$('.moneytext').html(res.data.data.payCharge)
total_fee = res.data.data.payCharge
orderno = res.data.data.tradeNo
}
if (res.fail) {
$(".errPlate").html("没有查到该车牌的停车信息,请查证后重新输入车牌查询");
$(".mask").show();
isEmpty = false;
return false;
}
}
});
}),
// 选择车牌省份
$('.area').click(function(e){
e.stopPropagation()
var that = $(this)
that.addClass('act').siblings().children().removeClass('act'),
$('.province').show(),
$('.keyboard').hide(),
$('.province ul').click(function(e){
e.stopPropagation()
if(e.target.nodeName === 'LI'){
var name = $(e.target).html()
that.html(name)
$(e.target).parent().parent().hide();
$('.keyboard').show();
that.removeClass('act');
$('.fake-box div').eq(0).addClass('act');
}
})
}),
//点击空白处关闭键盘
$('body').click(function(){
console.log('触发关闭')
$('.province').hide();
$('.keyboard').hide();
return false
}),
//点击完成关闭键盘
$('.accomplish').click(function(){
$('.keyboard').hide();
return false
}),
// 车牌输入
$('.fake').click(function(e){
e.stopPropagation()
$('.keyboard').show()
$('.province').hide()
var that = $(this)
that.addClass('act').siblings().children().removeClass('act'),
$('.keyboard li').off('touchstart').on('touchstart', function () {
var self=$(this).attr('class');
if((self=='i')||(self=='o')){
return
}
var cname = $(this).html();
$('.fake-box .act').html(cname);
var id_div = parseInt($('.fake-box .act').attr("id"));
$('#' + (id_div + 1)).addClass('act').siblings().removeClass('act');
return false
})
}),
$('.keyboard li').off('touchstart').on('touchstart', function (e) {
e.stopImmediatePropagation();
var self=$(this).attr('class');
if((self=='i')||(self=='o')){
return
}
var cname = $(this).html();
$('.fake-box .act').html(cname);
var id_div = parseInt($('.fake-box .act').attr("id"));
$('#' + (id_div + 1)).addClass('act').siblings().removeClass('act');
return false
}),
// 系能源车牌
$('.fakenew').click(function(){
$(this).attr('id', '7').removeClass('fakenew').html('')
}),
//车牌号焦点样式事件
$(".fake-box").on('touchstart', '.fake', function (e) {
console.log(e)
e.stopPropagation();
$('.province').hide();
$('.area').removeClass('act');
$('.keyboard').show();
$(this).addClass('act').siblings().removeClass('act');
}),
// 删除键
$('.backdel').off('touchstart').on('touchstart', function () {
$('.fake-box .act').html('');
var index = $('.fake-box .act').attr('id');
$('#' + (index - 1)).addClass('act').siblings().removeClass('act')
return false
}),
// 点击蒙层关闭蒙层
$('.mask').click(function(){
$(".mask").hide()
}),
// 缴费离场事件
$('.paycost').click(function(){
if(isWeiXin()){
$.ajax({
type: "post",
url: "http://www.lcgxlm.com:13259/its/admin/pay/brake",
data: {
code: code,
tradeNo:orderno,
total_fee: total_fee*100
},
success: function (res) {
console.log(res)
if(res.success){
function onBridgeReady(){
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": res.data.appId, //公众号id,由商户传入
"timeStamp":res.data.timeStamp, //时间戳,自1970年以来的秒数
"nonceStr":res.data.nonceStr, //随机串
"package":res.data.package, //订单详情扩展字符串
"signType":res.data.signType, //微信签名方式:
"paySign":res.data.paySign //微信签名
},
function(res){
console.log(res)
if(res.err_msg == "get_brand_wcpay_request:ok" ){
$('.content').hide()
$('.amount').hide()
$('.successto').show()
$('.carno div').removeClass('active')
$('.payno div').removeClass('active')
$('.success div').addClass('active')
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
}
});
}
if (typeof WeixinJSBridge == "undefined"){
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
}else{
onBridgeReady();
}
}else{
$(".errPlate").text("支付失败");
$(".errPlateBtn").remove();
$(".mask").show();
}
}
});
}
if(isAlipay()){
$.ajax({
type: "post",
url: "http://www.lcgxlm.com:13259/its/admin/brake/alipay",
data: {
tradeNo:orderno,
total_fee: total_fee
},
success:function(res){
console.log(res)
if(res.mesg == 'OK'){
ap.tradePay({
orderStr: res.orderString
}, function(res){
if(res.resultCode == 9000){
$('.content').hide()
$('.amount').hide()
$('.successto').show()
$('.carno div').removeClass('active')
$('.payno div').removeClass('active')
$('.success div').addClass('active')
}else{
$(".errPlate").text("支付失败");
$(".errPlateBtn").remove();
$(".mask").show();
}
});
}
}
})
}
})
)
</script>
</html>