Commit dbd86cb20e35fda390901d676d9dadec5741f124
1 parent
a79a8c53
add 0元支付功能
Showing
7 changed files
with
218 additions
and
55 deletions
billCodePay.html
... | ... | @@ -68,6 +68,19 @@ |
68 | 68 | font-size: 14px; |
69 | 69 | color: #EB453B; |
70 | 70 | } |
71 | + .paySuccess{ | |
72 | + width: 100%; | |
73 | + height: 100%; | |
74 | + text-align: center; | |
75 | + line-height: 100px; | |
76 | + font-size: 20px; | |
77 | + color: #fff; | |
78 | + background: rgba(0,0,0,.7); | |
79 | + position: fixed; | |
80 | + top:0; | |
81 | + left: 0; | |
82 | + display: none; | |
83 | + } | |
71 | 84 | </style> |
72 | 85 | </head> |
73 | 86 | <body> |
... | ... | @@ -130,7 +143,7 @@ |
130 | 143 | <img src="img/loading.gif" id="loading" style="display: none;" /> |
131 | 144 | </footer> |
132 | 145 | <section id="payTip" style="padding: 5px;margin-top:5px; color: #3385ff; font-size: 14px; "></section> |
133 | - | |
146 | + <div class="paySuccess" id="paySuccess">支付成功,请立即离场</div> | |
134 | 147 | <!-- |
135 | 148 | This HTML file is a template. |
136 | 149 | If you open it directly in the browser, you will see an empty page. | ... | ... |
config.js
dynCodePay.html
... | ... | @@ -66,6 +66,19 @@ |
66 | 66 | font-size: 14px; |
67 | 67 | color: #EB453B; |
68 | 68 | } |
69 | + .paySuccess{ | |
70 | + width: 100%; | |
71 | + height: 100%; | |
72 | + text-align: center; | |
73 | + line-height: 100px; | |
74 | + font-size: 20px; | |
75 | + color: #fff; | |
76 | + background: rgba(0,0,0,.7); | |
77 | + position: fixed; | |
78 | + top:0; | |
79 | + left: 0; | |
80 | + display: none; | |
81 | + } | |
69 | 82 | </style> |
70 | 83 | </head> |
71 | 84 | <body> |
... | ... | @@ -127,7 +140,7 @@ |
127 | 140 | <img src="img/loading.gif" id="loading" style="display: none;" /> |
128 | 141 | </footer> |
129 | 142 | <!--<section id="payTip" style="padding: 5px;margin-top:5px; color: #3385ff; font-size: 14px; "></section>--> |
130 | - | |
143 | + <div class="paySuccess" id="paySuccess">支付成功,请立即离场</div> | |
131 | 144 | </body> |
132 | 145 | |
133 | 146 | </html> | ... | ... |
js/billCodePay.js
... | ... | @@ -8,7 +8,11 @@ var $btnObj = null; |
8 | 8 | var $btnLoad = null; |
9 | 9 | var webAppCode = null;//如果是微信,先获取微信code |
10 | 10 | var flag = 0; |
11 | -window.onload = function () { | |
11 | +function trim(str) { | |
12 | + | |
13 | + return str.replace(/(^\s*)|(\s*$)/g, ""); | |
14 | +} | |
15 | + window.onload = function () { | |
12 | 16 | //var root = document.getElementById("root"); |
13 | 17 | $btnObj = document.getElementById("btnPayOK"); |
14 | 18 | $btnLoad = document.getElementById("loading"); |
... | ... | @@ -130,7 +134,45 @@ var webAppClass = { |
130 | 134 | //[方式二,倒计时支付] |
131 | 135 | $btnObj.style.display = "none"; |
132 | 136 | $btnLoad.style.display = "block"; |
133 | - webAppClass.okPay(webAppParams);//唤醒支付 | |
137 | + var val = document.getElementById("sumMoney").innerText; | |
138 | + var couponPersonId = trim(document.getElementById("discountBox").value); | |
139 | + var url = webAppRoot + window.webAppH5.zeroPayServer; | |
140 | + var discountParams = { | |
141 | + payOrderType : 101, | |
142 | + terminalSource:7, | |
143 | + orderId: webAppParams.orderId, | |
144 | + couponPersonId:couponPersonId, | |
145 | + app_id: '123', | |
146 | + sign_type: '123', | |
147 | + salt: '123', | |
148 | + deviceInfo: '123', | |
149 | + sign: '123', | |
150 | + } | |
151 | + if(val == '0.00' || val=='0'){ | |
152 | + postRequest(url, discountParams, function (res) { | |
153 | + console.log(res) | |
154 | + if(res.code==0){ | |
155 | + document.getElementById("paySuccess").style.display = 'block' | |
156 | + // | |
157 | + // document.getElementById("sumMoney").innerHTML = (res.data.orderFee/100) | |
158 | + // document.getElementById("discountTip").innerHTML = res.data.couponDescribe | |
159 | + // document.getElementById("discountFee").innerHTML = (res.data.discountFee/100) | |
160 | + // document.getElementById("discountDesc").style.display="none" | |
161 | + // $btnLoad.style.display = "none"; | |
162 | + // $btnObj.style.display = "block"; | |
163 | + // document.getElementById("discountBox").setAttribute('readonly','readonly'); | |
164 | + // flag = 1 | |
165 | + }else{ | |
166 | + alert(res.message) | |
167 | + // $discountBtn.disabled = false | |
168 | + // document.getElementById("discountTip").innerHTML = res.message | |
169 | + } | |
170 | + }) | |
171 | + }else{ | |
172 | + webAppClass.okPay(webAppParams);//唤醒支付 | |
173 | + } | |
174 | + | |
175 | + | |
134 | 176 | }, |
135 | 177 | //优惠券兑换 |
136 | 178 | codediscountClick:function(tmpObj){ | ... | ... |
js/dynCodePay.js
... | ... | @@ -9,6 +9,10 @@ var $btnObj = null; |
9 | 9 | var $btnLoad = null; |
10 | 10 | var webAppCode = null;//如果是微信,先获取微信code |
11 | 11 | // var flag = 0; |
12 | +function trim(str) { | |
13 | + | |
14 | + return str.replace(/(^\s*)|(\s*$)/g, ""); | |
15 | +} | |
12 | 16 | window.onload = function () { |
13 | 17 | $btnObj = getObjectByID("btnPayOK"); |
14 | 18 | $btnLoad = getObjectByID("loading"); |
... | ... | @@ -108,8 +112,46 @@ var webAppClass = { |
108 | 112 | if (webAppParams == null) { |
109 | 113 | alertMsg("暂无订单信息");return; |
110 | 114 | } |
111 | - //支付方式判断 | |
112 | - webAppClass.okPay(webAppParams); | |
115 | + $btnObj.style.display = "none"; | |
116 | + $btnLoad.style.display = "block"; | |
117 | + var val = document.getElementById("sumMoney").innerText; | |
118 | + var couponPersonId = trim(document.getElementById("discountBox").value); | |
119 | + var url = webAppRoot + window.webAppH5.zeroPayServer; | |
120 | + var discountParams = { | |
121 | + payOrderType : 101, | |
122 | + terminalSource:7, | |
123 | + orderId: webAppParams.orderId, | |
124 | + couponPersonId:couponPersonId, | |
125 | + app_id: '123', | |
126 | + sign_type: '123', | |
127 | + salt: '123', | |
128 | + deviceInfo: '123', | |
129 | + sign: '123', | |
130 | + } | |
131 | + if(val == '0.00' || val=='0'){ | |
132 | + postRequest(url, discountParams, function (res) { | |
133 | + console.log(res) | |
134 | + if(res.code==0){ | |
135 | + document.getElementById("paySuccess").style.display = 'block' | |
136 | + // | |
137 | + // document.getElementById("sumMoney").innerHTML = (res.data.orderFee/100) | |
138 | + // document.getElementById("discountTip").innerHTML = res.data.couponDescribe | |
139 | + // document.getElementById("discountFee").innerHTML = (res.data.discountFee/100) | |
140 | + // document.getElementById("discountDesc").style.display="none" | |
141 | + // $btnLoad.style.display = "none"; | |
142 | + // $btnObj.style.display = "block"; | |
143 | + // document.getElementById("discountBox").setAttribute('readonly','readonly'); | |
144 | + // flag = 1 | |
145 | + }else{ | |
146 | + alert(res.message) | |
147 | + // $discountBtn.disabled = false | |
148 | + // document.getElementById("discountTip").innerHTML = res.message | |
149 | + } | |
150 | + }) | |
151 | + }else{ | |
152 | + webAppClass.okPay(webAppParams);//唤醒支付 | |
153 | + } | |
154 | + | |
113 | 155 | }, |
114 | 156 | |
115 | 157 | //确定支付 | ... | ... |
js/pay.js
... | ... | @@ -202,43 +202,63 @@ var webAppClass = { |
202 | 202 | okPay: function (params) { |
203 | 203 | var orderID = params.orderId;//订单号 |
204 | 204 | //var moneyID = document.getElementById("sumMoney").innerHTML = webAppParams.orderId;//订单号 |
205 | - var root = webAppRoot; | |
206 | - //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器] | |
207 | - var clientType = clientBrowserEx(); | |
208 | - //alert(clientType); | |
209 | - switch (clientType) { | |
210 | - case "wxPay"://微信[内置浏览器] | |
211 | - //var wxPay = webAppH5.wxPayServer; | |
212 | - //var wxParams = webAppH5.comParams; | |
213 | - //wxParams.orderId = orderID; | |
214 | - //wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
215 | - //wxParams.terminalSource = 3;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
216 | - //debugger; | |
217 | - if (webAppCode == null || webAppCode == "") {//code检测 | |
218 | - alertMsg(appState.codeNullTip); | |
219 | - $btnObj.style.display = "block"; | |
220 | - $btnLoad.style.display = "none"; | |
221 | - return; | |
205 | + var val = document.getElementById("sumMoney").innerText; | |
206 | + var couponPersonId = document.getElementById("discountBox").value; | |
207 | + var url = webAppRoot + window.webAppH5.zeroPayServer; | |
208 | + var discountParams = { | |
209 | + payOrderType : 101, | |
210 | + terminalSource:7, | |
211 | + orderId: webAppParams.orderId, | |
212 | + couponPersonId:couponPersonId, | |
213 | + app_id: '123', | |
214 | + sign_type: '123', | |
215 | + salt: '123', | |
216 | + deviceInfo: '123', | |
217 | + sign: '123', | |
218 | + } | |
219 | + if(val == '0.00' || val=='0'){ | |
220 | + postRequest(url, discountParams, function (res) { | |
221 | + console.log(res) | |
222 | + if(res.code==0){ | |
223 | + document.getElementById("paySuccess").style.display = 'block' | |
224 | + // | |
225 | + // document.getElementById("sumMoney").innerHTML = (res.data.orderFee/100) | |
226 | + // document.getElementById("discountTip").innerHTML = res.data.couponDescribe | |
227 | + // document.getElementById("discountFee").innerHTML = (res.data.discountFee/100) | |
228 | + // document.getElementById("discountDesc").style.display="none" | |
229 | + // $btnLoad.style.display = "none"; | |
230 | + // $btnObj.style.display = "block"; | |
231 | + // document.getElementById("discountBox").setAttribute('readonly','readonly'); | |
232 | + // flag = 1 | |
233 | + }else{ | |
234 | + alert(res.message) | |
235 | + // $discountBtn.disabled = false | |
236 | + // document.getElementById("discountTip").innerHTML = res.message | |
222 | 237 | } |
223 | - webAppClass.payAjaxJDK(orderID); | |
224 | - console.log("wxPay");//微信支付 | |
225 | - break; | |
226 | - case "aliPay"://支付宝 | |
227 | - console.log("aliPay"); | |
228 | - //订单号 | |
229 | - var obj = {}; | |
230 | - //this.payAjax(url, { orderId: "11111", price: 0.01 }); | |
231 | - var aliPay = webAppH5.aliPayServer; | |
232 | - var aliParams = webAppH5.comParams; | |
233 | - aliParams.orderId = orderID; | |
234 | - aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
235 | - aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
236 | - aliParams.paySrcType = 101;//101停车支付 | |
237 | - webAppClass.payAliAjax(root + aliPay, aliParams); | |
238 | - break; | |
239 | - default://第三方浏览器other | |
240 | - //默认支付宝 | |
241 | - if (document.getElementById("aliPay").checked) { | |
238 | + }) | |
239 | + }else { | |
240 | + var root = webAppRoot; | |
241 | + //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器] | |
242 | + var clientType = clientBrowserEx(); | |
243 | + //alert(clientType); | |
244 | + switch (clientType) { | |
245 | + case "wxPay"://微信[内置浏览器] | |
246 | + //var wxPay = webAppH5.wxPayServer; | |
247 | + //var wxParams = webAppH5.comParams; | |
248 | + //wxParams.orderId = orderID; | |
249 | + //wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
250 | + //wxParams.terminalSource = 3;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
251 | + //debugger; | |
252 | + if (webAppCode == null || webAppCode == "") {//code检测 | |
253 | + alertMsg(appState.codeNullTip); | |
254 | + $btnObj.style.display = "block"; | |
255 | + $btnLoad.style.display = "none"; | |
256 | + return; | |
257 | + } | |
258 | + webAppClass.payAjaxJDK(orderID); | |
259 | + console.log("wxPay");//微信支付 | |
260 | + break; | |
261 | + case "aliPay"://支付宝 | |
242 | 262 | console.log("aliPay"); |
243 | 263 | //订单号 |
244 | 264 | var obj = {}; |
... | ... | @@ -250,19 +270,36 @@ var webAppClass = { |
250 | 270 | aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 |
251 | 271 | aliParams.paySrcType = 101;//101停车支付 |
252 | 272 | webAppClass.payAliAjax(root + aliPay, aliParams); |
253 | - } else {//微信页面支付 | |
254 | - var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096"; | |
255 | - //window.location.href = url; | |
256 | - var wxPay = webAppH5.wxPayServer; | |
257 | - var wxParams = webAppH5.comParams; | |
258 | - wxParams.orderId = orderID; | |
259 | - wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
260 | - wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
261 | - webAppClass.payAjax(root + wxPay, wxParams); | |
262 | - console.log("wxPay"); | |
263 | - } | |
264 | - break; | |
273 | + break; | |
274 | + default://第三方浏览器other | |
275 | + //默认支付宝 | |
276 | + if (document.getElementById("aliPay").checked) { | |
277 | + console.log("aliPay"); | |
278 | + //订单号 | |
279 | + var obj = {}; | |
280 | + //this.payAjax(url, { orderId: "11111", price: 0.01 }); | |
281 | + var aliPay = webAppH5.aliPayServer; | |
282 | + var aliParams = webAppH5.comParams; | |
283 | + aliParams.orderId = orderID; | |
284 | + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
285 | + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
286 | + aliParams.paySrcType = 101;//101停车支付 | |
287 | + webAppClass.payAliAjax(root + aliPay, aliParams); | |
288 | + } else {//微信页面支付 | |
289 | + var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096"; | |
290 | + //window.location.href = url; | |
291 | + var wxPay = webAppH5.wxPayServer; | |
292 | + var wxParams = webAppH5.comParams; | |
293 | + wxParams.orderId = orderID; | |
294 | + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号 | |
295 | + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付 | |
296 | + webAppClass.payAjax(root + wxPay, wxParams); | |
297 | + console.log("wxPay"); | |
298 | + } | |
299 | + break; | |
300 | + } | |
265 | 301 | } |
302 | + | |
266 | 303 | }, |
267 | 304 | |
268 | 305 | getCode: function () { | ... | ... |
pay.html
... | ... | @@ -68,6 +68,19 @@ |
68 | 68 | font-size: 14px; |
69 | 69 | color: #EB453B; |
70 | 70 | } |
71 | + .paySuccess{ | |
72 | + width: 100%; | |
73 | + height: 100%; | |
74 | + text-align: center; | |
75 | + line-height: 100px; | |
76 | + font-size: 20px; | |
77 | + color: #fff; | |
78 | + background: rgba(0,0,0,.7); | |
79 | + position: fixed; | |
80 | + top:0; | |
81 | + left: 0; | |
82 | + display: none; | |
83 | + } | |
71 | 84 | </style> |
72 | 85 | </head> |
73 | 86 | <body> |
... | ... | @@ -129,7 +142,7 @@ |
129 | 142 | <img src="img/loading.gif" id="loading" style="display: none;" /> |
130 | 143 | </footer> |
131 | 144 | <section id="payTip" style="padding: 10px;margin-top:5px; color: #3385ff; font-size: 14px; "></section> |
132 | - | |
145 | + <div class="paySuccess" id="paySuccess">支付成功,请立即离场</div> | |
133 | 146 | <!-- |
134 | 147 | This HTML file is a template. |
135 | 148 | If you open it directly in the browser, you will see an empty page. | ... | ... |