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 = "paybacknew.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 = "paybacknew.html?carNumber" + queryParams; } else { var tipStr = "无需缴费,欢迎下次光临"; sucessTip(tipStr); alertMsg(tipStr); } //var tel = document.getElementById("inputPhoneNum").value.replace(/\s/g, "");//去除空格 //var orderFee = keepTwoDecimalFull((tmpObj.orderFee / 100));//本次出场实际应付金额(减去折扣,优惠券等之后的应付金额) //var tmpUrl = "orderId=" + tmpObj.orderId + "&outtime=" + tmpObj.outtime + "&tel=" + tel + "&orderFee=" + orderFee; } 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; }