Browse Source

支付优化2

harryYao 2 years ago
parent
commit
a28fd6cd2b
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/App.vue

+ 6 - 2
src/App.vue

@@ -51,6 +51,7 @@
 
 <script>
 import axios from 'axios'
+import { queryToObj } from './utils/index.js'
 const PAY_TYPE = {
 	MONTHLY: 'MONTHLY', //包月
 	SEASONALLY: 'SEASONALLY', //包季;
@@ -88,7 +89,8 @@ export default {
   },
   created() {
     const search = window.location.search
-    this.chatToken = search.substring(1)
+    const obj = queryToObj(search.substring(1))
+		this.chatToken = obj.chatToken
 		this.getProducts()
   },
   computed: {
@@ -150,6 +152,7 @@ export default {
     },
 
 		onBridgeReady() {
+			const that = this
       WeixinJSBridge.invoke(
         "getBrandWCPayRequest",
         {
@@ -161,12 +164,13 @@ export default {
           paySign: this.payObj.paySign, //微信签名
         },
         function (res) {
+					console.log('支付结果:', res)
           if (res.err_msg == "get_brand_wcpay_request:ok") {
             // 使用以上方式判断前端返回,微信团队郑重提示:
             //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
             alert("支付成功");
           }
-          this.closePage();
+          that.closePage();
         }
       );
     },