diff --git a/config.js b/config.js
index 4c90769..6b33064 100644
--- a/config.js
+++ b/config.js
@@ -6,7 +6,9 @@
window.webAppH5 = {};
/*服务器地址*/
-var webAppRoot = "http://39.98.54.240:8090";
+var webAppRoot = "http://39.98.54.240:8090"; //"http://39.98.54.240:8090";
+//var webApp
+var webAppPayResult = "http://test.pay.renniting.cn/codepay/page/wxpayResult.html";
/*公共参数*/
webAppH5.comParams = {
@@ -18,6 +20,13 @@ webAppH5.comParams = {
token: '666'
}
+//小票扫码支付参数
+webAppH5.dynCode = {//卫岗固定参数
+ direction: 1,
+ codeType: 1,
+ channelId: "小票二维码"
+}
+
/*出、入场接口*/
webAppH5.comServer = "/keyTopQrCodeInOutPark/noCarQRcodeInOutPark";
@@ -60,6 +69,11 @@ webAppH5.aliPayServer = "/alipay/aliH5Pay";
// direction:1
//}
+//小票二维码出场
+//http://39.98.54.240/codepay/index.html?appid=0&lotId=1&payConfigId=2&receiptNo=3
+//http://localhost:1260/codepay/index.html?appid=0&lotId=1&payConfigId=2&receiptNo=3
+
+
//首页
//进出场标识>>>>>>>>>>direction=0 [通行方向 入:0,1:出 必填]
//测试服务器进场首页
@@ -70,5 +84,10 @@ webAppH5.aliPayServer = "/alipay/aliH5Pay";
+//测试支付[任你停测试-首页-停车记录(停车列表车牌号,再找到对应停车场编号)]
+//http://test.renniting.cn/parking/admin/SubMenus/allparkrecords.html
+
+//http://localhost:1260/pay.html?orderId=101526715300086198272&parkName=%E9%9D%99%E9%9B%85%E5%9C%B0%E4%B8%8A&parkCode=B1504020C7&inparktime=2018-12-24%2010%3A58%3A24&outtime=2018-12-24%2011%3A05%3A10&staytime=420&due=70&paid=0&orderTotalFee=70&orderFee=7&discountFee=63&plateno=%E8%92%99DTK366&outPayOrderNo=B1504020C720181224110510813DTK366-172192102&appOrderTimeout=%E8%AF%B7%E5%9C%A8%E6%94%AF%E4%BB%98%E5%AE%8C%E6%88%9010%E5%88%86%E9%92%9F%E5%86%85%E5%87%BA%E5%9C%BA%EF%BC%8C%E5%A6%82%E8%B6%85%E6%97%B6%E6%9C%AA%E5%87%BA%E5%9C%BA%EF%BC%8C%E4%BC%9A%E7%BB%A7%E7%BB%AD%E8%AE%A1%E8%B4%B9%E3%80%82&discountDesc=1%E6%8A%98%E4%BC%98%E6%83%A0&queryOrderInfo=%7B%22app_id%22%3A%221%22%2C%22carNumber%22%3A%22%E8%92%99DTK366%22%2C%22channelId%22%3A%22172192102%22%2C%22codeType%22%3A0%2C%22deviceInfo%22%3A%223%22%2C%22direction%22%3A1%2C%22parkingId%22%3A%22B1504020C7%22%2C%22plNo%22%3A%22B1504020C7%22%2C%22salt%22%3A%222%22%2C%22sign%22%3A%224%22%2C%22sign_type%22%3A%22md5%22%2C%22terminalSource%22%3A%227%22%2C%22token%22%3A%22666%22%7D&needPay=true
+
diff --git a/dynCodePay.html b/dynCodePay.html
new file mode 100644
index 0000000..d8b17ee
--- /dev/null
+++ b/dynCodePay.html
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 订单支付
+
+
+
+
+
+
+
+
+ 停车时长:
+ 进场时间:
+ 停车总费用:
+ 已支付金额:
+ 优惠金额:
+ 订单编号: 1234567890
+
+
+
+ 选择支付方式 出场时间:
+
+
+
+
+

+
支付宝支付
+
+
+
+
+
+

+
微信支付
+
+
+
+
+
+
+
+
+
+
+
diff --git a/index.html b/index.html
index 61c7973..0f1f5c3 100644
--- a/index.html
+++ b/index.html
@@ -68,10 +68,15 @@
function getResponse(params) {
var direction = params.direction;//direction=0 [通行方向 入:0,1:出 必填]
var queryParams = parseParams(params);
- if (direction == 0) {//入口
- window.location.href = "page/in.html?" + queryParams;
- } else {//出口
- window.location.href = "page/out.html?" + queryParams;
+ //首先判断是否小票二维码标识位lotId
+ if (typeof(params.lotId)!="undefined") {
+ window.location.href = "dynCodePay.html?" + queryParams;
+ } else {
+ if (direction == 0) {//入口
+ window.location.href = "page/in.html?" + queryParams;
+ } else {//出口
+ window.location.href = "page/out.html?" + queryParams;
+ }
}
}
diff --git a/js/dynCodePay.js b/js/dynCodePay.js
new file mode 100644
index 0000000..333eccd
--- /dev/null
+++ b/js/dynCodePay.js
@@ -0,0 +1,305 @@
+/*
+@songcxa
+@2018-12-14
+@小票动态扫码移动支付
+*/
+var webAppParams = null;
+var $btnObj = null;
+var $btnLoad = null;
+//var $btnLoad = document.getElementById("loading");
+window.onload = function () {
+ //var root = document.getElementById("root");
+ $btnObj = document.getElementById("btnPayOK");
+ $btnLoad = document.getElementById("loading");
+ $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;
+ $btnObj.onclick = webAppClass.okClick;
+ document.getElementById("payTip").innerHTML = "";
+ //参数
+ var tmpURLparams = getQueryString(window.location);
+ if (tmpURLparams != null) {
+ //设置UI参数
+ //webAppClass.setUI(webAppParams);
+ webAppClass.init(tmpURLparams);
+ } else {
+ alertMsg("没有接收到url参数信息");
+ }
+}
+/**/
+var webAppClass = {
+ //appid={0}&lotId={1}&payConfigId={2}&receiptNo=
+ 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);
+ } 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";
+ });
+ },
+ //OK
+ okClick: function (ev) {
+ document.getElementById("payTip").innerHTML = "";
+ if (webAppParams == null) {
+ alertMsg("暂无订单信息");return;
+ }
+ //先校验停车费用后缴费提交
+ webAppClass.checkParkCost();
+ },
+ //校验该订单当前支付时的费用(排除扫描订单后不支付时长)
+ 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) {
+ webAppClass.setUI(tmpObj);
+ webAppParams = tmpObj;//重新赋值
+ webAppClass.okPay(tmpObj);//唤醒支付
+ } else {
+ alertMsg("没有找到相应订单");
+ }
+ } 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;
+ //默认支付宝
+ 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");
+ }
+ },
+
+ //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://其他浏览器
+ 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";
+ });
+ },
+
+ //异步请求-支付宝
+ 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) {
+ console.log("网络地址出错...");alertMsg("网络地址出错...");
+ $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");//优惠金额
+
+ if (params != null && params!="") {
+ 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);
+
+ $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";
+ }
+ }
+}
\ No newline at end of file
diff --git a/js/pay.js b/js/pay.js
index 0d44b54..7442fc4 100644
--- a/js/pay.js
+++ b/js/pay.js
@@ -161,11 +161,17 @@ var webAppClass = {
postRequest(url, params, function (res) {
btnOBj.style.display = "block";
$btnLoad.style.display = "none";
- debugger;
+ //debugger;
if (res.code == 0) {//进场
- alertMsg("出场成功");
+ //alertMsg("出场成功");
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("没有找到返回值");
}
diff --git a/page/out.html b/page/out.html
index 6ca96e2..22d94b2 100644
--- a/page/out.html
+++ b/page/out.html
@@ -180,7 +180,7 @@
alertMsg("没有找到订单");
}
} else {//其他情况如【该卡号场内已存在】
- console.log(res.message);
+ console.log(res.message); alertMsg(res.message);
if ((init) != "init") {
alertMsg(res.message);
}
diff --git a/page/wxpayResult.html b/page/wxpayResult.html
new file mode 100644
index 0000000..c8b2363
--- /dev/null
+++ b/page/wxpayResult.html
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 支付状态
+
+
+
+
+
+
+
+
+
+
+
+
+