Blame view

js/billCodePay.js 26.1 KB
a7b83e0d   songchongxian   动态二维码
1
2
3
4
5
6
7
8
9
  /*
  @songcxa
  @2018-12-14
  @小票动态扫码移动支付
  */
  var webAppParams = null;
  var $btnObj = null;
  var $btnLoad = null;
  var webAppCode = null;//如果是微信,先获取微信code
72b1b692   Andy   add 兑换券
10
  var flag = 0;
dbd86cb2   Andy   add 0元支付功能
11
12
13
14
15
  function trim(str) {
  
      return str.replace(/(^\s*)|(\s*$)/g, "");
  }
      window.onload = function () {
a7b83e0d   songchongxian   动态二维码
16
17
18
      //var root = document.getElementById("root");
      $btnObj = document.getElementById("btnPayOK");
      $btnLoad = document.getElementById("loading");
72b1b692   Andy   add 兑换券
19
20
      //兑换按钮
      $discountBtn = document.getElementById("discountBtn");
a7b83e0d   songchongxian   动态二维码
21
22
23
24
25
26
27
28
29
30
      $linkPayDetail = getObjectByID("linkPayDetail");
      $linkPayDetail.onclick = webAppClass.linkPayDetailClick;
      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;
544f25d2   songchongxian   扫码支付。。。
31
      $btnObj.onclick = webAppClass.okClick;//确认支付按钮
a7b83e0d   songchongxian   动态二维码
32
33
34
      document.getElementById("payTip").innerHTML = "";
      //参数
      var tmpURLparams = getQueryString(window.location);
544f25d2   songchongxian   扫码支付。。。
35
36
     
      //当前浏览器环境
a7b83e0d   songchongxian   动态二维码
37
38
      var state = clientBrowserEx();
      if (state == "wxPay") {
544f25d2   songchongxian   扫码支付。。。
39
          //wx先获取code, 在获取订单
a7b83e0d   songchongxian   动态二维码
40
          webAppCode = webAppClass.getCode();
544f25d2   songchongxian   扫码支付。。。
41
42
43
44
45
46
47
48
      } else {
          if (tmpURLparams != null) {
              //设置UI参数
              //webAppClass.setUI(webAppParams);
              webAppClass.init(tmpURLparams);
          } else {
              alertMsg("没有接收到url参数信息");
          }
a7b83e0d   songchongxian   动态二维码
49
      }
72b1b692   Andy   add 兑换券
50
51
      //兑换按钮事件
      $discountBtn.onclick = webAppClass.discountClick;
a7b83e0d   songchongxian   动态二维码
52
53
54
55
  }
  /**/
  var webAppClass = {
      //appid={0}&lotId={1}&payConfigId={2}&receiptNo=
544f25d2   songchongxian   扫码支付。。。
56
      //初始化获取订单
a7b83e0d   songchongxian   动态二维码
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
      init: function (params) {
          var urlParams = params;
          var newParams = urlParams || {};
          $btnObj.style.display = "none";
          $btnLoad.style.display = "block";
          newParams.terminalSource = "7";//1:任你听 3:微信公共号 4:云平台 7:H5
          //var tmpParams = Object.assign(params, window.webAppH5.comParams, window.webAppH5.appOut);
          newParams.parkingId = params.lotId;
          newParams.carNumber = params.receiptNo;
          var tmpParams = Object.assign(newParams, window.webAppH5.comParams, window.webAppH5.dynCode);
          this.initRequest(webAppRoot + window.webAppH5.comServer, tmpParams, "init");
      },
      initRequest: function (url, params, init) {
          var btnObj = $btnObj;
          postRequest(url, params, function (res) {
              btnObj.style.display = "block";
              $btnLoad.style.display = "none";
              if (res.code == 0) {//进场
                  //alertMsg("出场成功");
                  if (res.data) {
                      var tmpObj = res.data;
                      //判断是否需要支付
                      if (tmpObj.needPay) {
                          //var queryParams = parseParams(tmpObj);
                          //window.location.href = "../pay.html?" + queryParams;
                          webAppParams = tmpObj;
                          webAppClass.setUI(tmpObj);
544f25d2   songchongxian   扫码支付。。。
84
                          countDownTime("countDownTime");//订单支付倒计时
a7b83e0d   songchongxian   动态二维码
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                      } else {
                          var tipStr = "无需缴费,欢迎下次光临";
                          alertMsg(tipStr);
                      }
                  } else {
                      alertMsg("没有找到订单");
                  }
              } else {//其他情况如【该卡号场内已存在】
                  console.log(res.message); alertMsg(res.message);
                  if ((init) != "init") { alertMsg(res.message); }
              }
          }, function (err) {
              console.log("网络服务超时..." + url);
              alertMsg("网络服务超时");
              btnObj.style.display = "block";
              $btnLoad.style.display = "none";
          });
      },
544f25d2   songchongxian   扫码支付。。。
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
      //1:先获取微信code; 2:然后获取订单信息
      getCode: function () {
          var appID = appWxID;
          var code = getUrlParam('code');
          var local = window.location.href;
          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'
          } else {
              //alert(code);
              var tmpURLparams = getQueryString(window.location);
              webAppClass.init(tmpURLparams);
              //去掉url中旧code
              window.history.replaceState(null, document.title, funcUrlDel("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
          }
      },
      //OK按钮
a7b83e0d   songchongxian   动态二维码
127
128
129
      okClick: function (ev) {
          document.getElementById("payTip").innerHTML = "";
          if (webAppParams == null) {
544f25d2   songchongxian   扫码支付。。。
130
              alertMsg("暂无订单信息"); return;
a7b83e0d   songchongxian   动态二维码
131
          }
544f25d2   songchongxian   扫码支付。。。
132
133
134
135
136
          //[方式一]先校验停车费用后缴费提交
          //webAppClass.checkParkCost();
          //[方式二,倒计时支付]
          $btnObj.style.display = "none";
          $btnLoad.style.display = "block";
dbd86cb2   Andy   add 0元支付功能
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
          var val = document.getElementById("sumMoney").innerText;
          var couponPersonId = trim(document.getElementById("discountBox").value);
          var url = webAppRoot + window.webAppH5.zeroPayServer;
          var discountParams = {
              payOrderType : 101,
              terminalSource:7,
              orderId: webAppParams.orderId,
              couponPersonId:couponPersonId,
              app_id: '123',
              sign_type: '123',
              salt: '123',
              deviceInfo: '123',
              sign: '123',
          }
          if(val == '0.00' || val=='0'){
              postRequest(url, discountParams, function (res) {
                  console.log(res)
                  if(res.code==0){
                      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
                  }else{
                      alert(res.message)
                      // $discountBtn.disabled = false
                      // document.getElementById("discountTip").innerHTML = res.message
                  }
              })
          }else{
              webAppClass.okPay(webAppParams);//唤醒支付
          }
  
  
a7b83e0d   songchongxian   动态二维码
176
      },
72b1b692   Andy   add 兑换券
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
      //优惠券兑换
      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,
58cc7f4c   Andy   add 兑换券
198
                  codeType:2
72b1b692   Andy   add 兑换券
199
200
201
202
203
204
205
206
207
208
209
210
211
212
              }
              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{
154213e8   Andy   add 兑换券
213
214
215
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
                      $discountBtn.disabled = false;
72b1b692   Andy   add 兑换券
216
217
218
219
220
221
222
223
224
225
226
                      document.getElementById("discountTip").innerHTML = res.message
                  }
              })
  
          }else{
              return
          }
      },
      discountClick: function(){
          discountVal = document.getElementById("discountBox").value;
          // console.log(discountVal)
a79a8c53   Andy   add 提示
227
          // console.log(discountVal.length)
72b1b692   Andy   add 兑换券
228
229
230
231
          if(discountVal.length > 0){
              $btnObj.style.display = "none";
              $btnLoad.style.display = "block";
              $discountBtn.disabled = true
2686890b   Andy   add 提示
232
233
234
235
236
237
238
              // console.log(webAppParams)
              if(webAppParams===null ||webAppParams==='null'||webAppParams===undefined){
                  document.getElementById("discountTip").innerHTML = '缺少参数';
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
                  return false;
              }
72b1b692   Andy   add 兑换券
239
240
241
242
243
244
245
246
247
248
249
              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,
58cc7f4c   Andy   add 兑换券
250
                  codeType:2
72b1b692   Andy   add 兑换券
251
252
253
254
255
256
257
258
259
260
261
262
263
264
              }
              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{
154213e8   Andy   add 兑换券
265
266
267
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
                      $discountBtn.disabled = false;
72b1b692   Andy   add 兑换券
268
269
270
271
272
                      document.getElementById("discountTip").innerHTML = res.message
                  }
              })
  
          }else{
2686890b   Andy   add 提示
273
274
275
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
              return false;
72b1b692   Andy   add 兑换券
276
277
          }
      },
a7b83e0d   songchongxian   动态二维码
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
      //校验该订单当前支付时的费用(排除扫描订单后不支付时长)
      checkParkCost: function () {
          $btnObj.style.display = "none";
          $btnLoad.style.display = "block";
          if (typeof (webAppParams.queryOrderInfo) == "undefined") {//没有queryOrderInfo返回第一页
              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) {
72b1b692   Andy   add 兑换券
293
294
295
296
297
298
299
300
                      if(flag == 1){
                          webAppClass.codediscountClick(tmpObj);
                      }else{
                          webAppClass.setUI(tmpObj);
                          webAppParams = tmpObj;//重新赋值
                          webAppClass.okPay(tmpObj);//唤醒支付
                      }
  
a7b83e0d   songchongxian   动态二维码
301
302
                  } else {
                      alertMsg("没有找到相应订单");
544f25d2   songchongxian   扫码支付。。。
303
304
                      $btnLoad.style.display = "none";
                      $btnObj.style.display = "block";
a7b83e0d   songchongxian   动态二维码
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
                  }
              } else {//其他情况如【该卡号场内已存在】
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
                  console.log(res.message); alertMsg(res.message);
              }
          }, function (err) {
              console.log("网络服务超时..." + url);
              alertMsg("网络服务超时");
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
              //$btnLoad.style.display = "none";
          });
      },
  
      //确定支付
      okPay: function (params) {
          var orderID = params.orderId;//订单号
          //var moneyID = document.getElementById("sumMoney").innerHTML = webAppParams.orderId;//订单号
          var root = webAppRoot;
          //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器]
          var clientType = clientBrowserEx();
          switch (clientType) {
              case "wxPay"://微信[内置浏览器]
544f25d2   songchongxian   扫码支付。。。
329
                  webAppClass.payAjaxJDK(orderID);
a7b83e0d   songchongxian   动态二维码
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
                  console.log("wxPay");//微信支付
                  break;
              case "aliPay"://支付宝
                  console.log("aliPay");
                  //订单号
                  var obj = {};
                  //this.payAjax(url, { orderId: "11111", price: 0.01 });
                  var aliPay = webAppH5.aliPayServer;
                  var aliParams = webAppH5.comParams;
                  aliParams.orderId = orderID;
                  aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                  aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
                  aliParams.paySrcType = 101;//101停车支付
                  webAppClass.payAliAjax(root + aliPay, aliParams);
                  break;
              default://第三方浏览器other[]
                  //默认支付宝
                  if (document.getElementById("aliPay").checked) {
                      console.log("aliPay");
                      //订单号
                      var obj = {};
                      //this.payAjax(url, { orderId: "11111", price: 0.01 });
                      var aliPay = webAppH5.aliPayServer;
                      var aliParams = webAppH5.comParams;
                      aliParams.orderId = orderID;
                      aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5   4微信公众号
                      aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
                      aliParams.paySrcType = 101;//101停车支付
                      webAppClass.payAliAjax(root + aliPay, aliParams);
                  } 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;
                      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);
                      console.log("wxPay");
                  }
                  break;
          }
      },
544f25d2   songchongxian   扫码支付。。。
373
     
a7b83e0d   songchongxian   动态二维码
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
      //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;
          }
      },
  
      //异步请求-微信
      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) {//进场
                  if (res.data) {
                      var tmpObj = res.data;
                      if (typeof (tmpObj.mwebUrl) != "undefined") {
                          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("网络地址出错...");
              btnOBj.style.display = "block";
          });
      },
  
      payAjaxJDK: function (orderID) {
          var btnOBj = $btnObj;
          //0:页面初始化获取code[webAppCode]
          var codeParams = { code: webAppCode, appId: appWxID };
          var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer;
          //alert(openIdUrl);
          //1:有code获取OpenId
          postRequest(openIdUrl, codeParams, function (res) {
              //alert(JSON.stringify(res));
              if (res.code == 0) {
                  //alert(res.data);
                  webAppClass.getPayParams(res.data, orderID);
544f25d2   songchongxian   扫码支付。。。
465
466
467
468
469
470
471
              }
              else if (res.code == 40163) {
                  alertMsg("请您重新扫码!");
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
              }
              else {
a7b83e0d   songchongxian   动态二维码
472
                  alertMsg(res.message);
544f25d2   songchongxian   扫码支付。。。
473
474
                  $btnLoad.style.display = "none";
                  $btnObj.style.display = "block";
a7b83e0d   songchongxian   动态二维码
475
476
477
              }
          }, function (err) {
              console.log("网络地址出错..." + openIdUrl);
544f25d2   songchongxian   扫码支付。。。
478
479
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
a7b83e0d   songchongxian   动态二维码
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
          });
          //2:获取支付参数
          //function getPayParams(openId) {
  
          //}
      },
      getPayParams: function (openId, orderID) {
          var wxPay = window.webAppH5.wxPayServer;
          var wxParams = window.webAppH5.comParams;
          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);
          wxParams.openId = openId;
          wxParams.appId = appWxID;
          var payParamsUrl = webAppRoot + window.webAppH5.wxPayServer;
          //alert(payParamsUrl);alert(orderID);
          postRequest(payParamsUrl, wxParams, function (res) {
              $btnObj.style.display = "block";
              $btnLoad.style.display = "none";
              //debugger;
              if (res.code == 0) {//进场
                  //alertMsg("出场成功");
                  if (res.data) {
                      var tmpObj = res.data;
                      webAppClass.weixinJSBridge(res.data);
                      console.log(JSON.stringify(tmpObj));
                      //alert(JSON.stringify(tmpObj));
                  } else {
                      alertMsg("没有找到返回值");
                  }
              } else {
                  $btnObj.style.display = "block";
                  $btnLoad.style.display = "none";
                  console.log(res.message); alertMsg(res.message);
              }
          }, function (err) {
              console.log("网络地址出错...");
              alertMsg("网络地址出错..." + payParamsUrl);
              $btnLoad.style.display = "none";
              $btnObj.style.display = "block";
          });
      },
      //调用微信内置WeixinJSBridge对象发起支付
      weixinJSBridge: function (params) {
          function onBridgeReady() {
              WeixinJSBridge.invoke(
                  'getBrandWCPayRequest', params,
                 function (res) {
                     //alert(res.err_msg);
                     if (res.err_msg == "get_brand_wcpay_request:ok") {
                         // 使用以上方式判断前端返回,微信团队郑重提示:
                         //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
                         window.location.href = webAppPayResult + "?trade_no=" + "success";
                     }
                     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);
                     }
                 });
          }
          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) {
          var btnOBj = $btnObj;
          postRequest(url, params, function (res) {
              btnOBj.style.display = "block";
              $btnLoad.style.display = "none";
              if (res.code == 0) {//进场
                  document.write(res.data);//打开支付表单
              } else {//其他情况如【该卡号场内已存在】
                  console.log(res.message);
                  alertMsg(res.message);
              }
          }, function (err) {
544f25d2   songchongxian   扫码支付。。。
568
              console.log("网络地址出错..."); alertMsg("网络地址出错...");
a7b83e0d   songchongxian   动态二维码
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
              $btnLoad.style.display = "none";
              btnOBj.style.display = "block";
          });
      },
  
      //设置UI
      setUI: function (params) {
          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");//优惠金额
  
544f25d2   songchongxian   扫码支付。。。
591
          if (params != null && params != "") {
a7b83e0d   songchongxian   动态二维码
592
593
594
595
596
597
598
599
600
601
602
              var price = keepTwoDecimalFull((params.orderFee / 100));//(params.orderFee / 100);
              $carNum.innerHTML = params.plateno;//手机号
              $orderNum.innerHTML = params.orderId;//订单号
              $sumMoney.innerHTML = price;///params.orderFee//缴费金额
              $outtime.innerHTML = params.outtime;//实际出场时间
              //.appOrderTimeout
              $payTip.innerHTML = "注意: " + params.appOrderTimeout;//请在支付完成10分钟内出场,如超时未出场,会继续计费。
  
              $parkName.innerHTML = params.parkName;
              $inparktime.innerHTML = params.inparktime;
              $staytime.innerHTML = formatSeconds(params.staytime);
544f25d2   songchongxian   扫码支付。。。
603
  
a7b83e0d   songchongxian   动态二维码
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
              $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用
              $paid.innerHTML = params.paid;
              $discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额
              $discountDesc.innerHTML = params.discountDesc;
          } else {
              console.log("没有接受到参数");
          }
      },
  
      //查看详情
      linkPayDetailClick: function (ev) {
          var $payDetail = getObjectByID("payDetail");
          var $linkPayDetail = getObjectByID("linkPayDetail");
          if ($linkPayDetail.innerHTML == "详情+") {
              $linkPayDetail.innerHTML = "详情-";
              $payDetail.style.height = "195px";
          } else {
              $linkPayDetail.innerHTML = "详情+";
              $payDetail.style.height = "55px";
          }
      }
544f25d2   songchongxian   扫码支付。。。
625
  }