Blame view

js/out.js 4.03 KB
bdca61de   liuqimichale   西城 扫码支付 签名
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  var queryParams = null;//?参数名称
  var $btnObj = null, $btnLoad = null;
  function inputDown() {
      var numObj = getObjectByID("inputPhoneNum");
      numObj.value = numObj.value.replace(/\D/g, '').replace(/^/, '$& ').replace(/....(?!$)/g, '$& ');
  }
  window.onload = function () {
      $btnObj = getObjectByID("btnPayOK");
      $btnLoad = getObjectByID("loading");
      $exChangeNum = getObjectByID("exChangeNum");
      // $exChangeNum.onclick = exChangeNumClick;
      queryParams = getQueryString(window.location);//获取url参数?sign=4&token=6&codeType=888
      var ok = $btnObj;
      ok.onclick = btnOkClick;
      //初始化请求订单,有跳转选择支付,没有填入手机号
      $inputCarNum = getObjectByID("inputCarNum");
      $inputCarNum.onkeyup = checkCharAndNumber
      //init();//初始化init
  }
  function init() {
      if (queryParams == null) {
          var str = "没有接收到请求参数"; alertMsg(str); console.log(str); return;
      }
      var params = queryParams || {};
      $btnObj.style.display = "none";
      $btnLoad.style.display = "block";
      params.payType = IsWeixinOrAlipay()//4:微信     1:支付宝
      params.terminalSource = "7";//1:任你听 3:微信公共号 4:云平台 7:H5
      //var tmpParams = Object.assign(params, window.webAppH5.comParams, window.webAppH5.appOut);
      var tmpParams = Object.assign(params, window.webAppH5.comParams);
      getRequest(webAppRoot + window.webAppH5.comServer, tmpParams, "init");
  }
  //点击查询订单
  function btnOkClick() {
      window.location.href = "listnew.html?carNumber=" + getCarNumber();
  }
  
  //读取订单数据
  function getRequest(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);
                      console.log(tmpObj)
                      window.location.href = "../listnew.html?carNumber" + queryParams;
                  } else {
                      var tipStr = "无需缴费,欢迎下次光临";
                      sucessTip(tipStr); alertMsg(tipStr);
                  }
  
              } else {
                  alertMsg("没有找到订单");
              }
          } else {//其他情况如【该卡号场内已存在】
              console.log(res.message); alertMsg(res.message);
              if ((init) != "init") {
                  alertMsg(res.message);
              }
              document.getElementById("inputPhoneNum").focus();
          }
      }, function (err) {
          console.log("网络服务超时..." + url);
          alertMsg("网络服务超时");
          btnObj.style.display = "block";
          $btnLoad.style.display = "none";
      });
  }
  //直接无需缴费出场
  function sucessTip(content) {
      var obj = ["header", "footer"];
      for (var i = 0; i < obj.length; i++) {
          var tmpObj = document.getElementById("" + obj[i] + "");
          tmpObj.style.display = "none";
      }
      document.getElementById("tipResult").style.display = "block";
      document.getElementById("outTipContent").innerHTML = content;
  }
  
  
  //获取查询条件值
  function getCarNumber() {
  
  
  
      var tmpValue = "";
      var tmpPhone = getObjectByID("inputPhoneNum");
      var phoneNumBox = getObjectByID("phoneNumBox");//手机号
      if(phoneNumBox.style.display === "block"){
          tmpValue = tmpPhone.value.replace(/\s*/g, "")+'111';//去除空格
          if (tmpValue == "" || tmpValue.length < 11) {
              alertMsg("请输入正确的手机号码!");
              tmpValue = "";
          }
      }else{
          var tmpNum = getObjectByID("inputCarNum").value;
          tmpValue = getObjectByID("selProvince").value + tmpNum;
          if (tmpNum == "" || tmpNum == " ") {
              alertMsg("车牌号不能为空!");
              tmpValue = "";
          }
      }
      console.log("查询值:" + tmpValue);
      return tmpValue;
  
  }