Blame view

js/pay.js 29.4 KB
afc9e308   liuqimichale   银联支付
1
  
f9cd3bb6   liuqimichale   初始化项目
2
3
4
5
  var webAppParams = null;
  var $btnObj = null;
  var $btnLoad = null;
  var flag = 0;
cd917be6   liuqimichale   0元支付
6
7
  var appWxID = getQueryString(window.location).appId;
  // var appWxID = 'wx945eccc8163fd75b'
f9cd3bb6   liuqimichale   初始化项目
8
9
10
11
12
13
14
15
  var webAppCode = null;//如果是微信,先获取微信code
  //var $btnLoad = document.getElementById("loading");
  window.onload = function () {
      //var root = document.getElementById("root");
      $btnObj = document.getElementById("btnPayOK");
      $btnLoad = document.getElementById("loading");
  
      $discountBtn = document.getElementById("discountBtn");
f9cd3bb6   liuqimichale   初始化项目
16
17
18
19
20
21
22
23
      var webRoot = window.location.href;
      //设置当前客户端浏览器模式[微信、支付宝、其他]
      webAppClass.clientBrowser();
      //绑定事件
      var ali = document.getElementById("rowAliPay");
      var wx = document.getElementById("rowWxPay");
      ali.onclick = webAppClass.aliClick;
      wx.onclick = webAppClass.wxClick;
b9e554af   liuqimichale   支付页面
24
25
      //$btnObj.onclick = webAppClass.okClick;
  
c3341558   xiejianpeng   格式化
26
      $btnObj.onclick = webAppClass.okPay;
b9e554af   liuqimichale   支付页面
27
  
f9cd3bb6   liuqimichale   初始化项目
28
29
30
      document.getElementById("payTip").innerHTML = "";
      //参数
      webAppParams = getQueryString(window.location);
c3341558   xiejianpeng   格式化
31
      if (webAppParams != null) {
b244e45c   liuqimichale   提示 需要支付的车牌号是否正确
32
          console.log(webAppParams.carNumber)
0e3e535a   liuqimichale   list 车牌号确定
33
  
b244e45c   liuqimichale   提示 需要支付的车牌号是否正确
34
  
f9cd3bb6   liuqimichale   初始化项目
35
          //设置UI参数
0e3e535a   liuqimichale   list 车牌号确定
36
          webAppClass.setUI(webAppParams);
f9cd3bb6   liuqimichale   初始化项目
37
38
39
40
41
42
43
44
45
46
      } else {
          alertMsg("暂无订单信息");
      }
  
      //获取微信code
      //webAppClass.getCode();
      var state = clientBrowserEx();
      if (state == "wxPay") {
          webAppCode = webAppClass.getCode();
      }
33e6793f   liuqimichale   支付页面
47
      // $discountBtn.onclick = webAppClass.discountClick;
f9cd3bb6   liuqimichale   初始化项目
48
49
50
51
  }
  /**/
  var webAppClass = {
      //优惠券兑换
c3341558   xiejianpeng   格式化
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
      codediscountClick: function (tmpObj) {
          discountVal = document.getElementById("discountBox").value;
          // console.log(discountVal)
          // console.log(discountVal.length)
          if (discountVal.length > 0) {
              $btnObj.style.display = "none";
              $btnLoad.style.display = "block";
              $discountBtn.disabled = true
              console.log(webAppParams.orderId)
              var url = webAppRoot + window.webAppH5.discountServer;
              var discountParams = {
                  app_id: '1',
                  salt: '1',
                  deviceInfo: '1',
                  sign_type: '1',
                  sign: '1',
                  token: '1',
                  terminalSource: 7,
                  orderId: webAppParams.orderId,
                  cardNo: discountVal,
                  codeType: 0
              }
              postRequest(url, discountParams, function (res) {
                  console.log(res)
                  if (res.code == 0) {
  
                      document.getElementById("sumMoney").innerHTML = (res.data.orderFee / 100)
                      document.getElementById("discountTip").innerHTML = res.data.couponDescribe
                      document.getElementById("discountFee").innerHTML = (res.data.discountFee / 100)
                      document.getElementById("discountDesc").style.display = "none"
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
                      flag = 1;
                      webAppClass.okPay(tmpObj);//唤醒支付
                  } else {
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
                      $discountBtn.disabled = false;
                      document.getElementById("discountTip").innerHTML = res.message
                  }
              })
f9cd3bb6   liuqimichale   初始化项目
93
  
c3341558   xiejianpeng   格式化
94
95
          } else {
              return
f9cd3bb6   liuqimichale   初始化项目
96
          }
c3341558   xiejianpeng   格式化
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
      },
      discountClick: function () {
          discountVal = document.getElementById("discountBox").value;
          // console.log(discountVal)
          // console.log(discountVal.length)
          if (discountVal.length > 0) {
              $btnObj.style.display = "none";
              $btnLoad.style.display = "block";
              $discountBtn.disabled = true
              // console.log(webAppParams.orderId);
              if (webAppParams === null || webAppParams === 'null' || webAppParams === undefined) {
                  document.getElementById("discountTip").innerHTML = '缺少参数';
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
                  return false;
              }
              var url = webAppRoot + window.webAppH5.discountServer;
              var discountParams = {
                  app_id: '1',
                  salt: '1',
                  deviceInfo: '1',
                  sign_type: '1',
                  sign: '1',
                  token: '1',
                  terminalSource: 7,
                  orderId: webAppParams.orderId,
                  cardNo: discountVal,
                  codeType: 0
              }
              postRequest(url, discountParams, function (res) {
                  console.log(res)
                  if (res.code == 0) {
  
                      document.getElementById("sumMoney").innerHTML = (res.data.orderFee / 100)
                      document.getElementById("discountTip").innerHTML = res.data.couponDescribe
                      document.getElementById("discountFee").innerHTML = (res.data.discountFee / 100)
                      document.getElementById("discountDesc").style.display = "none"
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
                      document.getElementById("discountBox").setAttribute('readonly', 'readonly');
                      flag = 1
                  } else {
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
                      $discountBtn.disabled = false;
                      document.getElementById("discountTip").innerHTML = res.message
                  }
              })
  
          } else {
f9cd3bb6   liuqimichale   初始化项目
147
148
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
c3341558   xiejianpeng   格式化
149
150
              return false;
          }
f9cd3bb6   liuqimichale   初始化项目
151
152
153
154
155
      },
      //OK
      okClick: function (ev) {
          document.getElementById("payTip").innerHTML = "";
          if (webAppParams == null) {
c3341558   xiejianpeng   格式化
156
157
              alertMsg("暂无订单信息");
              return;
f9cd3bb6   liuqimichale   初始化项目
158
159
160
161
162
163
164
165
          }
          //先校验停车费用后缴费提交
          webAppClass.checkParkCost();
      },
      //校验该订单当前支付时的费用(排除扫描订单后不支付时长)
      checkParkCost: function () {
          $btnObj.style.display = "none";
          $btnLoad.style.display = "block";
c3341558   xiejianpeng   格式化
166
          if (typeof (webAppParams.queryOrderInfo) == "undefined") {//没有queryOrderInfo返回第一页
f9cd3bb6   liuqimichale   初始化项目
167
168
169
170
171
172
173
174
175
176
              window.history.back(-1);
          }
          var tmpParams = JSON.parse(webAppParams.queryOrderInfo);
          var url = webAppRoot + window.webAppH5.comServer;
          postRequest(url, tmpParams, function (res) {
              //btnObj.style.display = "block"; //$btnLoad.style.display = "none";
              //$btnObj.style.display = "block";
              if (res.code == 0) {//进场
                  var tmpObj = res.data;
                  if (tmpObj) {
c3341558   xiejianpeng   格式化
177
178
179
180
181
182
                      if (flag == 1) {
                          webAppClass.codediscountClick(tmpObj);
                      } else {
                          webAppClass.setUI(tmpObj);
                          webAppParams = tmpObj;//重新赋值
                          webAppClass.okPay(tmpObj);//唤醒支付
f9cd3bb6   liuqimichale   初始化项目
183
184
                      }
  
c3341558   xiejianpeng   格式化
185
186
                      console.log(tmpObj)
                      // webAppClass.okPay(tmpObj);//唤醒支付
f9cd3bb6   liuqimichale   初始化项目
187
188
189
190
191
192
                  } else {
                      alertMsg("没有找到相应订单");
                  }
              } else {//其他情况如【该卡号场内已存在】
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
c3341558   xiejianpeng   格式化
193
194
                  console.log(res.message);
                  alertMsg(res.message);
f9cd3bb6   liuqimichale   初始化项目
195
196
197
198
199
200
201
202
203
204
205
206
              }
          }, function (err) {
              console.log("网络服务超时..." + url);
              alertMsg("网络服务超时");
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
              //$btnLoad.style.display = "none";
          });
      },
  
      //确定支付
      okPay: function (params) {
adab27e8   liuqimichale   签名
207
          var orderID = webAppParams.orderId;//订单号
c3341558   xiejianpeng   格式化
208
          // alert(orderID)
f9cd3bb6   liuqimichale   初始化项目
209
210
          //var moneyID = document.getElementById("sumMoney").innerHTML = webAppParams.orderId;//订单号
          var val = document.getElementById("sumMoney").innerText;
b9e554af   liuqimichale   支付页面
211
          //var couponPersonId = document.getElementById("discountBox").value;
f9cd3bb6   liuqimichale   初始化项目
212
          var url = webAppRoot + window.webAppH5.zeroPayServer;
c3341558   xiejianpeng   格式化
213
          var _paySrcType = getQueryString(window.location)._paySrcType
dc07d4e3   liuqimichale   update .gitignore
214
          var _mon = document.getElementById("sumMoney").innerText
adab27e8   liuqimichale   签名
215
  
f9cd3bb6   liuqimichale   初始化项目
216
          var discountParams = {
c3341558   xiejianpeng   格式化
217
218
219
220
221
222
223
              payOrderType: _paySrcType,
              recordArreaInfos: JSON.stringify([{
                  "orderId": webAppParams.orderId,
                  "orderNotPayFee": _mon * 100,
                  "parkId": getQueryString(window.location).parkCode
              }]),
              terminalSource: 7,
f9cd3bb6   liuqimichale   初始化项目
224
              orderId: webAppParams.orderId,
b9e554af   liuqimichale   支付页面
225
              //couponPersonId:couponPersonId,
f9cd3bb6   liuqimichale   初始化项目
226
227
228
229
230
231
              app_id: '123',
              sign_type: '123',
              salt: '123',
              deviceInfo: '123',
              sign: '123',
          }
c3341558   xiejianpeng   格式化
232
          if (val == '0.00' || val == '0') {
f9cd3bb6   liuqimichale   初始化项目
233
234
              postRequest(url, discountParams, function (res) {
                  console.log(res)
c3341558   xiejianpeng   格式化
235
                  if (res.code == 0) {
f9cd3bb6   liuqimichale   初始化项目
236
237
238
239
240
241
242
243
244
245
                      document.getElementById("paySuccess").style.display = 'block'
                      //
                      // document.getElementById("sumMoney").innerHTML = (res.data.orderFee/100)
                      // document.getElementById("discountTip").innerHTML = res.data.couponDescribe
                      // document.getElementById("discountFee").innerHTML = (res.data.discountFee/100)
                      // document.getElementById("discountDesc").style.display="none"
                      // $btnLoad.style.display = "none";
                      // $btnObj.style.display = "block";
                      // document.getElementById("discountBox").setAttribute('readonly','readonly');
                      // flag = 1
c3341558   xiejianpeng   格式化
246
                  } else {
f9cd3bb6   liuqimichale   初始化项目
247
248
249
250
251
                      alert(res.message)
                      // $discountBtn.disabled = false
                      // document.getElementById("discountTip").innerHTML = res.message
                  }
              })
c3341558   xiejianpeng   格式化
252
          } else {
f9cd3bb6   liuqimichale   初始化项目
253
254
255
256
257
258
259
260
261
262
263
264
              var root = webAppRoot;
              //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器]
              var clientType = clientBrowserEx();
              //alert(clientType);
              switch (clientType) {
                  case "wxPay"://微信[内置浏览器]
                      //var wxPay = webAppH5.wxPayServer;
                      //var wxParams = webAppH5.comParams;
                      //wxParams.orderId = orderID;
                      //wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                      //wxParams.terminalSource = 3;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
                      //debugger;
dc07d4e3   liuqimichale   update .gitignore
265
266
  
  
c3341558   xiejianpeng   格式化
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
                      // //新增start
                      //
                      // var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096";
                      // //window.location.href = url;
                      // var wxPay = webAppH5.wxPayServer;
                      // var wxParams = webAppH5.comParams;
                      // wxParams.carNumber = getQueryString(window.location).carnum;
                      // wxParams.orderId = orderID;
                      // wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                      // wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
                      //
                      // wxParams.paySrcType = getQueryString(window.location)._paySrcType;//101停车支付
                      //
                      // wxParams.recordArreaInfos= JSON.stringify([{"orderId":webAppParams.orderId,"orderNotPayFee":_mon*100,"parkId":getQueryString(window.location).parkCode}]);
                      //
                      // //新增end
8aa21713   liuqimichale   调试微信支付
283
284
285
286
287
288
289
  
                      // if (webAppCode == null || webAppCode == "") {//code检测
                      //     alertMsg(appState.codeNullTip);
                      //     $btnObj.style.display = "block";
                      //     $btnLoad.style.display = "none";
                      //     return;
                      // }
f9cd3bb6   liuqimichale   初始化项目
290
291
292
293
294
295
296
                      webAppClass.payAjaxJDK(orderID);
                      console.log("wxPay");//微信支付
                      break;
                  case "aliPay"://支付宝
                      console.log("aliPay");
                      //订单号
                      var obj = {};
afc9e308   liuqimichale   银联支付
297
298
299
  
                      var aliPay = webAppH5.doPay;
  
f9cd3bb6   liuqimichale   初始化项目
300
                      //this.payAjax(url, { orderId: "11111", price: 0.01 });
afc9e308   liuqimichale   银联支付
301
302
303
304
305
306
307
308
309
310
311
312
313
314
                      // var aliPay = webAppH5.aliPayServer;
                      // var aliParams = webAppH5.comParams;
                      // aliParams.orderId = orderID;
                      // aliParams.carNumber = getQueryString(window.location).carnum;
                      // aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                      // aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
                      // aliParams.paySrcType = getQueryString(window.location)._paySrcType;//101停车支付
                      //
                      // aliParams.recordArreaInfos = JSON.stringify([{
                      //     "orderId": webAppParams.orderId,
                      //     "orderNotPayFee": _mon * 100,
                      //     "parkId": getQueryString(window.location).parkCode
                      // }]);
                      webAppClass.payAliAjax(root + aliPay, utilParams(1,orderID,''));
f9cd3bb6   liuqimichale   初始化项目
315
316
317
318
319
320
321
322
                      break;
                  default://第三方浏览器other
                      //默认支付宝
                      if (document.getElementById("aliPay").checked) {
                          console.log("aliPay");
                          //订单号
                          var obj = {};
                          //this.payAjax(url, { orderId: "11111", price: 0.01 });
afc9e308   liuqimichale   银联支付
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
                        var aliPay = webAppH5.doPay;
                          // var aliParams = webAppH5.comParams;
                          // aliParams.orderId = orderID;
                          // aliParams.carNumber = getQueryString(window.location).carnum;
                          // aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                          // aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
                          // aliParams.paySrcType = getQueryString(window.location)._paySrcType;//101停车支付
                          //
                          // aliParams.recordArreaInfos = JSON.stringify([{
                          //     "orderId": webAppParams.orderId,
                          //     "orderNotPayFee": _mon * 100,
                          //     "parkId": getQueryString(window.location).parkCode
                          // }]);
  
                          //webAppClass.payAliAjax(root + aliPay, aliParams);
                        webAppClass.payAliAjax(root + aliPay, utilParams(1,orderID,''));
f9cd3bb6   liuqimichale   初始化项目
339
340
341
342
343
                      } else {//微信页面支付
                          var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096";
                          //window.location.href = url;
                          var wxPay = webAppH5.wxPayServer;
                          var wxParams = webAppH5.comParams;
dc07d4e3   liuqimichale   update .gitignore
344
                          wxParams.carNumber = getQueryString(window.location).carnum;
f9cd3bb6   liuqimichale   初始化项目
345
346
347
                          wxParams.orderId = orderID;
                          wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                          wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
dc07d4e3   liuqimichale   update .gitignore
348
  
c3341558   xiejianpeng   格式化
349
                          wxParams.paySrcType = getQueryString(window.location)._paySrcType;//101停车支付
dc07d4e3   liuqimichale   update .gitignore
350
  
c3341558   xiejianpeng   格式化
351
352
353
354
355
                          wxParams.recordArreaInfos = JSON.stringify([{
                              "orderId": webAppParams.orderId,
                              "orderNotPayFee": _mon * 100,
                              "parkId": getQueryString(window.location).parkCode
                          }]);
f9cd3bb6   liuqimichale   初始化项目
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
                          webAppClass.payAjax(root + wxPay, wxParams);
                          console.log("wxPay");
                      }
                      break;
              }
          }
  
      },
  
      getCode: function () {
          var appID = appWxID;
          var code = getUrlParam('code');
          var local = window.location.href;
          //alert("local:" + local);
          if (code == null || code === '') {
              //alert(code);
              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'
              //window.event.returnValue = false;
              //window.open('https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appID + '&redirect_uri=' + encodeURIComponent(local) + '&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect');
              //alert("22");
          } else {
              //getOpenId(code); //把code传给后台获取用户信息
              //alert(code);
              //webAppCode = code;
              return code;
          }
  
          function getUrlParam(name) {
              var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
              var r = window.location.search.substr(1).match(reg)
              if (r != null) return unescape(r[2])
              return null
          }
      },
      //Ali
      aliClick: function (ev) {
          console.log("AliClick");
          document.getElementById("aliPay").checked = true;
          ev.preventDefault();
      },
      //Wx
      wxClick: function (ev) {
          console.log("wxClick");
          document.getElementById("wxPay").checked = true;
          ev.preventDefault();
      },
      //浏览器
      clientBrowser: function () {
          if (/MicroMessenger/.test(window.navigator.userAgent)) {
              console.log("微信客户端");
              this.switchShow("wxPay");
          } else if (/AlipayClient/.test(window.navigator.userAgent)) {
              console.log("支付宝客户端");
              this.switchShow("aliPay");
          } else {
              console.log("其他浏览器");
              this.switchShow("other");
          }
      },
      //根据浏览器显示内容[aliPay、wxPay、other]
      switchShow: function (type) {
          var aliObj = document.getElementById("rowAliPay");
          var wxObj = document.getElementById("rowWxPay");
          var lineObj = document.getElementById("splitLine");
          switch (type) {
              case "aliPay":
                  lineObj.style.display = "none";
                  wxObj.style.display = "none";
                  document.getElementById("aliPay").checked = true;
                  break;
              case "wxPay":
                  lineObj.style.display = "none";
                  aliObj.style.display = "none";
                  document.getElementById("wxPay").checked = true;
                  break;
              default://其他浏览器[浏览器暂时屏蔽微信]
                  lineObj.style.display = "none";
                  wxObj.style.display = "none";
                  document.getElementById("aliPay").checked = true;
                  break;
          }
      },
  
      //异步请求-微信H5页面
      payAjax: function (url, params) {
          var btnOBj = $btnObj;
          postRequest(url, params, function (res) {
              btnOBj.style.display = "block";
              $btnLoad.style.display = "none";
              //debugger;
              if (res.code == 0) {//进场
                  //alertMsg("出场成功");
                  if (res.data) {
                      var tmpObj = res.data;
c3341558   xiejianpeng   格式化
450
                      if (typeof (tmpObj.mwebUrl) != "undefined") {
f9cd3bb6   liuqimichale   初始化项目
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
                          window.location.href = tmpObj.mwebUrl + "&redirect_url=" + webAppPayResult;
                      } else {
                          alertMsg("没有返回支付地址mwebUrl");
                      }
                      console.log(JSON.stringify(tmpObj));
                  } else {
                      alertMsg("没有找到返回值");
                  }
              } else {//其他情况如【该卡号场内已存在】
                  console.log(res.message);
                  alertMsg(res.message);
              }
          }, function (err) {
              console.log("网络地址出错...");
              alertMsg("网络地址出错...");
              $btnLoad.style.display = "none";
              btnOBj.style.display = "block";
          });
      },
      //异步请求-微信JDK调用
      payAjaxJDK: function (orderID) {
          var btnOBj = $btnObj;
          //0:页面初始化获取code[webAppCode]
c3341558   xiejianpeng   格式化
474
          var codeParams = {code: webAppCode, appId: appWxID};
f9cd3bb6   liuqimichale   初始化项目
475
476
477
478
          var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer;
  
          //1:有code获取OpenId
          postRequest(openIdUrl, codeParams, function (res) {
f9cd3bb6   liuqimichale   初始化项目
479
480
              //alert(JSON.stringify(res));
              if (res.code == 0) {
f9cd3bb6   liuqimichale   初始化项目
481
482
                  //alert(res.data);
                  webAppClass.getPayParams(res.data, orderID);
c3341558   xiejianpeng   格式化
483
              } else if (res.code == 40163) {//code been used, hints[重复code问题]
b39a76c4   liuqimichale   调试微信支付
484
  
f9cd3bb6   liuqimichale   初始化项目
485
486
487
488
                  alertMsg(appState.codeNullTip);
                  console.log(res.message);
                  $btnObj.style.display = "block";
                  $btnLoad.style.display = "none";
c3341558   xiejianpeng   格式化
489
              } else {
f9cd3bb6   liuqimichale   初始化项目
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
                  alertMsg(res.message);
                  $btnObj.style.display = "block";
                  $btnLoad.style.display = "none";
              }
          }, function (err) {
              console.log("网络地址出错..." + openIdUrl);
              $btnObj.style.display = "block";
              $btnLoad.style.display = "none";
          });
          //2:获取支付参数
          //function getPayParams(openId) {
  
          //}
      },
      getPayParams: function (openId, orderID) {
afc9e308   liuqimichale   银联支付
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
          // var wxPay = window.webAppH5.wxPayServer;
          // var wxParams = window.webAppH5.comParams;
          // var _mon = document.getElementById("sumMoney").innerHTML
          // wxParams.orderId = orderID;
          // wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
          // wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
          // //webAppClass.payAjax(root + wxPay, wxParams);
          //
          //
          // //新增start
          //
          //
          // wxParams.carNumber = getQueryString(window.location).carnum;
          //
          // wxParams.paySrcType = getQueryString(window.location)._paySrcType;//101停车支付
          //
          // wxParams.recordArreaInfos = JSON.stringify([{
          //     "orderId": webAppParams.orderId,
          //     "orderNotPayFee": _mon * 100,
          //     "parkId": getQueryString(window.location).parkCode
          // }]);
          //
          // //新增end
          //
          //
          // wxParams.openId = openId;
          // wxParams.appId = appWxID;
          // var payParamsUrl = webAppRoot + window.webAppH5.wxPayServer;
  
  
  
        var jsondata = utilParams(2,orderID,openId);
  
  
  
        var payParamsUrl = webAppRoot + window.webAppH5.doPay;
dc07d4e3   liuqimichale   update .gitignore
541
  
f9cd3bb6   liuqimichale   初始化项目
542
          //alert(payParamsUrl);alert(orderID);
afc9e308   liuqimichale   银联支付
543
          postRequest(payParamsUrl, jsondata, function (res) {
f9cd3bb6   liuqimichale   初始化项目
544
545
546
547
548
549
550
              $btnObj.style.display = "block";
              $btnLoad.style.display = "none";
              //debugger;
              if (res.code == 0) {//进场
                  //alertMsg("出场成功");
                  if (res.data) {
                      var tmpObj = res.data;
afc9e308   liuqimichale   银联支付
551
                      webAppClass.weixinJSBridge(tmpObj);
f9cd3bb6   liuqimichale   初始化项目
552
553
554
555
556
557
558
559
                      console.log(JSON.stringify(tmpObj));
                      //alert(JSON.stringify(tmpObj));
                  } else {
                      alertMsg("没有找到返回值");
                  }
              } else {
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
c3341558   xiejianpeng   格式化
560
561
                  console.log(res.message);
                  alertMsg(res.message);
f9cd3bb6   liuqimichale   初始化项目
562
563
564
565
566
567
568
569
570
571
              }
          }, function (err) {
              console.log("网络地址出错...");
              alertMsg("网络地址出错..." + payParamsUrl);
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
          });
      },
  
      //调用微信内置WeixinJSBridge对象发起支付
afc9e308   liuqimichale   银联支付
572
573
574
575
576
577
578
579
580
581
      weixinJSBridge: function (data) {
        var datas = JSON.parse(data.jsPayRequest);
        //datas = JSON.parse(datas);
        var timeStamp = datas.timeStamp;
        var appId = datas.appId;
        var nonceStr = datas.nonceStr;
        var package = datas.package;
        var paySign = datas.paySign;
        var type = datas.signType;
  
f9cd3bb6   liuqimichale   初始化项目
582
583
          function onBridgeReady() {
              WeixinJSBridge.invoke(
afc9e308   liuqimichale   银联支付
584
585
586
587
588
589
590
591
                'getBrandWCPayRequest', {
                  "appId":appId,     //公众号名称,由商户传入
                  "timeStamp":timeStamp,         //时间戳,自1970年以来的秒数
                  "nonceStr":nonceStr, //随机串
                  "package":package,
                  "signType":type,         //微信签名方式:
                  "paySign":paySign //微信签名
                },
c3341558   xiejianpeng   格式化
592
593
594
595
596
                  function (res) {
                      //alert(res.err_msg);
                      if (res.err_msg == "get_brand_wcpay_request:ok") {
                          // 使用以上方式判断前端返回,微信团队郑重提示:
                          //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
93dedac4   liuqimichale   调试微信支付
597
  
5206fa87   liuqimichale   调试微信支付
598
599
600
601
  
  
                          //window.location.href = webAppPayResult + "?trade_no=" + "success";
                        window.history.go(-2);
93dedac4   liuqimichale   调试微信支付
602
603
604
605
606
607
608
                        setTimeout(function(){
                          window.history.go(-2);
                          //var src = mUrl.Uri+'/WEB-INF/pages/select.html?openid='+func.openid+'&token='+func.token+"&";//mUrl.myParkCardView;
                          //window.location.href = src;
                        },3000);
  
  
c3341558   xiejianpeng   格式化
609
610
611
612
613
614
615
                      } else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
                          window.location.href = webAppPayResult + "?trade_no=" + "fail";
                      } else {
                          alertMsg(JSON.stringify(res));
                          //alert(res.err_msg);
                      }
                  });
f9cd3bb6   liuqimichale   初始化项目
616
          }
c3341558   xiejianpeng   格式化
617
  
f9cd3bb6   liuqimichale   初始化项目
618
619
620
621
622
623
624
625
626
627
628
629
630
631
          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();
          }
      },
  
      //异步请求-支付宝
      payAliAjax: function (url, params) {
afc9e308   liuqimichale   银联支付
632
  
f9cd3bb6   liuqimichale   初始化项目
633
634
635
636
637
          var btnOBj = $btnObj;
          postRequest(url, params, function (res) {
              btnOBj.style.display = "block";
              $btnLoad.style.display = "none";
              if (res.code == 0) {//进场
afc9e308   liuqimichale   银联支付
638
639
                  window.location.href = res.data.h5PayRequest
                  //document.write(res.data.h5PayRequest);//打开支付表单
f9cd3bb6   liuqimichale   初始化项目
640
641
642
643
644
              } else {//其他情况如【该卡号场内已存在】
                  console.log(res.message);
                  alertMsg(res.message);
              }
          }, function (err) {
c3341558   xiejianpeng   格式化
645
646
              console.log("网络地址出错...");
              alertMsg("网络地址出错...");
f9cd3bb6   liuqimichale   初始化项目
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
              $btnLoad.style.display = "none";
              btnOBj.style.display = "block";
          });
      },
  
      //设置UI
      setUI: function (params) {
          console.log('ui')
          var $carNum = getObjectByID("carNum"),//车牌号
              $orderNum = getObjectByID("orderNum"),//订单号
              $sumMoney = getObjectByID("sumMoney"),//实际应付金额
              $outtime = getObjectByID("outtime"),//实际出场时间
              $payTip = getObjectByID("payTip"),//支付提示
  
              $parkName = getObjectByID("parkName"),//车场名称
              $inparktime = getObjectByID("inparktime"),//进场时间
              $staytime = getObjectByID("staytime"),//停车时长
              $due = getObjectByID("due"),//停车总费用
  
              $paid = getObjectByID("paid"),//已支付金额
              $discountDesc = getObjectByID("discountDesc"),//8折优惠折扣费用
              $discountFee = getObjectByID("discountFee");//优惠金额
  
c3341558   xiejianpeng   格式化
670
          if (params != null && params != "") {
f9cd3bb6   liuqimichale   初始化项目
671
              var price = keepTwoDecimalFull((params.orderFee / 100));//(params.orderFee / 100);
33e6793f   liuqimichale   支付页面
672
              $carNum.innerHTML = params.carnum;//手机号
f9cd3bb6   liuqimichale   初始化项目
673
674
              $orderNum.innerHTML = params.orderId;//订单号
              $sumMoney.innerHTML = price;///params.orderFee//缴费金额
b9e554af   liuqimichale   支付页面
675
              $outtime.innerHTML = params.parkOutTime;//实际出场时间
f9cd3bb6   liuqimichale   初始化项目
676
677
678
679
680
681
682
683
              //.appOrderTimeout
              $payTip.innerHTML = "注意: " + params.appOrderTimeout;//请在支付完成10分钟内出场,如超时未出场,会继续计费。
  
              $parkName.innerHTML = params.parkName;
              $inparktime.innerHTML = params.inparktime;
              $staytime.innerHTML = formatSeconds(params.staytime);
  
              $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用
c3341558   xiejianpeng   格式化
684
              $paid.innerHTML = keepTwoDecimalFull(params.paid / 100);
33e6793f   liuqimichale   支付页面
685
              $discountFee.innerHTML = params.discountFee;//优惠金额
afc9e308   liuqimichale   银联支付
686
  
33e6793f   liuqimichale   支付页面
687
              // $discountDesc.innerHTML = params.discountDesc;
f9cd3bb6   liuqimichale   初始化项目
688
689
690
691
692
          } else {
              console.log("没有接受到参数");
          }
      },
  
e8db9094   liuqimichale   欠费列表
693
  
f9cd3bb6   liuqimichale   初始化项目
694
  }
b244e45c   liuqimichale   提示 需要支付的车牌号是否正确