Commit 6a633a7d115a64243690fd99a4d8b65b86208832
1 parent
442c6d46
出场结算页面 新建输入框
Showing
3 changed files
with
121 additions
and
17 deletions
config.js
@@ -34,7 +34,8 @@ webAppH5.dynCode = {//卫岗固定参数 | @@ -34,7 +34,8 @@ webAppH5.dynCode = {//卫岗固定参数 | ||
34 | 34 | ||
35 | /*出、入场接口*/ | 35 | /*出、入场接口*/ |
36 | webAppH5.comServer = "/keyTopQrCodeInOutPark/noCarQRcodeInOutPark"; | 36 | webAppH5.comServer = "/keyTopQrCodeInOutPark/noCarQRcodeInOutPark"; |
37 | - | 37 | +/*优惠券*/ |
38 | +webAppH5.discountServer = "/keyTopQrCodeInOutPark/useCouponQueryFee"; | ||
38 | //缴费-微信 | 39 | //缴费-微信 |
39 | webAppH5.wxPayServer = "/weixinpay/publicUnifiedOrder"; | 40 | webAppH5.wxPayServer = "/weixinpay/publicUnifiedOrder"; |
40 | 41 |
js/pay.js
@@ -6,12 +6,15 @@ | @@ -6,12 +6,15 @@ | ||
6 | var webAppParams = null; | 6 | var webAppParams = null; |
7 | var $btnObj = null; | 7 | var $btnObj = null; |
8 | var $btnLoad = null; | 8 | var $btnLoad = null; |
9 | +var flag = 0; | ||
9 | var webAppCode = null;//如果是微信,先获取微信code | 10 | var webAppCode = null;//如果是微信,先获取微信code |
10 | //var $btnLoad = document.getElementById("loading"); | 11 | //var $btnLoad = document.getElementById("loading"); |
11 | window.onload = function () { | 12 | window.onload = function () { |
12 | //var root = document.getElementById("root"); | 13 | //var root = document.getElementById("root"); |
13 | $btnObj = document.getElementById("btnPayOK"); | 14 | $btnObj = document.getElementById("btnPayOK"); |
14 | $btnLoad = document.getElementById("loading"); | 15 | $btnLoad = document.getElementById("loading"); |
16 | + | ||
17 | + $discountBtn = document.getElementById("discountBtn"); | ||
15 | $linkPayDetail = getObjectByID("linkPayDetail"); | 18 | $linkPayDetail = getObjectByID("linkPayDetail"); |
16 | $linkPayDetail.onclick = webAppClass.linkPayDetailClick; | 19 | $linkPayDetail.onclick = webAppClass.linkPayDetailClick; |
17 | var webRoot = window.location.href; | 20 | var webRoot = window.location.href; |
@@ -39,9 +42,98 @@ window.onload = function () { | @@ -39,9 +42,98 @@ window.onload = function () { | ||
39 | if (state == "wxPay") { | 42 | if (state == "wxPay") { |
40 | webAppCode = webAppClass.getCode(); | 43 | webAppCode = webAppClass.getCode(); |
41 | } | 44 | } |
45 | + $discountBtn.onclick = webAppClass.discountClick; | ||
42 | } | 46 | } |
43 | /**/ | 47 | /**/ |
44 | var webAppClass = { | 48 | var webAppClass = { |
49 | + //优惠券兑换 | ||
50 | + discountClick1:function(tmpObj){ | ||
51 | + discountVal = document.getElementById("discountBox").value; | ||
52 | + // console.log(discountVal) | ||
53 | + // console.log(discountVal.length) | ||
54 | + if(discountVal.length > 0){ | ||
55 | + $btnObj.style.display = "none"; | ||
56 | + $btnLoad.style.display = "block"; | ||
57 | + $discountBtn.disabled = true | ||
58 | + console.log(webAppParams.orderId) | ||
59 | + var url = webAppRoot + window.webAppH5.discountServer; | ||
60 | + var discountParams = { | ||
61 | + app_id:'1', | ||
62 | + salt:'1', | ||
63 | + deviceInfo:'1', | ||
64 | + sign_type:'1', | ||
65 | + sign:'1', | ||
66 | + token:'1', | ||
67 | + terminalSource:7, | ||
68 | + orderId:webAppParams.orderId, | ||
69 | + cardNo:discountVal, | ||
70 | + codeType:0 | ||
71 | + } | ||
72 | + postRequest(url, discountParams, function (res) { | ||
73 | + console.log(res) | ||
74 | + if(res.code==0){ | ||
75 | + | ||
76 | + document.getElementById("sumMoney").innerHTML = (res.data.orderFee/100) | ||
77 | + document.getElementById("discountTip").innerHTML = res.data.couponDescribe | ||
78 | + document.getElementById("discountFee").innerHTML = (res.data.discountFee/100) | ||
79 | + document.getElementById("discountDesc").style.display="none" | ||
80 | + $btnLoad.style.display = "none"; | ||
81 | + $btnObj.style.display = "block"; | ||
82 | + flag = 1 | ||
83 | + //webAppClass.okPay(tmpObj);//唤醒支付 | ||
84 | + }else{ | ||
85 | + $discountBtn.disabled = false | ||
86 | + document.getElementById("discountTip").innerHTML = res.message | ||
87 | + } | ||
88 | + }) | ||
89 | + | ||
90 | + }else{ | ||
91 | + return | ||
92 | + } | ||
93 | + }, | ||
94 | + discountClick: function(){ | ||
95 | + discountVal = document.getElementById("discountBox").value; | ||
96 | + // console.log(discountVal) | ||
97 | + // console.log(discountVal.length) | ||
98 | + if(discountVal.length > 0){ | ||
99 | + $btnObj.style.display = "none"; | ||
100 | + $btnLoad.style.display = "block"; | ||
101 | + $discountBtn.disabled = true | ||
102 | + console.log(webAppParams.orderId) | ||
103 | + var url = webAppRoot + window.webAppH5.discountServer; | ||
104 | + var discountParams = { | ||
105 | + app_id:'1', | ||
106 | + salt:'1', | ||
107 | + deviceInfo:'1', | ||
108 | + sign_type:'1', | ||
109 | + sign:'1', | ||
110 | + token:'1', | ||
111 | + terminalSource:7, | ||
112 | + orderId:webAppParams.orderId, | ||
113 | + cardNo:discountVal, | ||
114 | + codeType:0 | ||
115 | + } | ||
116 | + postRequest(url, discountParams, function (res) { | ||
117 | + console.log(res) | ||
118 | + if(res.code==0){ | ||
119 | + | ||
120 | + document.getElementById("sumMoney").innerHTML = (res.data.orderFee/100) | ||
121 | + document.getElementById("discountTip").innerHTML = res.data.couponDescribe | ||
122 | + document.getElementById("discountFee").innerHTML = (res.data.discountFee/100) | ||
123 | + document.getElementById("discountDesc").style.display="none" | ||
124 | + $btnLoad.style.display = "none"; | ||
125 | + $btnObj.style.display = "block"; | ||
126 | + flag = 1 | ||
127 | + }else{ | ||
128 | + $discountBtn.disabled = false | ||
129 | + document.getElementById("discountTip").innerHTML = res.message | ||
130 | + } | ||
131 | + }) | ||
132 | + | ||
133 | + }else{ | ||
134 | + return | ||
135 | + } | ||
136 | + }, | ||
45 | //OK | 137 | //OK |
46 | okClick: function (ev) { | 138 | okClick: function (ev) { |
47 | document.getElementById("payTip").innerHTML = ""; | 139 | document.getElementById("payTip").innerHTML = ""; |
@@ -66,9 +158,16 @@ var webAppClass = { | @@ -66,9 +158,16 @@ var webAppClass = { | ||
66 | if (res.code == 0) {//进场 | 158 | if (res.code == 0) {//进场 |
67 | var tmpObj = res.data; | 159 | var tmpObj = res.data; |
68 | if (tmpObj) { | 160 | if (tmpObj) { |
69 | - webAppClass.setUI(tmpObj); | ||
70 | - webAppParams = tmpObj;//重新赋值 | ||
71 | - webAppClass.okPay(tmpObj);//唤醒支付 | 161 | + if(flag == 1){ |
162 | + webAppClass.discountClick1(tmpObj); | ||
163 | + }else{ | ||
164 | + webAppClass.setUI(tmpObj); | ||
165 | + webAppParams = tmpObj;//重新赋值 | ||
166 | + webAppClass.okPay(tmpObj);//唤醒支付 | ||
167 | + } | ||
168 | + | ||
169 | + console.log(tmpObj) | ||
170 | + // webAppClass.okPay(tmpObj);//唤醒支付 | ||
72 | } else { | 171 | } else { |
73 | alertMsg("没有找到相应订单"); | 172 | alertMsg("没有找到相应订单"); |
74 | } | 173 | } |
@@ -264,7 +363,7 @@ var webAppClass = { | @@ -264,7 +363,7 @@ var webAppClass = { | ||
264 | //0:页面初始化获取code[webAppCode] | 363 | //0:页面初始化获取code[webAppCode] |
265 | var codeParams = { code: webAppCode, appId: appWxID }; | 364 | var codeParams = { code: webAppCode, appId: appWxID }; |
266 | var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer; | 365 | var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer; |
267 | - | 366 | + |
268 | //1:有code获取OpenId | 367 | //1:有code获取OpenId |
269 | postRequest(openIdUrl, codeParams, function (res) { | 368 | postRequest(openIdUrl, codeParams, function (res) { |
270 | //alert(JSON.stringify(res)); | 369 | //alert(JSON.stringify(res)); |
@@ -290,7 +389,7 @@ var webAppClass = { | @@ -290,7 +389,7 @@ var webAppClass = { | ||
290 | }); | 389 | }); |
291 | //2:获取支付参数 | 390 | //2:获取支付参数 |
292 | //function getPayParams(openId) { | 391 | //function getPayParams(openId) { |
293 | - | 392 | + |
294 | //} | 393 | //} |
295 | }, | 394 | }, |
296 | getPayParams: function (openId, orderID) { | 395 | getPayParams: function (openId, orderID) { |
@@ -337,12 +436,12 @@ var webAppClass = { | @@ -337,12 +436,12 @@ var webAppClass = { | ||
337 | WeixinJSBridge.invoke( | 436 | WeixinJSBridge.invoke( |
338 | 'getBrandWCPayRequest', params, | 437 | 'getBrandWCPayRequest', params, |
339 | //'getBrandWCPayRequest', { | 438 | //'getBrandWCPayRequest', { |
340 | - // "appId": appWxID, //公众号名称,由商户传入 | ||
341 | - // "timeStamp": "1395712654", //时间戳,自1970年以来的秒数 | ||
342 | - // "nonceStr": "e61463f8efa94090b1f366cccfbbb444", //随机串 | 439 | + // "appId": appWxID, //公众号名称,由商户传入 |
440 | + // "timeStamp": "1395712654", //时间戳,自1970年以来的秒数 | ||
441 | + // "nonceStr": "e61463f8efa94090b1f366cccfbbb444", //随机串 | ||
343 | // "package": "prepay_id=u802345jgfjsdfgsdg888", | 442 | // "package": "prepay_id=u802345jgfjsdfgsdg888", |
344 | - // "signType": "MD5", //微信签名方式: | ||
345 | - // "paySign": "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名 | 443 | + // "signType": "MD5", //微信签名方式: |
444 | + // "paySign": "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名 | ||
346 | //}, | 445 | //}, |
347 | function (res) { | 446 | function (res) { |
348 | //alert(res.err_msg); | 447 | //alert(res.err_msg); |
@@ -393,6 +492,7 @@ var webAppClass = { | @@ -393,6 +492,7 @@ var webAppClass = { | ||
393 | 492 | ||
394 | //设置UI | 493 | //设置UI |
395 | setUI: function (params) { | 494 | setUI: function (params) { |
495 | + console.log('ui') | ||
396 | var $carNum = getObjectByID("carNum"),//车牌号 | 496 | var $carNum = getObjectByID("carNum"),//车牌号 |
397 | $orderNum = getObjectByID("orderNum"),//订单号 | 497 | $orderNum = getObjectByID("orderNum"),//订单号 |
398 | $sumMoney = getObjectByID("sumMoney"),//实际应付金额 | 498 | $sumMoney = getObjectByID("sumMoney"),//实际应付金额 |
@@ -420,7 +520,7 @@ var webAppClass = { | @@ -420,7 +520,7 @@ var webAppClass = { | ||
420 | $parkName.innerHTML = params.parkName; | 520 | $parkName.innerHTML = params.parkName; |
421 | $inparktime.innerHTML = params.inparktime; | 521 | $inparktime.innerHTML = params.inparktime; |
422 | $staytime.innerHTML = formatSeconds(params.staytime); | 522 | $staytime.innerHTML = formatSeconds(params.staytime); |
423 | - | 523 | + |
424 | $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用 | 524 | $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用 |
425 | $paid.innerHTML = params.paid; | 525 | $paid.innerHTML = params.paid; |
426 | $discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额 | 526 | $discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额 |
@@ -442,4 +542,4 @@ var webAppClass = { | @@ -442,4 +542,4 @@ var webAppClass = { | ||
442 | $payDetail.style.height = "55px"; | 542 | $payDetail.style.height = "55px"; |
443 | } | 543 | } |
444 | } | 544 | } |
445 | -} | ||
446 | \ No newline at end of file | 545 | \ No newline at end of file |
546 | +} |
pay.html
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | <meta http-equiv="Expires" content="0"> | 15 | <meta http-equiv="Expires" content="0"> |
16 | <link rel="stylesheet" href="css/index.css?v=0.1"> | 16 | <link rel="stylesheet" href="css/index.css?v=0.1"> |
17 | <script src="config.js?v=0.1"></script> | 17 | <script src="config.js?v=0.1"></script> |
18 | - <script src="js/common.js?v=0.11"></script> | 18 | + <script src="js/common.js?v=1.11"></script> |
19 | <!--<script src="js/jweixin-1.0.0.js?v=0.1"></script>--> | 19 | <!--<script src="js/jweixin-1.0.0.js?v=0.1"></script>--> |
20 | <script src="js/pay.js?v=0.120"></script> | 20 | <script src="js/pay.js?v=0.120"></script> |
21 | <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>--> | 21 | <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>--> |
@@ -43,6 +43,7 @@ | @@ -43,6 +43,7 @@ | ||
43 | display: inline-block; | 43 | display: inline-block; |
44 | float: left; | 44 | float: left; |
45 | color: #8a8a8a; | 45 | color: #8a8a8a; |
46 | + font-size: 14px; | ||
46 | } | 47 | } |
47 | .discountBox:focus{ | 48 | .discountBox:focus{ |
48 | border: 0; | 49 | border: 0; |
@@ -63,6 +64,8 @@ | @@ -63,6 +64,8 @@ | ||
63 | background: #fff; | 64 | background: #fff; |
64 | } | 65 | } |
65 | .discount-tip{ | 66 | .discount-tip{ |
67 | + padding-top: 10px; | ||
68 | + font-size: 14px; | ||
66 | color: #EB453B; | 69 | color: #EB453B; |
67 | } | 70 | } |
68 | </style> | 71 | </style> |
@@ -88,10 +91,10 @@ | @@ -88,10 +91,10 @@ | ||
88 | </section> | 91 | </section> |
89 | <div class="row marginTop"> | 92 | <div class="row marginTop"> |
90 | <div style="overflow: hidden"> | 93 | <div style="overflow: hidden"> |
91 | - <input class="discountBox" type="text" placeholder="请输入优惠券编号" maxlength="20"> | ||
92 | - <button class="discountBtn">兑换</button> | 94 | + <input class="discountBox" id="discountBox" type="text" placeholder="请输入优惠券编号" maxlength="20"> |
95 | + <button class="discountBtn" id="discountBtn">兑换</button> | ||
93 | </div> | 96 | </div> |
94 | - <div class="discount-tip">注意:</div> | 97 | + <div class="discount-tip" id="discountTip"></div> |
95 | </div> | 98 | </div> |
96 | <section id="section" class="marginTop"> | 99 | <section id="section" class="marginTop"> |
97 | <div class="flexBoxRow" > | 100 | <div class="flexBoxRow" > |