Browse Source

h5支付操作

tang 4 years ago
parent
commit
1251a6013d
2 changed files with 21 additions and 5 deletions
  1. 20 0
      Paytocomplete.html
  2. 1 5
      index.html

+ 20 - 0
Paytocomplete.html

@@ -73,6 +73,26 @@
73
 </body>
73
 </body>
74
 
74
 
75
 </html>
75
 </html>
76
+<script>
77
+    var userpay = parseParms()
78
+    //hash参数转对象
79
+    function parseParms() {
80
+        var str = window.location.href.split("?")[1];
81
+        var pieces = str.split("&"), data = {}, i, parts;
82
+        // process each query pair
83
+        for (i = 0; i < pieces.length; i++) {
84
+            parts = pieces[i].split("=");
85
+            if (parts.length < 2) {
86
+                parts.push("");
87
+            }
88
+            data[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
89
+        }
90
+        return data
91
+    }
92
+    var zfbuserpay;
93
+    zfbuserpay = JSON.parse(userpay.result)
94
+    alert(zfbuserpay)
95
+</script>
76
 <style>
96
 <style>
77
     body {
97
     body {
78
 
98
 

+ 1 - 5
index.html

@@ -457,10 +457,6 @@
457
                     signType: signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
457
                     signType: signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
458
                     paySign: paysign, // 支付签名
458
                     paySign: paysign, // 支付签名
459
                     success: (res) => {
459
                     success: (res) => {
460
-                        if(res.err_msg == "get_brand_wcpay_request:ok"){
461
-                            alert("支付成功");
462
-                            //点支付成功,就到这里进行跳转,这里可以写需要跳转得地址
463
-                        }
464
                         // 支付成功后的回调函数
460
                         // 支付成功后的回调函数
465
                         // location.replace("./Paytocomplete.html")
461
                         // location.replace("./Paytocomplete.html")
466
                         // window.location.replace("./Paytocomplete.html")
462
                         // window.location.replace("./Paytocomplete.html")
@@ -489,7 +485,7 @@
489
                 tradeNO: pay_info.tradeNO, // 必传,此使用方式下该字段必传
485
                 tradeNO: pay_info.tradeNO, // 必传,此使用方式下该字段必传
490
             }, function (result) {
486
             }, function (result) {
491
                 if (result.resultCode == '9000') {
487
                 if (result.resultCode == '9000') {
492
-                    location.replace("./Paytocomplete.html");
488
+                    location.replace("./Paytocomplete.html?result="+result);
493
                     money = '';
489
                     money = '';
494
                 } else {
490
                 } else {
495
                     alert("支付失败")
491
                     alert("支付失败")