Commit a7b83e0d6a55edbb69d164023bc19f076f100842

Authored by songchongxian
1 parent 903c4448

动态二维码

billCodePay.html 0 → 100644
  1 +<!doctype html>
  2 +<html lang="en">
  3 +<head>
  4 + <meta charset="utf-8">
  5 + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6 + <meta name="theme-color" content="#000000">
  7 + <meta name="google" value="notranslate">
  8 + <meta name="format-detection" content="telephone=no">
  9 + <meta name="format-detection" content="email=no">
  10 + <meta name="apple-mobile-web-app-capable" content="yes">
  11 + <meta name="apple-mobile-web-app-status-bar-style" content="black">
  12 + <meta http-equiv="Pragma" content="no-cache">
  13 + <meta http-equiv="Cache-control" content="no-cache">
  14 + <meta http-equiv="Cache" content="no-cache">
  15 + <meta http-equiv="Expires" content="0">
  16 + <link rel="stylesheet" href="css/index.css?v=0.1">
  17 + <script src="config.js?v=0.1"></script>
  18 + <script src="js/common.js?v=0.1"></script>
  19 + <script src="js/billCodePay.js?v=0.1"></script>
  20 + <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>-->
  21 + <!--<script src="config.js"></script>-->
  22 + <!--
  23 + Notice the use of %PUBLIC_URL% in the tags above.
  24 + It will be replaced with the URL of the `public` folder during the build.
  25 + Only files inside the `public` folder can be referenced from the HTML.
  26 +
  27 + Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
  28 + work correctly both with client-side routing and a non-root public URL.
  29 + Learn how to configure a non-root public URL by running `npm run build`.
  30 + -->
  31 + <title>订单支付</title>
  32 +</head>
  33 +<body>
  34 + <!--<noscript>-->
  35 + <!--You need to enable JavaScript to run this app.-->
  36 + <!--</noscript>-->
  37 + <header id="header" class="flexBoxRow panelBgColor">
  38 + <div class="headerBox">
  39 + <div class="carNumBox"><span></span><span id="carNum"></span></div>
  40 + <div class="moneyBox"><span>¥</span><span id="sumMoney">0.00</span></div>
  41 + </div>
  42 + </header>
  43 + <section id="payDetail" class="panelBgColor marginTop">
  44 + <div><span>车场名称:</span><span id="parkName"></span><a id="linkPayDetail">详情+</a> </div>
  45 + <div><span>停车时长:</span><span id="staytime"></span></div>
  46 + <div><span>进场时间:</span><span id="inparktime"></span></div>
  47 + <div><span>停车总费用:</span><span id="due"></span></div>
  48 + <div><span>已支付金额:</span><span id="paid"></span></div>
  49 + <div><span>优惠金额:</span><span id="discountFee"></span><span id="discountDesc"></span></div>
  50 + <div><span>订单编号: </span><span id="orderNum"></span> </div>
  51 + </section>
  52 + <section id="section" class="marginTop">
  53 + <div class="flexBoxRow">
  54 + <span class="payWayTitle">选择支付方式</span> <span class="orderTime colorGray">出场时间: <span id="outtime"></span></span>
  55 + </div>
  56 + <div class="row marginTop">
  57 + <!--AliPay-->
  58 + <div class="flexBoxRow" id="rowAliPay">
  59 + <img class="payIcon" src="img/aliPay.png" />
  60 + <span class="marginLeft">支付宝支付</span>
  61 + <label for="aliPay" class="radio">
  62 + <span class="radio-bg"></span>
  63 + <input type="radio" name="radioPayWay" id="aliPay" value="支付宝" checked="checked" />
  64 + <span class="radio-on"></span>
  65 + </label>
  66 + </div>
  67 + <hr class="splitLine marginTop" id="splitLine" />
  68 + <!--WxPay-->
  69 + <div class="flexBoxRow marginTop" id="rowWxPay">
  70 + <img class="payIcon" src="img/wxPay.png" />
  71 + <span class="marginLeft">微信支付</span>
  72 + <label for="wxPay" class="radio">
  73 + <span class="radio-bg"></span>
  74 + <input type="radio" name="radioPayWay" id="wxPay" value="微信" />
  75 + <span class="radio-on"></span>
  76 + </label>
  77 + </div>
  78 + </div>
  79 + </section>
  80 + <footer id="footer" class="flexBoxRow marginTop">
  81 + <div class="btnOK" id="btnPayOK">确定支付</div>
  82 + <img src="img/loading.gif" id="loading" style="display: none;" />
  83 + </footer>
  84 + <section id="payTip" style="padding: 5px;margin-top:5px; color: #3385ff; font-size: 14px; "></section>
  85 +
  86 + <!--
  87 + This HTML file is a template.
  88 + If you open it directly in the browser, you will see an empty page.
  89 +
  90 + You can add webfonts, meta tags, or analytics to this file.
  91 + The build step will place the bundled scripts into the <body> tag.
  92 +
  93 + To begin the development, run `npm start` or `yarn start`.
  94 + To create a production bundle, use `npm run build` or `yarn build`.
  95 + -->
  96 +</body>
  97 +
  98 +</html>
... ...
config.js
... ... @@ -5,10 +5,15 @@
5 5 */
6 6 window.webAppH5 = {};
7 7  
  8 +//微信appID
  9 +var appWxID = "wx1e9001e5940605b1";//wx945eccc8163fd75b
  10 +
8 11 /*服务器地址*/
9   -var webAppRoot = "http://39.98.54.240:8090"; //"http://39.98.54.240:8090";
10   -//var webApp
11   -var webAppPayResult = "http://test.pay.renniting.cn/codepay/page/wxpayResult.html";
  12 +//var webAppRoot = "http://39.98.54.240:8090";
  13 +var webAppRoot = "http://pay.service.renniting.cn/v1";
  14 +
  15 +//微信支付结果回调地址
  16 +var webAppPayResult = "http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/page/wxpayResult.html";
12 17  
13 18 /*公共参数*/
14 19 webAppH5.comParams = {
... ... @@ -20,7 +25,7 @@ webAppH5.comParams = {
20 25 token: '666'
21 26 }
22 27  
23   -//小票扫码支付参数
  28 +//小票扫码支付参数codeType[0静态码、1小票二维码、2动态二维码]
24 29 webAppH5.dynCode = {//卫岗固定参数
25 30 direction: 1,
26 31 codeType: 1,
... ... @@ -33,6 +38,9 @@ webAppH5.comServer = &quot;/keyTopQrCodeInOutPark/noCarQRcodeInOutPark&quot;;
33 38 //缴费-微信
34 39 webAppH5.wxPayServer = "/weixinpay/publicUnifiedOrder";
35 40  
  41 +//微信获取openID
  42 +webAppH5.wxGetOpenIdServer = "/weixinPublicPay/getOpenIdByCode";
  43 +
36 44 //缴费-支付宝
37 45 webAppH5.aliPayServer = "/alipay/aliH5Pay";
38 46  
... ... @@ -71,7 +79,7 @@ webAppH5.aliPayServer = &quot;/alipay/aliH5Pay&quot;;
71 79  
72 80 //小票二维码出场
73 81 //http://39.98.54.240/codepay/index.html?appid=0&lotId=1&payConfigId=2&receiptNo=3
74   -//http://localhost:1260/codepay/index.html?appid=0&lotId=1&payConfigId=2&receiptNo=3
  82 +//http://localhost:1260/codepay/index.html?appid=0&lotId=3504&payConfigId=2&receiptNo=3&
75 83  
76 84  
77 85 //首页
... ... @@ -89,5 +97,22 @@ webAppH5.aliPayServer = &quot;/alipay/aliH5Pay&quot;;
89 97  
90 98 //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
91 99  
  100 +/*正式环境前缀*/
  101 +//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay
  102 +
  103 +/*
  104 +lotId -->parkingId
  105 +receiptNo --> carNumber 车牌号
  106 +direction 固定 1
  107 +codeType 固定 1
  108 +terminalSource 固定 7
  109 +channelId 固定 小票二维码
  110 +*/
  111 +//http://localhost:1260/dynCodePay.html?appid=0&lotId=3504&payConfigId=2&receiptNo=%E8%92%99D9203C
  112 +//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/index.html?appid=0&lotId=3504&payConfigId=2&receiptNo=%E8%92%99D9203C
  113 +
  114 +//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/index.html?appid=0&lotId=3504&payConfigId=2&receiptNo=蒙D871R2
92 115  
  116 +/*类型1:codeType2动态二维码正式环境地址前缀*/
  117 +//http://wxgzh.renniting.cn/wechatwuxi/DEV/Threewf/codepay/index.html?codeType=2&isNeedPay=1&orderId=001&parkName=万达停车场&parkCode=a001&inparktime=2018-12-26 00:00:00&outtime=2018-12-26 10:00:00&staytime=360&orderFee=100&plateno=蒙DY2408
93 118  
... ...
1   -http://132.232.101.107/webApp/paywxali/index.html
2   -
3   -http://132.232.101.107/webApp/paywxali/demo.html
4   -判断当前手机端浏览器是微信还是支付宝
5   -
6   -
7   -
8   -
9   -调用微信和支付宝第三方接口方法总结
10   -https://blog.csdn.net/yufeng005/article/details/54583467
11   -
12   -
13   -
14   -ajax支付
15   -https://www.cnblogs.com/junjieok/p/4538580.html
16   -
17 1  
18 2  
19 3  
... ... @@ -51,3 +35,38 @@ http://39.98.54.240/codepay/index.html?plNo=P11011700C&amp;parkingId=1&amp;channelId=172
51 35 //测试服务器出场首页
52 36 http://39.98.54.240/codepay/index.html?plNo=P11011700C&parkingId=1&channelId=172198243&direction=1&codeType=0&expireDate=expireDate&extendData=extendData
53 37  
  38 +
  39 +
  40 +说明:
  41 +支付宝:后台返回form表单,直接支付,简单。
  42 +微信支付麻烦,1服务号需要配置支付目录;2:获取code;3:获取openid;4:获取参数;5:发起支付; JSAPI支付流程
  43 +
  44 +pay.html,先校验订单,在发起请求
  45 +
  46 +//小票固定参数
  47 +[billCodePay.html,扫码二维码,纸质]
  48 +对应关系:
  49 +lotId -->parkingId 停车场编号
  50 +receiptNo --> carNumber 车牌号
  51 +direction 固定 1
  52 +codeType 固定 1
  53 +terminalSource 固定 7
  54 +channelId 固定 小票二维码
  55 +
  56 +
  57 +//动态二维码[dynCodePay.html]
  58 +String qrcodeType;//2-动态二维码
  59 +private Boolean isNeedPay=true;
  60 +private String orderId;//订单号
  61 +private String parkName;//停车场名称
  62 +private String parkCode;//停车场编号
  63 +private String inparktime;//进场时间 格式:yyyy-MM-dd HH:mm:ss
  64 +private String outtime;//出场时间 格式:yyyy-MM-dd HH:mm:ss
  65 +private String staytime;//停车时长1
  66 +private String orderFee;//本次出场实际应付金额(减去折扣,优惠券等之后的应付金额)分
  67 +private String plateno;// 车牌号
  68 +
  69 +?codeType=2&isNeedPay=1&orderId=001&parkName=万达停车场&parkCode=a001&inparktime=2018-12-26 00:00:00&outtime=2018-12-26 10:00:00&staytime=1&orderFee=100&plateno=蒙DY2408
  70 +
  71 +
  72 +
... ...
dynCodePay.html
... ... @@ -13,12 +13,11 @@
13 13 <meta http-equiv="Cache-control" content="no-cache">
14 14 <meta http-equiv="Cache" content="no-cache">
15 15 <meta http-equiv="Expires" content="0">
16   - <link rel="stylesheet" href="css/index.css?v=0.1">
17   - <script src="config.js?v=0.1"></script>
18   - <script src="js/common.js?v=0.1"></script>
19   - <script src="js/dynCodePay.js?v=0.1"></script>
20   - <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>-->
21   - <!--<script src="config.js"></script>-->
  16 + <link rel="stylesheet" href="css/index.css?v=0.10">
  17 + <script src="config.js?v=0.10"></script>
  18 + <script src="js/common.js?v=0.10"></script>
  19 + <script src="js/dynCodePay.js?v=0.10"></script>
  20 + <!--<script src="config.js"></script>-->
22 21 <!--
23 22 Notice the use of %PUBLIC_URL% in the tags above.
24 23 It will be replaced with the URL of the `public` folder during the build.
... ... @@ -44,10 +43,10 @@
44 43 <div><span>车场名称:</span><span id="parkName"></span><a id="linkPayDetail">详情+</a> </div>
45 44 <div><span>停车时长:</span><span id="staytime"></span></div>
46 45 <div><span>进场时间:</span><span id="inparktime"></span></div>
47   - <div><span>停车总费用:</span><span id="due"></span></div>
48   - <div><span>已支付金额:</span><span id="paid"></span></div>
49   - <div><span>优惠金额:</span><span id="discountFee"></span><span id="discountDesc"></span></div>
50   - <div><span>订单编号: </span><span id="orderNum">1234567890</span> </div>
  46 + <!--<div><span>停车总费用:</span><span id="due"></span></div>-->
  47 + <!--<div><span>已支付金额:</span><span id="paid"></span></div>-->
  48 + <!--<div><span>优惠金额:</span><span id="discountFee"></span><span id="discountDesc"></span></div>-->
  49 + <div><span>订单编号: </span><span id="orderNum"></span> </div>
51 50 </section>
52 51 <section id="section" class="marginTop">
53 52 <div class="flexBoxRow">
... ... @@ -81,18 +80,8 @@
81 80 <div class="btnOK" id="btnPayOK">确定支付</div>
82 81 <img src="img/loading.gif" id="loading" style="display: none;" />
83 82 </footer>
84   - <section id="payTip" style="padding: 5px;margin-top:5px; color: #3385ff; font-size: 14px; "></section>
  83 + <!--<section id="payTip" style="padding: 5px;margin-top:5px; color: #3385ff; font-size: 14px; "></section>-->
85 84  
86   - <!--
87   - This HTML file is a template.
88   - If you open it directly in the browser, you will see an empty page.
89   -
90   - You can add webfonts, meta tags, or analytics to this file.
91   - The build step will place the bundled scripts into the <body> tag.
92   -
93   - To begin the development, run `npm start` or `yarn start`.
94   - To create a production bundle, use `npm run build` or `yarn build`.
95   - -->
96 85 </body>
97 86  
98 87 </html>
... ...
index.html
... ... @@ -66,16 +66,22 @@
66 66 }
67 67 //type[fail、sucesss]
68 68 function getResponse(params) {
  69 + //debugger;
69 70 var direction = params.direction;//direction=0 [通行方向 入:0,1:出 必填]
70 71 var queryParams = parseParams(params);
71   - //首先判断是否小票二维码标识位lotId
72   - if (typeof(params.lotId)!="undefined") {
73   - window.location.href = "dynCodePay.html?" + queryParams;
  72 + //小票二维码特殊处理[不带codeType]
  73 + if (typeof(params.lotId) != "undefined") {
  74 + window.location.href = "billCodePay.html?" + queryParams;
74 75 } else {
75   - if (direction == 0) {//入口
76   - window.location.href = "page/in.html?" + queryParams;
77   - } else {//出口
78   - window.location.href = "page/out.html?" + queryParams;
  76 + //跳转标识codeType[0静态码、1小票二维码、2动态二维码]
  77 + if (params.codeType == 2) {
  78 + window.location.href = "dynCodePay.html?" + queryParams;
  79 + } else {
  80 + if (direction == 0) {//入口
  81 + window.location.href = "page/in.html?" + queryParams;
  82 + } else {//出口
  83 + window.location.href = "page/out.html?" + queryParams;
  84 + }
79 85 }
80 86 }
81 87 }
... ...
js/billCodePay.js 0 → 100644
  1 +/*
  2 +@songcxa
  3 +@2018-12-14
  4 +@小票动态扫码移动支付
  5 +*/
  6 +var webAppParams = null;
  7 +var $btnObj = null;
  8 +var $btnLoad = null;
  9 +var webAppCode = null;//如果是微信,先获取微信code
  10 +window.onload = function () {
  11 + //var root = document.getElementById("root");
  12 + $btnObj = document.getElementById("btnPayOK");
  13 + $btnLoad = document.getElementById("loading");
  14 + $linkPayDetail = getObjectByID("linkPayDetail");
  15 + $linkPayDetail.onclick = webAppClass.linkPayDetailClick;
  16 + var webRoot = window.location.href;
  17 + //当前客户端浏览器模式[微信、支付宝、其他]
  18 + webAppClass.clientBrowser();
  19 + //绑定事件
  20 + var ali = document.getElementById("rowAliPay");
  21 + var wx = document.getElementById("rowWxPay");
  22 + ali.onclick = webAppClass.aliClick;
  23 + wx.onclick = webAppClass.wxClick;
  24 + $btnObj.onclick = webAppClass.okClick;
  25 + document.getElementById("payTip").innerHTML = "";
  26 + //参数
  27 + var tmpURLparams = getQueryString(window.location);
  28 + if (tmpURLparams != null) {
  29 + //设置UI参数
  30 + //webAppClass.setUI(webAppParams);
  31 + webAppClass.init(tmpURLparams);
  32 + } else {
  33 + alertMsg("没有接收到url参数信息");
  34 + }
  35 +
  36 + //获取微信code
  37 + //webAppClass.getCode();
  38 + var state = clientBrowserEx();
  39 + if (state == "wxPay") {
  40 + webAppCode = webAppClass.getCode();
  41 + }
  42 +}
  43 +/**/
  44 +var webAppClass = {
  45 + //appid={0}&lotId={1}&payConfigId={2}&receiptNo=
  46 + init: function (params) {
  47 + var urlParams = params;
  48 + var newParams = urlParams || {};
  49 + $btnObj.style.display = "none";
  50 + $btnLoad.style.display = "block";
  51 + newParams.terminalSource = "7";//1:任你听 3:微信公共号 4:云平台 7:H5
  52 + //var tmpParams = Object.assign(params, window.webAppH5.comParams, window.webAppH5.appOut);
  53 + newParams.parkingId = params.lotId;
  54 + newParams.carNumber = params.receiptNo;
  55 + var tmpParams = Object.assign(newParams, window.webAppH5.comParams, window.webAppH5.dynCode);
  56 + this.initRequest(webAppRoot + window.webAppH5.comServer, tmpParams, "init");
  57 + },
  58 + initRequest: function (url, params, init) {
  59 + var btnObj = $btnObj;
  60 + postRequest(url, params, function (res) {
  61 + btnObj.style.display = "block";
  62 + $btnLoad.style.display = "none";
  63 + if (res.code == 0) {//进场
  64 + //alertMsg("出场成功");
  65 + if (res.data) {
  66 + var tmpObj = res.data;
  67 + //判断是否需要支付
  68 + if (tmpObj.needPay) {
  69 + //var queryParams = parseParams(tmpObj);
  70 + //window.location.href = "../pay.html?" + queryParams;
  71 + webAppParams = tmpObj;
  72 + webAppClass.setUI(tmpObj);
  73 + } else {
  74 + var tipStr = "无需缴费,欢迎下次光临";
  75 + alertMsg(tipStr);
  76 + }
  77 + } else {
  78 + alertMsg("没有找到订单");
  79 + }
  80 + } else {//其他情况如【该卡号场内已存在】
  81 + console.log(res.message); alertMsg(res.message);
  82 + if ((init) != "init") { alertMsg(res.message); }
  83 + }
  84 + }, function (err) {
  85 + console.log("网络服务超时..." + url);
  86 + alertMsg("网络服务超时");
  87 + btnObj.style.display = "block";
  88 + $btnLoad.style.display = "none";
  89 + });
  90 + },
  91 + //OK
  92 + okClick: function (ev) {
  93 + document.getElementById("payTip").innerHTML = "";
  94 + if (webAppParams == null) {
  95 + alertMsg("暂无订单信息");return;
  96 + }
  97 + //先校验停车费用后缴费提交
  98 + webAppClass.checkParkCost();
  99 + },
  100 + //校验该订单当前支付时的费用(排除扫描订单后不支付时长)
  101 + checkParkCost: function () {
  102 + $btnObj.style.display = "none";
  103 + $btnLoad.style.display = "block";
  104 + if (typeof (webAppParams.queryOrderInfo) == "undefined") {//没有queryOrderInfo返回第一页
  105 + window.history.back(-1);
  106 + }
  107 + var tmpParams = JSON.parse(webAppParams.queryOrderInfo);
  108 + var url = webAppRoot + window.webAppH5.comServer;
  109 + postRequest(url, tmpParams, function (res) {
  110 + //btnObj.style.display = "block"; //$btnLoad.style.display = "none";
  111 + //$btnObj.style.display = "block";
  112 + if (res.code == 0) {//进场
  113 + var tmpObj = res.data;
  114 + if (tmpObj) {
  115 + webAppClass.setUI(tmpObj);
  116 + webAppParams = tmpObj;//重新赋值
  117 + webAppClass.okPay(tmpObj);//唤醒支付
  118 + } else {
  119 + alertMsg("没有找到相应订单");
  120 + }
  121 + } else {//其他情况如【该卡号场内已存在】
  122 + $btnLoad.style.display = "none";
  123 + $btnObj.style.display = "block";
  124 + console.log(res.message); alertMsg(res.message);
  125 + }
  126 + }, function (err) {
  127 + console.log("网络服务超时..." + url);
  128 + alertMsg("网络服务超时");
  129 + $btnLoad.style.display = "none";
  130 + $btnObj.style.display = "block";
  131 + //$btnLoad.style.display = "none";
  132 + });
  133 + },
  134 +
  135 + //确定支付
  136 + okPay: function (params) {
  137 + var orderID = params.orderId;//订单号
  138 + //var moneyID = document.getElementById("sumMoney").innerHTML = webAppParams.orderId;//订单号
  139 + var root = webAppRoot;
  140 + //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器]
  141 + var clientType = clientBrowserEx();
  142 + switch (clientType) {
  143 + case "wxPay"://微信[内置浏览器]
  144 + webAppClass.payAjaxJDK(orderID);
  145 + console.log("wxPay");//微信支付
  146 + break;
  147 + case "aliPay"://支付宝
  148 + console.log("aliPay");
  149 + //订单号
  150 + var obj = {};
  151 + //this.payAjax(url, { orderId: "11111", price: 0.01 });
  152 + var aliPay = webAppH5.aliPayServer;
  153 + var aliParams = webAppH5.comParams;
  154 + aliParams.orderId = orderID;
  155 + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  156 + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  157 + aliParams.paySrcType = 101;//101停车支付
  158 + webAppClass.payAliAjax(root + aliPay, aliParams);
  159 + break;
  160 + default://第三方浏览器other[]
  161 + //默认支付宝
  162 + if (document.getElementById("aliPay").checked) {
  163 + console.log("aliPay");
  164 + //订单号
  165 + var obj = {};
  166 + //this.payAjax(url, { orderId: "11111", price: 0.01 });
  167 + var aliPay = webAppH5.aliPayServer;
  168 + var aliParams = webAppH5.comParams;
  169 + aliParams.orderId = orderID;
  170 + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  171 + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  172 + aliParams.paySrcType = 101;//101停车支付
  173 + webAppClass.payAliAjax(root + aliPay, aliParams);
  174 + } else {//微信页面支付
  175 + var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096";
  176 + //window.location.href = url;
  177 + var wxPay = webAppH5.wxPayServer;
  178 + var wxParams = webAppH5.comParams;
  179 + wxParams.orderId = orderID;
  180 + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  181 + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  182 + webAppClass.payAjax(root + wxPay, wxParams);
  183 + console.log("wxPay");
  184 + }
  185 + break;
  186 + }
  187 + },
  188 + getCode: function () {
  189 + var appID = appWxID;
  190 + var code = getUrlParam('code');
  191 + var local = window.location.href;
  192 + //alert("local:" + local);
  193 + if (code == null || code === '') {
  194 + //alert(code);
  195 + 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'
  196 + } else {
  197 + //alert(code);
  198 + return code;
  199 + }
  200 + function getUrlParam(name) {
  201 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  202 + var r = window.location.search.substr(1).match(reg)
  203 + if (r != null) return unescape(r[2])
  204 + return null
  205 + }
  206 + },
  207 + //Ali
  208 + aliClick: function (ev) {
  209 + console.log("AliClick");
  210 + document.getElementById("aliPay").checked = true;
  211 + ev.preventDefault();
  212 + },
  213 + //Wx
  214 + wxClick: function (ev) {
  215 + console.log("wxClick");
  216 + document.getElementById("wxPay").checked = true;
  217 + ev.preventDefault();
  218 + },
  219 + //浏览器
  220 + clientBrowser: function () {
  221 + if (/MicroMessenger/.test(window.navigator.userAgent)) {
  222 + console.log("微信客户端");
  223 + this.switchShow("wxPay");
  224 + } else if (/AlipayClient/.test(window.navigator.userAgent)) {
  225 + console.log("支付宝客户端");
  226 + this.switchShow("aliPay");
  227 + } else {
  228 + console.log("其他浏览器");
  229 + this.switchShow("other");
  230 + }
  231 + },
  232 + //根据浏览器显示内容[aliPay、wxPay、other]
  233 + switchShow: function (type) {
  234 + var aliObj = document.getElementById("rowAliPay");
  235 + var wxObj = document.getElementById("rowWxPay");
  236 + var lineObj = document.getElementById("splitLine");
  237 + switch (type) {
  238 + case "aliPay":
  239 + lineObj.style.display = "none";
  240 + wxObj.style.display = "none";
  241 + document.getElementById("aliPay").checked = true;
  242 + break;
  243 + case "wxPay":
  244 + lineObj.style.display = "none";
  245 + aliObj.style.display = "none";
  246 + document.getElementById("wxPay").checked = true;
  247 + break;
  248 + default://其他浏览器[浏览器暂时屏蔽微信]
  249 + lineObj.style.display = "none";
  250 + wxObj.style.display = "none";
  251 + document.getElementById("aliPay").checked = true;
  252 + break;
  253 + }
  254 + },
  255 +
  256 + //异步请求-微信
  257 + payAjax: function (url, params) {
  258 + var btnOBj = $btnObj;
  259 + postRequest(url, params, function (res) {
  260 + btnOBj.style.display = "block";
  261 + $btnLoad.style.display = "none";
  262 + //debugger;
  263 + if (res.code == 0) {//进场
  264 + if (res.data) {
  265 + var tmpObj = res.data;
  266 + if (typeof (tmpObj.mwebUrl) != "undefined") {
  267 + window.location.href = tmpObj.mwebUrl + "&redirect_url=" + webAppPayResult;
  268 + } else {
  269 + alertMsg("没有返回支付地址mwebUrl");
  270 + }
  271 + console.log(JSON.stringify(tmpObj));
  272 + } else {
  273 + alertMsg("没有找到返回值");
  274 + }
  275 + } else {//其他情况如【该卡号场内已存在】
  276 + console.log(res.message);
  277 + alertMsg(res.message);
  278 + }
  279 + }, function (err) {
  280 + console.log("网络地址出错...");
  281 + alertMsg("网络地址出错...");
  282 + btnOBj.style.display = "block";
  283 + });
  284 + },
  285 +
  286 + payAjaxJDK: function (orderID) {
  287 + var btnOBj = $btnObj;
  288 + //0:页面初始化获取code[webAppCode]
  289 + var codeParams = { code: webAppCode, appId: appWxID };
  290 + var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer;
  291 + //alert(openIdUrl);
  292 + //1:有code获取OpenId
  293 + postRequest(openIdUrl, codeParams, function (res) {
  294 + //alert(JSON.stringify(res));
  295 + if (res.code == 0) {
  296 + //alert(res.data);
  297 + webAppClass.getPayParams(res.data, orderID);
  298 + } else {
  299 + alertMsg(res.message);
  300 + }
  301 + }, function (err) {
  302 + console.log("网络地址出错..." + openIdUrl);
  303 + });
  304 + //2:获取支付参数
  305 + //function getPayParams(openId) {
  306 +
  307 + //}
  308 + },
  309 + getPayParams: function (openId, orderID) {
  310 + var wxPay = window.webAppH5.wxPayServer;
  311 + var wxParams = window.webAppH5.comParams;
  312 + wxParams.orderId = orderID;
  313 + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  314 + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  315 + //webAppClass.payAjax(root + wxPay, wxParams);
  316 + wxParams.openId = openId;
  317 + wxParams.appId = appWxID;
  318 + var payParamsUrl = webAppRoot + window.webAppH5.wxPayServer;
  319 + //alert(payParamsUrl);alert(orderID);
  320 + postRequest(payParamsUrl, wxParams, function (res) {
  321 + $btnObj.style.display = "block";
  322 + $btnLoad.style.display = "none";
  323 + //debugger;
  324 + if (res.code == 0) {//进场
  325 + //alertMsg("出场成功");
  326 + if (res.data) {
  327 + var tmpObj = res.data;
  328 + webAppClass.weixinJSBridge(res.data);
  329 + console.log(JSON.stringify(tmpObj));
  330 + //alert(JSON.stringify(tmpObj));
  331 + } else {
  332 + alertMsg("没有找到返回值");
  333 + }
  334 + } else {
  335 + $btnObj.style.display = "block";
  336 + $btnLoad.style.display = "none";
  337 + console.log(res.message); alertMsg(res.message);
  338 + }
  339 + }, function (err) {
  340 + console.log("网络地址出错...");
  341 + alertMsg("网络地址出错..." + payParamsUrl);
  342 + $btnLoad.style.display = "none";
  343 + $btnObj.style.display = "block";
  344 + });
  345 + },
  346 + //调用微信内置WeixinJSBridge对象发起支付
  347 + weixinJSBridge: function (params) {
  348 + function onBridgeReady() {
  349 + WeixinJSBridge.invoke(
  350 + 'getBrandWCPayRequest', params,
  351 + function (res) {
  352 + //alert(res.err_msg);
  353 + if (res.err_msg == "get_brand_wcpay_request:ok") {
  354 + // 使用以上方式判断前端返回,微信团队郑重提示:
  355 + //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  356 + window.location.href = webAppPayResult + "?trade_no=" + "success";
  357 + }
  358 + else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
  359 + window.location.href = webAppPayResult + "?trade_no=" + "fail";
  360 + }
  361 + else {
  362 + alertMsg(JSON.stringify(res));
  363 + //alert(res.err_msg);
  364 + }
  365 + });
  366 + }
  367 + if (typeof WeixinJSBridge == "undefined") {
  368 + if (document.addEventListener) {
  369 + document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  370 + } else if (document.attachEvent) {
  371 + document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  372 + document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  373 + }
  374 + } else {
  375 + onBridgeReady();
  376 + }
  377 + },
  378 + //异步请求-支付宝
  379 + payAliAjax: function (url, params) {
  380 + var btnOBj = $btnObj;
  381 + postRequest(url, params, function (res) {
  382 + btnOBj.style.display = "block";
  383 + $btnLoad.style.display = "none";
  384 + if (res.code == 0) {//进场
  385 + document.write(res.data);//打开支付表单
  386 + } else {//其他情况如【该卡号场内已存在】
  387 + console.log(res.message);
  388 + alertMsg(res.message);
  389 + }
  390 + }, function (err) {
  391 + console.log("网络地址出错...");alertMsg("网络地址出错...");
  392 + $btnLoad.style.display = "none";
  393 + btnOBj.style.display = "block";
  394 + });
  395 + },
  396 +
  397 + //设置UI
  398 + setUI: function (params) {
  399 + var $carNum = getObjectByID("carNum"),//车牌号
  400 + $orderNum = getObjectByID("orderNum"),//订单号
  401 + $sumMoney = getObjectByID("sumMoney"),//实际应付金额
  402 + $outtime = getObjectByID("outtime"),//实际出场时间
  403 + $payTip = getObjectByID("payTip"),//支付提示
  404 +
  405 + $parkName = getObjectByID("parkName"),//车场名称
  406 + $inparktime = getObjectByID("inparktime"),//进场时间
  407 + $staytime = getObjectByID("staytime"),//停车时长
  408 + $due = getObjectByID("due"),//停车总费用
  409 +
  410 + $paid = getObjectByID("paid"),//已支付金额
  411 + $discountDesc = getObjectByID("discountDesc"),//8折优惠折扣费用
  412 + $discountFee = getObjectByID("discountFee");//优惠金额
  413 +
  414 + if (params != null && params!="") {
  415 + var price = keepTwoDecimalFull((params.orderFee / 100));//(params.orderFee / 100);
  416 + $carNum.innerHTML = params.plateno;//手机号
  417 + $orderNum.innerHTML = params.orderId;//订单号
  418 + $sumMoney.innerHTML = price;///params.orderFee//缴费金额
  419 + $outtime.innerHTML = params.outtime;//实际出场时间
  420 + //.appOrderTimeout
  421 + $payTip.innerHTML = "注意: " + params.appOrderTimeout;//请在支付完成10分钟内出场,如超时未出场,会继续计费。
  422 +
  423 + $parkName.innerHTML = params.parkName;
  424 + $inparktime.innerHTML = params.inparktime;
  425 + $staytime.innerHTML = formatSeconds(params.staytime);
  426 +
  427 + $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用
  428 + $paid.innerHTML = params.paid;
  429 + $discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额
  430 + $discountDesc.innerHTML = params.discountDesc;
  431 + } else {
  432 + console.log("没有接受到参数");
  433 + }
  434 + },
  435 +
  436 + //查看详情
  437 + linkPayDetailClick: function (ev) {
  438 + var $payDetail = getObjectByID("payDetail");
  439 + var $linkPayDetail = getObjectByID("linkPayDetail");
  440 + if ($linkPayDetail.innerHTML == "详情+") {
  441 + $linkPayDetail.innerHTML = "详情-";
  442 + $payDetail.style.height = "195px";
  443 + } else {
  444 + $linkPayDetail.innerHTML = "详情+";
  445 + $payDetail.style.height = "55px";
  446 + }
  447 + }
  448 +}
0 449 \ No newline at end of file
... ...
js/common.js
... ... @@ -215,4 +215,24 @@ function checkCharAndNumber(ev) {
215 215 //this.value = this.value.toUpperCase();
216 216 var tmpValue = this.value.replace(/[^\d|chun]/g, '');
217 217 this.value = this.value.toUpperCase();
218   -}
219 218 \ No newline at end of file
  219 +}
  220 +
  221 +/*检测当前app浏览器*/
  222 +function clientBrowserEx() {
  223 + var state = "other";//default
  224 + if (/MicroMessenger/.test(window.navigator.userAgent)) {
  225 + console.log("微信客户端");
  226 + //this.switchShow("wxPay");
  227 + state = "wxPay";
  228 + } else if (/AlipayClient/.test(window.navigator.userAgent)) {
  229 + console.log("支付宝客户端");
  230 + //this.switchShow("aliPay");
  231 + state = "aliPay";
  232 + } else {
  233 + console.log("其他浏览器");
  234 + state = "other";
  235 + }
  236 + return state;
  237 +}
  238 +
  239 +
... ...
js/dynCodePay.js
1 1 /*
2 2 @songcxa
3   -@2018-12-14
  3 +@2018-12-26
4 4 @小票动态扫码移动支付
  5 +@动态二维码url包括订单、金额、进出场时间、停车场编号、车牌号等
5 6 */
6   -var webAppParams = null;
  7 +var webAppParams = null;//URL参数
7 8 var $btnObj = null;
8 9 var $btnLoad = null;
9   -//var $btnLoad = document.getElementById("loading");
  10 +var webAppCode = null;//如果是微信,先获取微信code
10 11 window.onload = function () {
11   - //var root = document.getElementById("root");
12   - $btnObj = document.getElementById("btnPayOK");
13   - $btnLoad = document.getElementById("loading");
  12 + $btnObj = getObjectByID("btnPayOK");
  13 + $btnLoad = getObjectByID("loading");
14 14 $linkPayDetail = getObjectByID("linkPayDetail");
15 15 $linkPayDetail.onclick = webAppClass.linkPayDetailClick;
16 16 var webRoot = window.location.href;
17 17 //当前客户端浏览器模式[微信、支付宝、其他]
18 18 webAppClass.clientBrowser();
19 19 //绑定事件
20   - var ali = document.getElementById("rowAliPay");
21   - var wx = document.getElementById("rowWxPay");
  20 + var ali = getObjectByID("rowAliPay");
  21 + var wx = getObjectByID("rowWxPay");
22 22 ali.onclick = webAppClass.aliClick;
23 23 wx.onclick = webAppClass.wxClick;
24 24 $btnObj.onclick = webAppClass.okClick;
25   - document.getElementById("payTip").innerHTML = "";
  25 + //document.getElementById("payTip").innerHTML = "";
26 26 //参数
27 27 var tmpURLparams = getQueryString(window.location);
28 28 if (tmpURLparams != null) {
29   - //设置UI参数
30   - //webAppClass.setUI(webAppParams);
31   - webAppClass.init(tmpURLparams);
  29 + webAppParams = tmpURLparams;
  30 + webAppClass.setUI(webAppParams);
  31 + //webAppClass.init(tmpURLparams); //设置UI参数
32 32 } else {
33 33 alertMsg("没有接收到url参数信息");
34 34 }
  35 +
  36 + //获取微信code
  37 + //webAppClass.getCode();
  38 + var state = clientBrowserEx();
  39 + if (state == "wxPay") {
  40 + webAppCode = webAppClass.getCode();
  41 + }
35 42 }
36 43 /**/
37 44 var webAppClass = {
38   - //appid={0}&lotId={1}&payConfigId={2}&receiptNo=
39   - init: function (params) {
40   - var urlParams = params;
41   - var newParams = urlParams || {};
42   - $btnObj.style.display = "none";
43   - $btnLoad.style.display = "block";
44   - newParams.terminalSource = "7";//1:任你听 3:微信公共号 4:云平台 7:H5
45   - //var tmpParams = Object.assign(params, window.webAppH5.comParams, window.webAppH5.appOut);
46   - newParams.parkingId = params.lotId;
47   - newParams.carNumber = params.receiptNo;
48   - var tmpParams = Object.assign(newParams, window.webAppH5.comParams, window.webAppH5.dynCode);
49   - this.initRequest(webAppRoot + window.webAppH5.comServer, tmpParams, "init");
50   - },
51   - initRequest: function (url, params, init) {
52   - var btnObj = $btnObj;
53   - postRequest(url, params, function (res) {
54   - btnObj.style.display = "block";
55   - $btnLoad.style.display = "none";
56   - if (res.code == 0) {//进场
57   - //alertMsg("出场成功");
58   - if (res.data) {
59   - var tmpObj = res.data;
60   - //判断是否需要支付
61   - if (tmpObj.needPay) {
62   - //var queryParams = parseParams(tmpObj);
63   - //window.location.href = "../pay.html?" + queryParams;
64   - webAppParams = tmpObj;
65   - webAppClass.setUI(tmpObj);
66   - } else {
67   - var tipStr = "无需缴费,欢迎下次光临";
68   - alertMsg(tipStr);
69   - }
70   - } else {
71   - alertMsg("没有找到订单");
72   - }
73   - } else {//其他情况如【该卡号场内已存在】
74   - console.log(res.message); alertMsg(res.message);
75   - if ((init) != "init") { alertMsg(res.message); }
76   - }
77   - }, function (err) {
78   - console.log("网络服务超时..." + url);
79   - alertMsg("网络服务超时");
80   - btnObj.style.display = "block";
81   - $btnLoad.style.display = "none";
82   - });
83   - },
84 45 //OK
85 46 okClick: function (ev) {
86   - document.getElementById("payTip").innerHTML = "";
  47 + //document.getElementById("payTip").innerHTML = "";
87 48 if (webAppParams == null) {
88 49 alertMsg("暂无订单信息");return;
89 50 }
90   - //先校验停车费用后缴费提交
91   - webAppClass.checkParkCost();
92   - },
93   - //校验该订单当前支付时的费用(排除扫描订单后不支付时长)
94   - checkParkCost: function () {
95   - $btnObj.style.display = "none";
96   - $btnLoad.style.display = "block";
97   - if (typeof (webAppParams.queryOrderInfo) == "undefined") {//没有queryOrderInfo返回第一页
98   - window.history.back(-1);
99   - }
100   - var tmpParams = JSON.parse(webAppParams.queryOrderInfo);
101   - var url = webAppRoot + window.webAppH5.comServer;
102   - postRequest(url, tmpParams, function (res) {
103   - //btnObj.style.display = "block"; //$btnLoad.style.display = "none";
104   - //$btnObj.style.display = "block";
105   - if (res.code == 0) {//进场
106   - var tmpObj = res.data;
107   - if (tmpObj) {
108   - webAppClass.setUI(tmpObj);
109   - webAppParams = tmpObj;//重新赋值
110   - webAppClass.okPay(tmpObj);//唤醒支付
111   - } else {
112   - alertMsg("没有找到相应订单");
113   - }
114   - } else {//其他情况如【该卡号场内已存在】
115   - $btnLoad.style.display = "none";
116   - $btnObj.style.display = "block";
117   - console.log(res.message); alertMsg(res.message);
118   - }
119   - }, function (err) {
120   - console.log("网络服务超时..." + url);
121   - alertMsg("网络服务超时");
122   - $btnLoad.style.display = "none";
123   - $btnObj.style.display = "block";
124   - //$btnLoad.style.display = "none";
125   - });
  51 + //支付方式判断
  52 + webAppClass.okPay(webAppParams);
126 53 },
127 54  
128 55 //确定支付
129 56 okPay: function (params) {
130 57 var orderID = params.orderId;//订单号
131   - //var moneyID = document.getElementById("sumMoney").innerHTML = webAppParams.orderId;//订单号
  58 + //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器]
  59 + var clientType = clientBrowserEx();
  60 + switch (clientType) {
  61 + case "wxPay"://微信[内置浏览器]
  62 + webAppClass.payAjaxJDK(orderID);console.log("wxPay");//微信支付
  63 + break;
  64 + case "aliPay"://支付宝
  65 + webAppClass.payAliOption(orderID); console.log("aliPay");
  66 + break;
  67 + default://第三方浏览器other[暂只支持支付宝]
  68 + webAppClass.payAliOption(orderID);
  69 + break;
  70 + }
  71 + },
  72 + //支付宝支付参数
  73 + payAliOption: function (orderID) {
132 74 var root = webAppRoot;
133   - //默认支付宝
134   - if (document.getElementById("aliPay").checked) {
135   - console.log("aliPay");
136   - //订单号
137   - var obj = {};
138   - //this.payAjax(url, { orderId: "11111", price: 0.01 });
139   - var aliPay = webAppH5.aliPayServer;
140   - var aliParams = webAppH5.comParams;
141   - aliParams.orderId = orderID;
142   - aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
143   - aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
144   - aliParams.paySrcType = 101;//101停车支付
145   - webAppClass.payAliAjax(root + aliPay, aliParams);
146   - } else {//微信
147   - var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096";
148   - //window.location.href = url;
149   - var wxPay = webAppH5.wxPayServer;
150   - var wxParams = webAppH5.comParams;
151   - wxParams.orderId = orderID;
152   - wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
153   - wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
154   - webAppClass.payAjax(root + wxPay, wxParams);
155   - console.log("wxPay");
  75 + var aliPay = webAppH5.aliPayServer;
  76 + var aliParams = webAppH5.comParams;
  77 + aliParams.orderId = orderID;
  78 + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  79 + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  80 + aliParams.paySrcType = 101;//101停车支付
  81 + webAppClass.payAliAjax(root + aliPay, aliParams);
  82 + },
  83 + //获取微信code
  84 + getCode: function () {
  85 + var appID = appWxID;
  86 + var code = getUrlParam('code');
  87 + var local = window.location.href;
  88 + //alert("local:" + local);
  89 + if (code == null || code === '') {
  90 + //alert(code);
  91 + 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'
  92 + } else {
  93 + return code;
  94 + }
  95 + function getUrlParam(name) {
  96 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  97 + var r = window.location.search.substr(1).match(reg)
  98 + if (r != null) return unescape(r[2])
  99 + return null
156 100 }
157 101 },
158   -
159 102 //Ali
160 103 aliClick: function (ev) {
161 104 console.log("AliClick");
... ... @@ -170,15 +113,17 @@ var webAppClass = {
170 113 },
171 114 //浏览器
172 115 clientBrowser: function () {
173   - if (/MicroMessenger/.test(window.navigator.userAgent)) {
174   - console.log("微信客户端");
175   - this.switchShow("wxPay");
176   - } else if (/AlipayClient/.test(window.navigator.userAgent)) {
177   - console.log("支付宝客户端");
178   - this.switchShow("aliPay");
179   - } else {
180   - console.log("其他浏览器");
181   - this.switchShow("other");
  116 + var type = clientBrowserEx();
  117 + switch (type) {
  118 + case "aliPay":
  119 + this.switchShow("aliPay"); console.log("支付宝客户端");
  120 + break;
  121 + case "wxPay":
  122 + this.switchShow("wxPay"); console.log("微信客户端");
  123 + break;
  124 + default://other
  125 + this.switchShow("other"); console.log("其他浏览器");
  126 + break;
182 127 }
183 128 },
184 129 //根据浏览器显示内容[aliPay、wxPay、other]
... ... @@ -197,7 +142,10 @@ var webAppClass = {
197 142 aliObj.style.display = "none";
198 143 document.getElementById("wxPay").checked = true;
199 144 break;
200   - default://其他浏览器
  145 + default://其他浏览器[浏览器暂时屏蔽微信]
  146 + lineObj.style.display = "none";
  147 + wxObj.style.display = "none";
  148 + document.getElementById("aliPay").checked = true;
201 149 break;
202 150 }
203 151 },
... ... @@ -232,41 +180,129 @@ var webAppClass = {
232 180 });
233 181 },
234 182  
  183 + payAjaxJDK: function (orderID) {
  184 + //0:页面初始化获取code[webAppCode]
  185 + var codeParams = { code: webAppCode, appId: appWxID };
  186 + var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer;
  187 + $btnObj.style.display = "none"; $btnLoad.style.display = "block";
  188 + //1:有code获取OpenId
  189 + postRequest(openIdUrl, codeParams, function (res) {
  190 + $btnObj.style.display = "block"; $btnLoad.style.display = "none";
  191 + //alert(JSON.stringify(res));
  192 + if (res.code == 0) {
  193 + webAppClass.getPayParams(res.data, orderID);
  194 + } else {
  195 + alertMsg(res.message);
  196 + }
  197 + }, function (err) {
  198 + $btnObj.style.display = "block"; $btnLoad.style.display = "none";
  199 + console.log("网络地址出错..." + openIdUrl);
  200 + });
  201 + },
  202 + getPayParams: function (openId, orderID) {
  203 + var wxPay = window.webAppH5.wxPayServer;
  204 + var wxParams = window.webAppH5.comParams;
  205 + wxParams.orderId = orderID;
  206 + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  207 + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  208 + //webAppClass.payAjax(root + wxPay, wxParams);
  209 + wxParams.openId = openId;
  210 + wxParams.appId = appWxID;
  211 + var payParamsUrl = webAppRoot + window.webAppH5.wxPayServer;
  212 + //alert(payParamsUrl);alert(orderID);
  213 + $btnObj.style.display = "none"; $btnLoad.style.display = "block";
  214 + postRequest(payParamsUrl, wxParams, function (res) {
  215 + $btnObj.style.display = "block"; $btnLoad.style.display = "none";
  216 + //debugger;
  217 + if (res.code == 0) {//进场
  218 + //alertMsg("出场成功");
  219 + if (res.data) {
  220 + var tmpObj = res.data;
  221 + webAppClass.weixinJSBridge(res.data);//唤醒wx支付
  222 + console.log(JSON.stringify(tmpObj));
  223 + //alert(JSON.stringify(tmpObj));
  224 + } else {
  225 + alertMsg("没有找到返回值");
  226 + }
  227 + } else {
  228 + $btnObj.style.display = "block";$btnLoad.style.display = "none";
  229 + console.log(res.message); alertMsg(res.message);
  230 + }
  231 + }, function (err) {
  232 + console.log("网络地址出错...");
  233 + alertMsg("网络地址出错..." + payParamsUrl);
  234 + $btnObj.style.display = "block"; $btnLoad.style.display = "none";
  235 + });
  236 + },
  237 + //调用微信内置WeixinJSBridge对象发起支付
  238 + weixinJSBridge: function (params) {
  239 + function onBridgeReady() {
  240 + WeixinJSBridge.invoke(
  241 + 'getBrandWCPayRequest', params,
  242 + function (res) {
  243 + //alert(res.err_msg);
  244 + if (res.err_msg == "get_brand_wcpay_request:ok") {
  245 + // 使用以上方式判断前端返回,微信团队郑重提示:
  246 + //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  247 + window.location.href = webAppPayResult + "?trade_no=" + "success";
  248 + }
  249 + else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
  250 + window.location.href = webAppPayResult + "?trade_no=" + "fail";
  251 + }
  252 + else {
  253 + alertMsg(JSON.stringify(res));
  254 + //alert(res.err_msg);
  255 + }
  256 + });
  257 + }
  258 + if (typeof WeixinJSBridge == "undefined") {
  259 + if (document.addEventListener) {
  260 + document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  261 + } else if (document.attachEvent) {
  262 + document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  263 + document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  264 + }
  265 + } else {
  266 + onBridgeReady();
  267 + }
  268 + },
235 269 //异步请求-支付宝
236 270 payAliAjax: function (url, params) {
237   - var btnOBj = $btnObj;
  271 + $btnObj.style.display = "none"; $btnLoad.style.display = "block";
238 272 postRequest(url, params, function (res) {
239   - btnOBj.style.display = "block";
240   - $btnLoad.style.display = "none";
241   - if (res.code == 0) {//进场
242   - document.write(res.data);//打开支付表单
243   - } else {//其他情况如【该卡号场内已存在】
244   - console.log(res.message);
245   - alertMsg(res.message);
  273 + $btnObj.style.display = "block"; $btnLoad.style.display = "none";
  274 + if (res !=null) {
  275 + if (res.code == 0) {//进场
  276 + document.write(res.data);//打开支付表单
  277 + } else {//其他情况如【该卡号场内已存在】
  278 + console.log(res.message);
  279 + alertMsg(res.message);
  280 + }
  281 + } else {
  282 + alertMsg("没有找到次订单信息");
246 283 }
247 284 }, function (err) {
248 285 console.log("网络地址出错...");alertMsg("网络地址出错...");
249   - $btnLoad.style.display = "none";
250   - btnOBj.style.display = "block";
  286 + $btnObj.style.display = "block"; $btnLoad.style.display = "none";
251 287 });
252 288 },
253 289  
254   - //设置UI
  290 + //设置UI参数[订单、金额、停车场名称及编号]
255 291 setUI: function (params) {
256 292 var $carNum = getObjectByID("carNum"),//车牌号
257 293 $orderNum = getObjectByID("orderNum"),//订单号
258 294 $sumMoney = getObjectByID("sumMoney"),//实际应付金额
259 295 $outtime = getObjectByID("outtime"),//实际出场时间
260   - $payTip = getObjectByID("payTip"),//支付提示
  296 + //$payTip = getObjectByID("payTip"),//支付提示
261 297  
262 298 $parkName = getObjectByID("parkName"),//车场名称
263 299 $inparktime = getObjectByID("inparktime"),//进场时间
264   - $staytime = getObjectByID("staytime"),//停车时长
265   - $due = getObjectByID("due"),//停车总费用
  300 + $staytime = getObjectByID("staytime");//停车时长
266 301  
267   - $paid = getObjectByID("paid"),//已支付金额
268   - $discountDesc = getObjectByID("discountDesc"),//8折优惠折扣费用
269   - $discountFee = getObjectByID("discountFee");//优惠金额
  302 + //$due = getObjectByID("due"),//停车总费用
  303 + //$paid = getObjectByID("paid"),//已支付金额
  304 + //$discountDesc = getObjectByID("discountDesc"),//8折优惠折扣费用
  305 + //$discountFee = getObjectByID("discountFee");//优惠金额
270 306  
271 307 if (params != null && params!="") {
272 308 var price = keepTwoDecimalFull((params.orderFee / 100));//(params.orderFee / 100);
... ... @@ -275,16 +311,16 @@ var webAppClass = {
275 311 $sumMoney.innerHTML = price;///params.orderFee//缴费金额
276 312 $outtime.innerHTML = params.outtime;//实际出场时间
277 313 //.appOrderTimeout
278   - $payTip.innerHTML = "注意: " + params.appOrderTimeout;//请在支付完成10分钟内出场,如超时未出场,会继续计费。
  314 + //$payTip.innerHTML = "注意: " + params.appOrderTimeout;//请在支付完成10分钟内出场,如超时未出场,会继续计费。
279 315  
280 316 $parkName.innerHTML = params.parkName;
281 317 $inparktime.innerHTML = params.inparktime;
282 318 $staytime.innerHTML = formatSeconds(params.staytime);
283 319  
284   - $due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用
285   - $paid.innerHTML = params.paid;
286   - $discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额
287   - $discountDesc.innerHTML = params.discountDesc;
  320 + //$due.innerHTML = keepTwoDecimalFull((params.due / 100));//停车总费用
  321 + //$paid.innerHTML = params.paid;
  322 + //$discountFee.innerHTML = keepTwoDecimalFull((params.discountFee / 100));//优惠金额
  323 + //$discountDesc.innerHTML = params.discountDesc;
288 324 } else {
289 325 console.log("没有接受到参数");
290 326 }
... ... @@ -296,7 +332,7 @@ var webAppClass = {
296 332 var $linkPayDetail = getObjectByID("linkPayDetail");
297 333 if ($linkPayDetail.innerHTML == "详情+") {
298 334 $linkPayDetail.innerHTML = "详情-";
299   - $payDetail.style.height = "195px";
  335 + $payDetail.style.height = "110px";
300 336 } else {
301 337 $linkPayDetail.innerHTML = "详情+";
302 338 $payDetail.style.height = "55px";
... ...
js/pay.js
... ... @@ -6,6 +6,7 @@
6 6 var webAppParams = null;
7 7 var $btnObj = null;
8 8 var $btnLoad = null;
  9 +var webAppCode = null;//如果是微信,先获取微信code
9 10 //var $btnLoad = document.getElementById("loading");
10 11 window.onload = function () {
11 12 //var root = document.getElementById("root");
... ... @@ -14,7 +15,7 @@ window.onload = function () {
14 15 $linkPayDetail = getObjectByID("linkPayDetail");
15 16 $linkPayDetail.onclick = webAppClass.linkPayDetailClick;
16 17 var webRoot = window.location.href;
17   - //当前客户端浏览器模式[微信、支付宝、其他]
  18 + //设置当前客户端浏览器模式[微信、支付宝、其他]
18 19 webAppClass.clientBrowser();
19 20 //绑定事件
20 21 var ali = document.getElementById("rowAliPay");
... ... @@ -31,6 +32,13 @@ window.onload = function () {
31 32 } else {
32 33 alertMsg("暂无订单信息");
33 34 }
  35 +
  36 + //获取微信code
  37 + //webAppClass.getCode();
  38 + var state = clientBrowserEx();
  39 + if (state == "wxPay") {
  40 + webAppCode = webAppClass.getCode();
  41 + }
34 42 }
35 43 /**/
36 44 var webAppClass = {
... ... @@ -83,32 +91,86 @@ var webAppClass = {
83 91 var orderID = params.orderId;//订单号
84 92 //var moneyID = document.getElementById("sumMoney").innerHTML = webAppParams.orderId;//订单号
85 93 var root = webAppRoot;
86   - //默认支付宝
87   - if (document.getElementById("aliPay").checked) {
88   - console.log("aliPay");
89   - //订单号
90   - var obj = {};
91   - //this.payAjax(url, { orderId: "11111", price: 0.01 });
92   - var aliPay = webAppH5.aliPayServer;
93   - var aliParams = webAppH5.comParams;
94   - aliParams.orderId = orderID;
95   - aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
96   - aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
97   - aliParams.paySrcType = 101;//101停车支付
98   - webAppClass.payAliAjax(root + aliPay, aliParams);
99   - } else {//微信
100   - var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096";
101   - //window.location.href = url;
102   - var wxPay = webAppH5.wxPayServer;
103   - var wxParams = webAppH5.comParams;
104   - wxParams.orderId = orderID;
105   - wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
106   - wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
107   - webAppClass.payAjax(root + wxPay, wxParams);
108   - console.log("wxPay");
  94 + //第一首先判断当前哪种浏览器方式[微信内置、支付宝内置、第三方浏览器]
  95 + var clientType = clientBrowserEx();
  96 + //alert(clientType);
  97 + switch (clientType) {
  98 + case "wxPay"://微信[内置浏览器]
  99 + //var wxPay = webAppH5.wxPayServer;
  100 + //var wxParams = webAppH5.comParams;
  101 + //wxParams.orderId = orderID;
  102 + //wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  103 + //wxParams.terminalSource = 3;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  104 + webAppClass.payAjaxJDK(orderID);
  105 + console.log("wxPay");//微信支付
  106 + break;
  107 + case "aliPay"://支付宝
  108 + console.log("aliPay");
  109 + //订单号
  110 + var obj = {};
  111 + //this.payAjax(url, { orderId: "11111", price: 0.01 });
  112 + var aliPay = webAppH5.aliPayServer;
  113 + var aliParams = webAppH5.comParams;
  114 + aliParams.orderId = orderID;
  115 + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  116 + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  117 + aliParams.paySrcType = 101;//101停车支付
  118 + webAppClass.payAliAjax(root + aliPay, aliParams);
  119 + break;
  120 + default://第三方浏览器other
  121 + //默认支付宝
  122 + if (document.getElementById("aliPay").checked) {
  123 + console.log("aliPay");
  124 + //订单号
  125 + var obj = {};
  126 + //this.payAjax(url, { orderId: "11111", price: 0.01 });
  127 + var aliPay = webAppH5.aliPayServer;
  128 + var aliParams = webAppH5.comParams;
  129 + aliParams.orderId = orderID;
  130 + aliParams.payType = 1;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  131 + aliParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  132 + aliParams.paySrcType = 101;//101停车支付
  133 + webAppClass.payAliAjax(root + aliPay, aliParams);
  134 + } else {//微信页面支付
  135 + var url = " https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx20161110163838f231619da20804912345&package=1037687096";
  136 + //window.location.href = url;
  137 + var wxPay = webAppH5.wxPayServer;
  138 + var wxParams = webAppH5.comParams;
  139 + wxParams.orderId = orderID;
  140 + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  141 + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  142 + webAppClass.payAjax(root + wxPay, wxParams);
  143 + console.log("wxPay");
  144 + }
  145 + break;
109 146 }
110 147 },
111 148  
  149 + getCode: function () {
  150 + var appID = appWxID;
  151 + var code = getUrlParam('code');
  152 + var local = window.location.href;
  153 + //alert("local:" + local);
  154 + if (code == null || code === '') {
  155 + //alert(code);
  156 + 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'
  157 + //window.event.returnValue = false;
  158 + //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');
  159 + //alert("22");
  160 + } else {
  161 + //getOpenId(code); //把code传给后台获取用户信息
  162 + //alert(code);
  163 + //webAppCode = code;
  164 + return code;
  165 + }
  166 +
  167 + function getUrlParam(name) {
  168 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  169 + var r = window.location.search.substr(1).match(reg)
  170 + if (r != null) return unescape(r[2])
  171 + return null
  172 + }
  173 + },
112 174 //Ali
113 175 aliClick: function (ev) {
114 176 console.log("AliClick");
... ... @@ -150,12 +212,15 @@ var webAppClass = {
150 212 aliObj.style.display = "none";
151 213 document.getElementById("wxPay").checked = true;
152 214 break;
153   - default://其他浏览器
  215 + default://其他浏览器[浏览器暂时屏蔽微信]
  216 + lineObj.style.display = "none";
  217 + wxObj.style.display = "none";
  218 + document.getElementById("aliPay").checked = true;
154 219 break;
155 220 }
156 221 },
157 222  
158   - //异步请求-微信
  223 + //异步请求-微信H5页面
159 224 payAjax: function (url, params) {
160 225 var btnOBj = $btnObj;
161 226 postRequest(url, params, function (res) {
... ... @@ -182,9 +247,112 @@ var webAppClass = {
182 247 }, function (err) {
183 248 console.log("网络地址出错...");
184 249 alertMsg("网络地址出错...");
  250 + $btnLoad.style.display = "none";
185 251 btnOBj.style.display = "block";
186 252 });
187 253 },
  254 + //异步请求-微信JDK调用
  255 + payAjaxJDK: function (orderID) {
  256 + var btnOBj = $btnObj;
  257 + //0:页面初始化获取code[webAppCode]
  258 + var codeParams = { code: webAppCode, appId: appWxID };
  259 + var openIdUrl = webAppRoot + window.webAppH5.wxGetOpenIdServer;
  260 + //alert(openIdUrl);
  261 + //1:有code获取OpenId
  262 + postRequest(openIdUrl, codeParams, function (res) {
  263 + //alert(JSON.stringify(res));
  264 + if (res.code == 0) {
  265 + //alert(res.data);
  266 + webAppClass.getPayParams(res.data, orderID);
  267 + } else {
  268 + alertMsg(res.message);
  269 + }
  270 + }, function (err) {
  271 + console.log("网络地址出错..." + openIdUrl);
  272 + });
  273 + //2:获取支付参数
  274 + //function getPayParams(openId) {
  275 +
  276 + //}
  277 + },
  278 + getPayParams: function (openId, orderID) {
  279 + var wxPay = window.webAppH5.wxPayServer;
  280 + var wxParams = window.webAppH5.comParams;
  281 + wxParams.orderId = orderID;
  282 + wxParams.payType = 4;// 1:支付宝 2:微信 3:银联 10:H5 4微信公众号
  283 + wxParams.terminalSource = 7;//请求端来源 1: 任你停 2:pda 3:微信公共号 7:H5扫码 10页面支付
  284 + //webAppClass.payAjax(root + wxPay, wxParams);
  285 + wxParams.openId = openId;
  286 + wxParams.appId = appWxID;
  287 + var payParamsUrl = webAppRoot + window.webAppH5.wxPayServer;
  288 + //alert(payParamsUrl);alert(orderID);
  289 + postRequest(payParamsUrl, wxParams, function (res) {
  290 + $btnObj.style.display = "block";
  291 + $btnLoad.style.display = "none";
  292 + //debugger;
  293 + if (res.code == 0) {//进场
  294 + //alertMsg("出场成功");
  295 + if (res.data) {
  296 + var tmpObj = res.data;
  297 + webAppClass.weixinJSBridge(res.data);
  298 + console.log(JSON.stringify(tmpObj));
  299 + //alert(JSON.stringify(tmpObj));
  300 + } else {
  301 + alertMsg("没有找到返回值");
  302 + }
  303 + } else {
  304 + $btnLoad.style.display = "none";
  305 + $btnObj.style.display = "block";
  306 + console.log(res.message); alertMsg(res.message);
  307 + }
  308 + }, function (err) {
  309 + console.log("网络地址出错...");
  310 + alertMsg("网络地址出错..." + payParamsUrl);
  311 + $btnLoad.style.display = "none";
  312 + $btnObj.style.display = "block";
  313 + });
  314 + },
  315 +
  316 + //调用微信内置WeixinJSBridge对象发起支付
  317 + weixinJSBridge: function (params) {
  318 + function onBridgeReady() {
  319 + WeixinJSBridge.invoke(
  320 + 'getBrandWCPayRequest', params,
  321 + //'getBrandWCPayRequest', {
  322 + // "appId": appWxID, //公众号名称,由商户传入
  323 + // "timeStamp": "1395712654", //时间戳,自1970年以来的秒数
  324 + // "nonceStr": "e61463f8efa94090b1f366cccfbbb444", //随机串
  325 + // "package": "prepay_id=u802345jgfjsdfgsdg888",
  326 + // "signType": "MD5", //微信签名方式:
  327 + // "paySign": "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名
  328 + //},
  329 + function (res) {
  330 + //alert(res.err_msg);
  331 + if (res.err_msg == "get_brand_wcpay_request:ok") {
  332 + // 使用以上方式判断前端返回,微信团队郑重提示:
  333 + //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  334 + window.location.href = webAppPayResult+"?trade_no=" + "success";
  335 + }
  336 + else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
  337 + window.location.href = webAppPayResult + "?trade_no=" + "fail";
  338 + }
  339 + else {
  340 + alertMsg(JSON.stringify(res));
  341 + //alert(res.err_msg);
  342 + }
  343 + });
  344 + }
  345 + if (typeof WeixinJSBridge == "undefined") {
  346 + if (document.addEventListener) {
  347 + document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  348 + } else if (document.attachEvent) {
  349 + document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  350 + document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  351 + }
  352 + } else {
  353 + onBridgeReady();
  354 + }
  355 + },
188 356  
189 357 //异步请求-支付宝
190 358 payAliAjax: function (url, params) {
... ...
page/alipayResult.html
... ... @@ -51,6 +51,8 @@
51 51 console.log(JSON.stringify(tmpParams));
52 52 if (tmpParams.trade_no != "") {
53 53 getResponse("success");
  54 + } else {
  55 + getResponse("fail");
54 56 }
55 57 //alertMsg("支付返回参数:" + JSON.stringify(tmpParams));
56 58 } else {
... ...
page/wxpayResult.html
... ... @@ -49,8 +49,10 @@
49 49 var tmpParams = getQueryString(window.location);
50 50 if (tmpParams != null) {
51 51 console.log(JSON.stringify(tmpParams));
52   - if (tmpParams.trade_no != "") {
  52 + if (tmpParams.trade_no == "success") {
53 53 getResponse("success");
  54 + } else {
  55 + getResponse("fail");
54 56 }
55 57 //alertMsg("支付返回参数:" + JSON.stringify(tmpParams));
56 58 } else {
... ...
pay.html
... ... @@ -16,7 +16,8 @@
16 16 <link rel="stylesheet" href="css/index.css?v=0.1">
17 17 <script src="config.js?v=0.1"></script>
18 18 <script src="js/common.js?v=0.1"></script>
19   - <script src="js/pay.js?v=0.1"></script>
  19 + <!--<script src="js/jweixin-1.0.0.js?v=0.1"></script>-->
  20 + <script src="js/pay.js?v=0.110"></script>
20 21 <!--<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>-->
21 22 <!--<script src="config.js"></script>-->
22 23 <!--
... ...