Commit 544f25d22aed5ecd037dc8188c9c0894526d24fe
1 parent
ed71fe63
扫码支付。。。
Showing
11 changed files
with
217 additions
and
116 deletions
billCodePay.html
... | ... | @@ -13,10 +13,10 @@ |
13 | 13 | <meta http-equiv="Cache-control" content="no-cache"> |
14 | 14 | <meta http-equiv="Cache" content="no-cache"> |
15 | 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.121"> | |
17 | 17 | <script src="config.js?v=0.1"></script> |
18 | - <script src="js/common.js?v=0.1"></script> | |
19 | - <script src="js/billCodePay.js?v=0.1"></script> | |
18 | + <script src="js/common.js?v=0.121"></script> | |
19 | + <script src="js/billCodePay.js?v=0.121"></script> | |
20 | 20 | <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>--> |
21 | 21 | <!--<script src="config.js"></script>--> |
22 | 22 | <!-- |
... | ... | @@ -34,7 +34,8 @@ |
34 | 34 | <!--<noscript>--> |
35 | 35 | <!--You need to enable JavaScript to run this app.--> |
36 | 36 | <!--</noscript>--> |
37 | - <header id="header" class="flexBoxRow panelBgColor"> | |
37 | + <header id="header" class="flexBoxRow_column panelBgColor"> | |
38 | + <div class="headTip" id="headTip"><span>订单获取成功,请您尽快完成支付,剩余时间:</span><span id="countDownTime"></span> </div> | |
38 | 39 | <div class="headerBox"> |
39 | 40 | <div class="carNumBox"><span></span><span id="carNum"></span></div> |
40 | 41 | <div class="moneyBox"><span>¥</span><span id="sumMoney">0.00</span></div> | ... | ... |
config.js
... | ... | @@ -6,12 +6,10 @@ |
6 | 6 | window.webAppH5 = {}; |
7 | 7 | |
8 | 8 | //微信appID |
9 | -var appWxID = "wx1e9001e5940605b1";//wx945eccc8163fd75b | |
9 | +var appWxID = "wx945eccc8163fd75b"; | |
10 | 10 | |
11 | 11 | /*服务器地址*/ |
12 | -//var webAppRoot = "http://39.98.54.240:8090"; | |
13 | -var webAppRoot = "http://pay.service.renniting.cn/v1"; | |
14 | - | |
12 | +var webAppRoot = "http://pay.service.renniting.cn/v1";//http://39.98.54.240:8090"; //"http://39.98.54.240:8090"; | |
15 | 13 | //微信支付结果回调地址 |
16 | 14 | var webAppPayResult = "http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/page/wxpayResult.html"; |
17 | 15 | |
... | ... | @@ -25,7 +23,7 @@ webAppH5.comParams = { |
25 | 23 | token: '666' |
26 | 24 | } |
27 | 25 | |
28 | -//小票扫码支付参数codeType[0静态码、1小票二维码、2动态二维码] | |
26 | +//小票扫码支付参数 | |
29 | 27 | webAppH5.dynCode = {//卫岗固定参数 |
30 | 28 | direction: 1, |
31 | 29 | codeType: 1, |
... | ... | @@ -38,7 +36,7 @@ webAppH5.comServer = "/keyTopQrCodeInOutPark/noCarQRcodeInOutPark"; |
38 | 36 | //缴费-微信 |
39 | 37 | webAppH5.wxPayServer = "/weixinpay/publicUnifiedOrder"; |
40 | 38 | |
41 | -//微信获取openID | |
39 | +//缴费-微信 | |
42 | 40 | webAppH5.wxGetOpenIdServer = "/weixinPublicPay/getOpenIdByCode"; |
43 | 41 | |
44 | 42 | //缴费-支付宝 |
... | ... | @@ -79,7 +77,7 @@ webAppH5.aliPayServer = "/alipay/aliH5Pay"; |
79 | 77 | |
80 | 78 | //小票二维码出场 |
81 | 79 | //http://39.98.54.240/codepay/index.html?appid=0&lotId=1&payConfigId=2&receiptNo=3 |
82 | -//http://localhost:1260/codepay/index.html?appid=0&lotId=3504&payConfigId=2&receiptNo=3& | |
80 | +//http://localhost:1260/codepay/index.html?appid=0&lotId=1&payConfigId=2&receiptNo=3 | |
83 | 81 | |
84 | 82 | |
85 | 83 | //首页 |
... | ... | @@ -97,22 +95,5 @@ webAppH5.aliPayServer = "/alipay/aliH5Pay"; |
97 | 95 | |
98 | 96 | //http://localhost:1260/pay.html?orderId=101526715300086198272&parkName=%E9%9D%99%E9%9B%85%E5%9C%B0%E4%B8%8A&parkCode=B1504020C7&inparktime=2018-12-24%2010%3A58%3A24&outtime=2018-12-24%2011%3A05%3A10&staytime=420&due=70&paid=0&orderTotalFee=70&orderFee=7&discountFee=63&plateno=%E8%92%99DTK366&outPayOrderNo=B1504020C720181224110510813DTK366-172192102&appOrderTimeout=%E8%AF%B7%E5%9C%A8%E6%94%AF%E4%BB%98%E5%AE%8C%E6%88%9010%E5%88%86%E9%92%9F%E5%86%85%E5%87%BA%E5%9C%BA%EF%BC%8C%E5%A6%82%E8%B6%85%E6%97%B6%E6%9C%AA%E5%87%BA%E5%9C%BA%EF%BC%8C%E4%BC%9A%E7%BB%A7%E7%BB%AD%E8%AE%A1%E8%B4%B9%E3%80%82&discountDesc=1%E6%8A%98%E4%BC%98%E6%83%A0&queryOrderInfo=%7B%22app_id%22%3A%221%22%2C%22carNumber%22%3A%22%E8%92%99DTK366%22%2C%22channelId%22%3A%22172192102%22%2C%22codeType%22%3A0%2C%22deviceInfo%22%3A%223%22%2C%22direction%22%3A1%2C%22parkingId%22%3A%22B1504020C7%22%2C%22plNo%22%3A%22B1504020C7%22%2C%22salt%22%3A%222%22%2C%22sign%22%3A%224%22%2C%22sign_type%22%3A%22md5%22%2C%22terminalSource%22%3A%227%22%2C%22token%22%3A%22666%22%7D&needPay=true |
99 | 97 | |
100 | -/*正式环境前缀*/ | |
101 | -//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay | |
102 | - | |
103 | -/*类型1: | |
104 | -lotId -->parkingId | |
105 | -receiptNo --> carNumber 车牌号 | |
106 | -direction 固定 1 | |
107 | -codeType 固定 1 | |
108 | -terminalSource 固定 7 | |
109 | -channelId 固定 小票二维码 | |
110 | -*/ | |
111 | -//http://localhost:1260/dynCodePay.html?appid=0&lotId=3504&payConfigId=2&receiptNo=%E8%92%99D9203C | |
112 | -//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/index.html?appid=0&lotId=3504&payConfigId=2&receiptNo=%E8%92%99D9203C | |
113 | - | |
114 | -//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/index.html?appid=0&lotId=3504&payConfigId=2&receiptNo=蒙D871R2 | |
115 | 98 | |
116 | -/*类型2:codeType2动态二维码正式环境地址前缀*/ | |
117 | -//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/index.html?codeType=2&isNeedPay=1&orderId=001&parkName=万达停车场&parkCode=a001&inparktime=2018-12-26 00:00:00&outtime=2018-12-26 10:00:00&staytime=360&orderFee=100&plateno=蒙DY2408 | |
118 | 99 | ... | ... |
css/index.css
... | ... | @@ -33,11 +33,20 @@ body { |
33 | 33 | } |
34 | 34 | .flexBoxRow { |
35 | 35 | display: flex; |
36 | + display: -webkit-flex; | |
36 | 37 | justify-content: left; |
37 | 38 | flex-direction:row; |
38 | 39 | align-items:center; |
39 | 40 | width:100%; |
40 | 41 | } |
42 | +.flexBoxRow_column { | |
43 | + display: flex; | |
44 | + display: -webkit-flex; | |
45 | + justify-content: left; | |
46 | + flex-direction:column; | |
47 | + align-items:center; | |
48 | + width:100%; | |
49 | +} | |
41 | 50 | .carNumBox { |
42 | 51 | font-size:1.4rem; |
43 | 52 | font-weight:bold; |
... | ... | @@ -169,4 +178,17 @@ body { |
169 | 178 | transition: all 0.2s ease; |
170 | 179 | transform: scale(1, 1); |
171 | 180 | display: inline-block; |
172 | -} | |
173 | 181 | \ No newline at end of file |
182 | +} | |
183 | + | |
184 | +.headTip { | |
185 | + display:none;text-align: center; | |
186 | + background-color:rgba(253, 201, 11, 0.95); | |
187 | + width: 100%; | |
188 | + line-height:25px; | |
189 | +} | |
190 | +.headTip > span:first-child { | |
191 | + | |
192 | +} | |
193 | +.headTip > span:last-child { | |
194 | + color:red;font-size: 1.6rem; | |
195 | +} | ... | ... |
doc.txt
1 | -git | |
2 | -http://192.168.1.195:9998/web_developers/codepay.git | |
1 | +http://132.232.101.107/webApp/paywxali/index.html | |
2 | + | |
3 | +http://132.232.101.107/webApp/paywxali/demo.html | |
4 | +判断当前手机端浏览器是微信还是支付宝 | |
5 | + | |
6 | + | |
7 | + | |
8 | + | |
9 | +调用微信和支付宝第三方接口方法总结 | |
10 | +https://blog.csdn.net/yufeng005/article/details/54583467 | |
11 | + | |
12 | + | |
13 | + | |
14 | +ajax支付 | |
15 | +https://www.cnblogs.com/junjieok/p/4538580.html | |
16 | + | |
17 | + | |
3 | 18 | |
4 | 19 | |
5 | 20 | //进出场接口文档-卫岗 |
... | ... | @@ -37,40 +52,15 @@ http://39.98.54.240/codepay/index.html?plNo=P11011700C&parkingId=1&channelId=172 |
37 | 52 | http://39.98.54.240/codepay/index.html?plNo=P11011700C&parkingId=1&channelId=172198243&direction=1&codeType=0&expireDate=expireDate&extendData=extendData |
38 | 53 | |
39 | 54 | |
55 | +//server通过--12 | |
56 | +//出场--支付校验 | |
57 | +http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/page/out6.html?plNo=B1504020C7&parkingId=1&channelId=172198243&direction=1&codeType=0&expireDate=expireDate&extendData=extendData | |
40 | 58 | |
41 | -说明: | |
42 | -支付宝:后台返回form表单,直接支付,简单。 | |
43 | -微信支付麻烦,1服务号需要配置支付目录;2:获取code;3:获取openid;4:获取参数;5:发起支付; JSAPI支付流程 | |
44 | - | |
45 | -pay.html,先校验订单,在发起请求 | |
46 | - | |
47 | -//小票固定参数 | |
48 | -[billCodePay.html,扫码二维码,纸质] | |
49 | -对应关系: | |
50 | -lotId -->parkingId 停车场编号 | |
51 | -receiptNo --> carNumber 车牌号 | |
52 | -direction 固定 1 | |
53 | -codeType 固定 1 | |
54 | -terminalSource 固定 7 | |
55 | -channelId 固定 小票二维码 | |
56 | - | |
57 | - | |
58 | -//动态二维码[dynCodePay.html] | |
59 | -String qrcodeType;//2-动态二维码 | |
60 | -private Boolean isNeedPay=true; | |
61 | -private String orderId;//订单号 | |
62 | -private String parkName;//停车场名称 | |
63 | -private String parkCode;//停车场编号 | |
64 | -private String inparktime;//进场时间 格式:yyyy-MM-dd HH:mm:ss | |
65 | -private String outtime;//出场时间 格式:yyyy-MM-dd HH:mm:ss | |
66 | -private String staytime;//停车时长1 | |
67 | -private String orderFee;//本次出场实际应付金额(减去折扣,优惠券等之后的应付金额)分 | |
68 | -private String plateno;// 车牌号 | |
69 | - | |
70 | -?codeType=2&isNeedPay=1&orderId=001&parkName=万达停车场&parkCode=a001&inparktime=2018-12-26 00:00:00&outtime=2018-12-26 10:00:00&staytime=1&orderFee=100&plateno=蒙DY2408 | |
71 | - | |
72 | - | |
73 | -//动态二维码测试,订单号:101527546939039301632 车牌:蒙D11111 可以测试 | |
74 | -http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/dynCodePay.html?codeType=2&isNeedPay=1&orderId=101527546939039301632&parkName=%E4%B8%87%E8%BE%BE%E5%81%9C%E8%BD%A6%E5%9C%BA&parkCode=a001&inparktime=2018-12-26%2000%3A00%3A00&outtime=2018-12-26%2010%3A00%3A00&staytime=360&orderFee=100&plateno=%E8%92%99DY2408 | |
59 | +//动态码-钱在url中,没有校验 | |
60 | +http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/dynCodePay6.html?codeType=2&isNeedPay=1&orderId=101527546939039301632&parkName=%E4%B8%87%E8%BE%BE%E5%81%9C%E8%BD%A6%E5%9C%BA&parkCode=a001&inparktime=2018-12-26%2000%3A00%3A00&outtime=2018-12-26%2010%3A00%3A00&staytime=360&orderFee=100&plateno=%E8%92%99DY2408 | |
75 | 61 | |
76 | 62 | |
63 | +//出场码 | |
64 | +http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/pay.html?orderId=101536977652977254400&parkName=%E9%9D%99%E9%9B%85%E5%B0%81%E9%97%AD%E8%BD%A6%E5%9C%BA&parkCode=B1504020C7&inparktime=2019-01-21%2018%3A37%3A26&outtime=2019-01-22%2012%3A01%3A48&staytime=62640&due=1100&paid=0&orderTotalFee=1100&orderFee=990&discountFee=110&plateno=%E8%92%99DJF612&outPayOrderNo=B1504020C720190122120148594DJF612-172198243&appOrderTimeout=%E8%AF%B7%E5%9C%A8%E6%94%AF%E4%BB%98%E5%AE%8C%E6%88%9010%E5%88%86%E9%92%9F%E5%86%85%E5%87%BA%E5%9C%BA%EF%BC%8C%E5%A6%82%E8%B6%85%E6%97%B6%E6%9C%AA%E5%87%BA%E5%9C%BA%EF%BC%8C%E4%BC%9A%E7%BB%A7%E7%BB%AD%E8%AE%A1%E8%B4%B9%E3%80%82&discountDesc=9%E6%8A%98%E4%BC%98%E6%83%A0&queryOrderInfo=%7B%22app_id%22%3A%221%22%2C%22carNumber%22%3A%22%E8%92%99DJF612%22%2C%22channelId%22%3A%22172198243%22%2C%22codeType%22%3A0%2C%22deviceInfo%22%3A%223%22%2C%22direction%22%3A1%2C%22expireDate%22%3A%22expireDate%22%2C%22extendData%22%3A%22extendData%22%2C%22parkingId%22%3A%223504%22%2C%22plNo%22%3A%22B1504020C7%22%2C%22salt%22%3A%222%22%2C%22sign%22%3A%224%22%2C%22sign_type%22%3A%22md5%22%2C%22terminalSource%22%3A%227%22%2C%22token%22%3A%22666%22%7D&needPay=true | |
65 | +//动态码 | |
66 | +http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/dynCodePay.html?codeType=2&isNeedPay=1&orderId=101536977652977254400&parkName=%E4%B8%87%E8%BE%BE%E5%81%9C%E8%BD%A6%E5%9C%BA&parkCode=a001&inparktime=2018-12-26%2000%3A00%3A00&outtime=2018-12-26%2010%3A00%3A00&staytime=360&orderFee=100&plateno=%E8%92%99D3C187 | |
77 | 67 | \ No newline at end of file | ... | ... |
dynCodePay.html
... | ... | @@ -13,10 +13,10 @@ |
13 | 13 | <meta http-equiv="Cache-control" content="no-cache"> |
14 | 14 | <meta http-equiv="Cache" content="no-cache"> |
15 | 15 | <meta http-equiv="Expires" content="0"> |
16 | - <link rel="stylesheet" href="css/index.css?v=0.10"> | |
17 | - <script src="config.js?v=0.10"></script> | |
18 | - <script src="js/common.js?v=0.10"></script> | |
19 | - <script src="js/dynCodePay.js?v=0.10"></script> | |
16 | + <link rel="stylesheet" href="css/index.css?v=0.1"> | |
17 | + <script src="config.js?v=0.1"></script> | |
18 | + <script src="js/common.js?v=0.12"></script> | |
19 | + <script src="js/dynCodePay.js?v=0.12"></script> | |
20 | 20 | <!--<script src="config.js"></script>--> |
21 | 21 | <!-- |
22 | 22 | Notice the use of %PUBLIC_URL% in the tags above. | ... | ... |
js/billCodePay.js
... | ... | @@ -21,28 +21,30 @@ window.onload = function () { |
21 | 21 | var wx = document.getElementById("rowWxPay"); |
22 | 22 | ali.onclick = webAppClass.aliClick; |
23 | 23 | wx.onclick = webAppClass.wxClick; |
24 | - $btnObj.onclick = webAppClass.okClick; | |
24 | + $btnObj.onclick = webAppClass.okClick;//确认支付按钮 | |
25 | 25 | document.getElementById("payTip").innerHTML = ""; |
26 | 26 | //参数 |
27 | 27 | var tmpURLparams = getQueryString(window.location); |
28 | - if (tmpURLparams != null) { | |
29 | - //设置UI参数 | |
30 | - //webAppClass.setUI(webAppParams); | |
31 | - webAppClass.init(tmpURLparams); | |
32 | - } else { | |
33 | - alertMsg("没有接收到url参数信息"); | |
34 | - } | |
35 | - | |
36 | - //获取微信code | |
37 | - //webAppClass.getCode(); | |
28 | + | |
29 | + //当前浏览器环境 | |
38 | 30 | var state = clientBrowserEx(); |
39 | 31 | if (state == "wxPay") { |
32 | + //wx先获取code, 在获取订单 | |
40 | 33 | webAppCode = webAppClass.getCode(); |
34 | + } else { | |
35 | + if (tmpURLparams != null) { | |
36 | + //设置UI参数 | |
37 | + //webAppClass.setUI(webAppParams); | |
38 | + webAppClass.init(tmpURLparams); | |
39 | + } else { | |
40 | + alertMsg("没有接收到url参数信息"); | |
41 | + } | |
41 | 42 | } |
42 | 43 | } |
43 | 44 | /**/ |
44 | 45 | var webAppClass = { |
45 | 46 | //appid={0}&lotId={1}&payConfigId={2}&receiptNo= |
47 | + //初始化获取订单 | |
46 | 48 | init: function (params) { |
47 | 49 | var urlParams = params; |
48 | 50 | var newParams = urlParams || {}; |
... | ... | @@ -70,6 +72,7 @@ var webAppClass = { |
70 | 72 | //window.location.href = "../pay.html?" + queryParams; |
71 | 73 | webAppParams = tmpObj; |
72 | 74 | webAppClass.setUI(tmpObj); |
75 | + countDownTime("countDownTime");//订单支付倒计时 | |
73 | 76 | } else { |
74 | 77 | var tipStr = "无需缴费,欢迎下次光临"; |
75 | 78 | alertMsg(tipStr); |
... | ... | @@ -88,14 +91,41 @@ var webAppClass = { |
88 | 91 | $btnLoad.style.display = "none"; |
89 | 92 | }); |
90 | 93 | }, |
91 | - //OK | |
94 | + //1:先获取微信code; 2:然后获取订单信息 | |
95 | + getCode: function () { | |
96 | + var appID = appWxID; | |
97 | + var code = getUrlParam('code'); | |
98 | + var local = window.location.href; | |
99 | + if (code == null || code == "") { | |
100 | + //alert(code); | |
101 | + window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appID + '&redirect_uri=' + encodeURIComponent(local) + '&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect' | |
102 | + } else { | |
103 | + //alert(code); | |
104 | + var tmpURLparams = getQueryString(window.location); | |
105 | + webAppClass.init(tmpURLparams); | |
106 | + //去掉url中旧code | |
107 | + window.history.replaceState(null, document.title, funcUrlDel("code")); | |
108 | + return code; | |
109 | + } | |
110 | + function getUrlParam(name) { | |
111 | + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | |
112 | + var r = window.location.search.substr(1).match(reg) | |
113 | + if (r != null) return unescape(r[2]) | |
114 | + return null | |
115 | + } | |
116 | + }, | |
117 | + //OK按钮 | |
92 | 118 | okClick: function (ev) { |
93 | 119 | document.getElementById("payTip").innerHTML = ""; |
94 | 120 | if (webAppParams == null) { |
95 | - alertMsg("暂无订单信息");return; | |
121 | + alertMsg("暂无订单信息"); return; | |
96 | 122 | } |
97 | - //先校验停车费用后缴费提交 | |
98 | - webAppClass.checkParkCost(); | |
123 | + //[方式一]先校验停车费用后缴费提交 | |
124 | + //webAppClass.checkParkCost(); | |
125 | + //[方式二,倒计时支付] | |
126 | + $btnObj.style.display = "none"; | |
127 | + $btnLoad.style.display = "block"; | |
128 | + webAppClass.okPay(webAppParams);//唤醒支付 | |
99 | 129 | }, |
100 | 130 | //校验该订单当前支付时的费用(排除扫描订单后不支付时长) |
101 | 131 | checkParkCost: function () { |
... | ... | @@ -117,6 +147,8 @@ var webAppClass = { |
117 | 147 | webAppClass.okPay(tmpObj);//唤醒支付 |
118 | 148 | } else { |
119 | 149 | alertMsg("没有找到相应订单"); |
150 | + $btnLoad.style.display = "none"; | |
151 | + $btnObj.style.display = "block"; | |
120 | 152 | } |
121 | 153 | } else {//其他情况如【该卡号场内已存在】 |
122 | 154 | $btnLoad.style.display = "none"; |
... | ... | @@ -141,7 +173,7 @@ var webAppClass = { |
141 | 173 | var clientType = clientBrowserEx(); |
142 | 174 | switch (clientType) { |
143 | 175 | case "wxPay"://微信[内置浏览器] |
144 | - webAppClass.payAjaxJDK(orderID); | |
176 | + webAppClass.payAjaxJDK(orderID); | |
145 | 177 | console.log("wxPay");//微信支付 |
146 | 178 | break; |
147 | 179 | case "aliPay"://支付宝 |
... | ... | @@ -185,25 +217,7 @@ var webAppClass = { |
185 | 217 | break; |
186 | 218 | } |
187 | 219 | }, |
188 | - getCode: function () { | |
189 | - var appID = appWxID; | |
190 | - var code = getUrlParam('code'); | |
191 | - var local = window.location.href; | |
192 | - //alert("local:" + local); | |
193 | - if (code == null || code === '') { | |
194 | - //alert(code); | |
195 | - window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appID + '&redirect_uri=' + encodeURIComponent(local) + '&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect' | |
196 | - } else { | |
197 | - //alert(code); | |
198 | - return code; | |
199 | - } | |
200 | - function getUrlParam(name) { | |
201 | - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | |
202 | - var r = window.location.search.substr(1).match(reg) | |
203 | - if (r != null) return unescape(r[2]) | |
204 | - return null | |
205 | - } | |
206 | - }, | |
220 | + | |
207 | 221 | //Ali |
208 | 222 | aliClick: function (ev) { |
209 | 223 | console.log("AliClick"); |
... | ... | @@ -295,11 +309,21 @@ var webAppClass = { |
295 | 309 | if (res.code == 0) { |
296 | 310 | //alert(res.data); |
297 | 311 | webAppClass.getPayParams(res.data, orderID); |
298 | - } else { | |
312 | + } | |
313 | + else if (res.code == 40163) { | |
314 | + alertMsg("请您重新扫码!"); | |
315 | + $btnLoad.style.display = "none"; | |
316 | + $btnObj.style.display = "block"; | |
317 | + } | |
318 | + else { | |
299 | 319 | alertMsg(res.message); |
320 | + $btnLoad.style.display = "none"; | |
321 | + $btnObj.style.display = "block"; | |
300 | 322 | } |
301 | 323 | }, function (err) { |
302 | 324 | console.log("网络地址出错..." + openIdUrl); |
325 | + $btnLoad.style.display = "none"; | |
326 | + $btnObj.style.display = "block"; | |
303 | 327 | }); |
304 | 328 | //2:获取支付参数 |
305 | 329 | //function getPayParams(openId) { |
... | ... | @@ -388,7 +412,7 @@ var webAppClass = { |
388 | 412 | alertMsg(res.message); |
389 | 413 | } |
390 | 414 | }, function (err) { |
391 | - console.log("网络地址出错...");alertMsg("网络地址出错..."); | |
415 | + console.log("网络地址出错..."); alertMsg("网络地址出错..."); | |
392 | 416 | $btnLoad.style.display = "none"; |
393 | 417 | btnOBj.style.display = "block"; |
394 | 418 | }); |
... | ... | @@ -411,7 +435,7 @@ var webAppClass = { |
411 | 435 | $discountDesc = getObjectByID("discountDesc"),//8折优惠折扣费用 |
412 | 436 | $discountFee = getObjectByID("discountFee");//优惠金额 |
413 | 437 | |
414 | - if (params != null && params!="") { | |
438 | + if (params != null && params != "") { | |
415 | 439 | var price = keepTwoDecimalFull((params.orderFee / 100));//(params.orderFee / 100); |
416 | 440 | $carNum.innerHTML = params.plateno;//手机号 |
417 | 441 | $orderNum.innerHTML = params.orderId;//订单号 |
... | ... | @@ -423,7 +447,7 @@ var webAppClass = { |
423 | 447 | $parkName.innerHTML = params.parkName; |
424 | 448 | $inparktime.innerHTML = params.inparktime; |
425 | 449 | $staytime.innerHTML = formatSeconds(params.staytime); |
426 | - | |
450 | + | |
427 | 451 | $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用 |
428 | 452 | $paid.innerHTML = params.paid; |
429 | 453 | $discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额 |
... | ... | @@ -445,4 +469,4 @@ var webAppClass = { |
445 | 469 | $payDetail.style.height = "55px"; |
446 | 470 | } |
447 | 471 | } |
448 | -} | |
449 | 472 | \ No newline at end of file |
473 | +} | ... | ... |
js/common.js
1 | -/*自定义异步请求*/ | |
1 | +/* | |
2 | + state | |
3 | +*/ | |
4 | +var appState = { | |
5 | + defaultTime: 120,//默认2分钟倒计时 | |
6 | + countDownTime_timer: null,//支付倒计时 | |
7 | + codeNullTip: "微信授权失败,请您尝试重新扫码 !",//code获取失败提示语 | |
8 | + expandField_1: null,//扩展字段1-备用 | |
9 | + expandObj_1: null,//扩展字段1-备用 | |
10 | +} | |
11 | + | |
12 | +/*自定义异步请求*/ | |
2 | 13 | function ajax() { |
3 | 14 | var ajaxData = { |
4 | 15 | type: (arguments[0].type || "GET").toUpperCase(), |
... | ... | @@ -236,3 +247,42 @@ function clientBrowserEx() { |
236 | 247 | } |
237 | 248 | |
238 | 249 | |
250 | +/*支付倒计时 @id*/ | |
251 | +function countDownTime(id) { | |
252 | + $obj = getObjectByID(id); | |
253 | + getObjectByID("headTip").style.display = "block"; | |
254 | + var count = appState.defaultTime; | |
255 | + appState.countDownTime_timer = setInterval(function () { | |
256 | + if (count==0) { | |
257 | + clearInterval(appState.countDownTime_timer); | |
258 | + appState.countDownTime_timer = null; | |
259 | + $obj.innerHTML = count + "秒"; | |
260 | + //删除code后刷新 | |
261 | + window.location.href = funcUrlDel("code"); | |
262 | + } else { | |
263 | + --count; | |
264 | + $obj.innerHTML = count + "秒"; | |
265 | + } | |
266 | + }, 1000); | |
267 | +} | |
268 | + | |
269 | +/*删除url中某个参数*/ | |
270 | +function funcUrlDel(name) { | |
271 | + var loca = window.location; | |
272 | + var baseUrl = loca.origin + loca.pathname + "?"; | |
273 | + var query = loca.search.substr(1); | |
274 | + if (query.indexOf(name) > -1) { | |
275 | + var obj = {} | |
276 | + var arr = query.split("&"); | |
277 | + for (var i = 0; i < arr.length; i++) { | |
278 | + arr[i] = arr[i].split("="); | |
279 | + obj[arr[i][0]] = arr[i][1]; | |
280 | + }; | |
281 | + delete obj[name]; | |
282 | + var url = baseUrl + JSON.stringify(obj).replace(/[\"\{\}]/g, "").replace(/\:/g, "=").replace(/\,/g, "&"); | |
283 | + return url | |
284 | + } else { | |
285 | + return loca.href; | |
286 | + } | |
287 | +} | |
288 | + | ... | ... |
js/dynCodePay.js
... | ... | @@ -184,6 +184,11 @@ var webAppClass = { |
184 | 184 | //0:页面初始化获取code[webAppCode] |
185 | 185 | var codeParams = { code: webAppCode, appId: appWxID }; |
186 | 186 | var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer; |
187 | + //debugger; | |
188 | + if (webAppCode == null || webAppCode == "") { | |
189 | + alertMsg(appState.codeNullTip); | |
190 | + return; | |
191 | + } | |
187 | 192 | $btnObj.style.display = "none"; $btnLoad.style.display = "block"; |
188 | 193 | //1:有code获取OpenId |
189 | 194 | postRequest(openIdUrl, codeParams, function (res) { |
... | ... | @@ -191,7 +196,12 @@ var webAppClass = { |
191 | 196 | //alert(JSON.stringify(res)); |
192 | 197 | if (res.code == 0) { |
193 | 198 | webAppClass.getPayParams(res.data, orderID); |
194 | - } else { | |
199 | + } | |
200 | + else if (res.code == 40163) {//code been used, hints | |
201 | + alertMsg(appState.codeNullTip); | |
202 | + console.log(res.message); | |
203 | + } | |
204 | + else { | |
195 | 205 | alertMsg(res.message); |
196 | 206 | } |
197 | 207 | }, function (err) { | ... | ... |
js/pay.js
... | ... | @@ -55,7 +55,7 @@ var webAppClass = { |
55 | 55 | checkParkCost: function () { |
56 | 56 | $btnObj.style.display = "none"; |
57 | 57 | $btnLoad.style.display = "block"; |
58 | - if (typeof (webAppParams.queryOrderInfo) == "undefined") {//没有queryOrderInfo返回第一页 | |
58 | + if (typeof(webAppParams.queryOrderInfo) == "undefined") {//没有queryOrderInfo返回第一页 | |
59 | 59 | window.history.back(-1); |
60 | 60 | } |
61 | 61 | var tmpParams = JSON.parse(webAppParams.queryOrderInfo); |
... | ... | @@ -101,6 +101,13 @@ var webAppClass = { |
101 | 101 | //wxParams.orderId = orderID; |
102 | 102 | //wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 |
103 | 103 | //wxParams.terminalSource = 3;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 |
104 | + //debugger; | |
105 | + if (webAppCode == null || webAppCode == "") {//code检测 | |
106 | + alertMsg(appState.codeNullTip); | |
107 | + $btnObj.style.display = "block"; | |
108 | + $btnLoad.style.display = "none"; | |
109 | + return; | |
110 | + } | |
104 | 111 | webAppClass.payAjaxJDK(orderID); |
105 | 112 | console.log("wxPay");//微信支付 |
106 | 113 | break; |
... | ... | @@ -257,18 +264,29 @@ var webAppClass = { |
257 | 264 | //0:页面初始化获取code[webAppCode] |
258 | 265 | var codeParams = { code: webAppCode, appId: appWxID }; |
259 | 266 | var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer; |
260 | - //alert(openIdUrl); | |
267 | + | |
261 | 268 | //1:有code获取OpenId |
262 | 269 | postRequest(openIdUrl, codeParams, function (res) { |
263 | 270 | //alert(JSON.stringify(res)); |
264 | 271 | if (res.code == 0) { |
265 | 272 | //alert(res.data); |
266 | 273 | webAppClass.getPayParams(res.data, orderID); |
267 | - } else { | |
274 | + } | |
275 | + else if (res.code == 40163) {//code been used, hints[重复code问题] | |
276 | + alertMsg(appState.codeNullTip); | |
277 | + console.log(res.message); | |
278 | + $btnObj.style.display = "block"; | |
279 | + $btnLoad.style.display = "none"; | |
280 | + } | |
281 | + else { | |
268 | 282 | alertMsg(res.message); |
283 | + $btnObj.style.display = "block"; | |
284 | + $btnLoad.style.display = "none"; | |
269 | 285 | } |
270 | 286 | }, function (err) { |
271 | 287 | console.log("网络地址出错..." + openIdUrl); |
288 | + $btnObj.style.display = "block"; | |
289 | + $btnLoad.style.display = "none"; | |
272 | 290 | }); |
273 | 291 | //2:获取支付参数 |
274 | 292 | //function getPayParams(openId) { | ... | ... |
pay.html
... | ... | @@ -15,9 +15,9 @@ |
15 | 15 | <meta http-equiv="Expires" content="0"> |
16 | 16 | <link rel="stylesheet" href="css/index.css?v=0.1"> |
17 | 17 | <script src="config.js?v=0.1"></script> |
18 | - <script src="js/common.js?v=0.1"></script> | |
18 | + <script src="js/common.js?v=0.12"></script> | |
19 | 19 | <!--<script src="js/jweixin-1.0.0.js?v=0.1"></script>--> |
20 | - <script src="js/pay.js?v=0.110"></script> | |
20 | + <script src="js/pay.js?v=0.12"></script> | |
21 | 21 | <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>--> |
22 | 22 | <!--<script src="config.js"></script>--> |
23 | 23 | <!-- | ... | ... |