bayi пре 1 година
родитељ
комит
5dbf03c40f
1 измењених фајлова са 30 додато и 21 уклоњено
  1. 30 21
      小咖秀公众号支付/index.html

+ 30 - 21
小咖秀公众号支付/index.html

@@ -100,9 +100,9 @@
           <img src="http://reader-wx.ai160.com/images/reader/v3/active.png" class="active" v-show="active==products[1].id" />
         </div>
       </div>
-      <div class="payBox">
+      <div class="payBox" v-if="active!=''">
         <div class="left">
-          终身会员
+          {{product.title}}
           <span class="price">{{product.price/100}}</span>
         </div>
@@ -120,6 +120,7 @@
         products: [],
         product: {},
         active: '',
+        uid: '',
         code: ''
       },
       mounted() {
@@ -130,8 +131,10 @@
         var searchParams = new URLSearchParams(url)
         // 获取code参数的值
         var code = searchParams.get('code')
-        console.log(searchParams, '=======', code) // 输出:021gINll25JRUb49AYll2au8ga0gINl-
+        var uid = searchParams.get('uid')
+        console.log(uid, '=======', code)
         if (code) {
+          this.uid = uid
           this.code = code
           axios({
             method: 'get',
@@ -171,35 +174,41 @@
               method: 'post',
               url: 'https://reader-api.efunbox.cn/wx/pay/efun',
               headers: {
-                uid: 'd83d947655f6455a96f4197d31afa6d4',
+                uid: this.uid,
                 channelCode: '3001'
               },
               data: {
                 payType: 'WXPAY',
+                code: this.code,
                 orderId: res.data.data
               }
-            }).then(res => {})
-            /*  WeixinJSBridge.invoke(
-              'getBrandWCPayRequest',
-              {
-                appId: res.appId, //公众号ID,由商户传入2
-                timeStamp: res.timeStamp, //时间戳,自1970年以来的秒数
-                nonceStr: res.nonceStr, //随机串
-                package: res.package,
-                signType: res.signType, //微信签名方式:
-                paySign: res.paySign //微信签名
-              },
-              async res => {
-                if (res.err_msg == 'get_brand_wcpay_request:ok') {
-                  payIsSuccess()
+            }).then(res => {
+              let options = res.data.data
+              console.log(options, 'rrrses')
+              WeixinJSBridge.invoke(
+                'getBrandWCPayRequest',
+                {
+                  appId: options.appId, //公众号ID,由商户传入2
+                  timeStamp: options.timeStamp, //时间戳,自1970年以来的秒数
+                  nonceStr: options.nonceStr, //随机串
+                  package: options.package,
+                  signType: options.signType, //微信签名方式:
+                  paySign: options.sign //微信签名
+                },
+                async res => {
+                  if (res.err_msg == 'get_brand_wcpay_request:ok') {
+                    console.log('支付成功')
+                  } else {
+                    this.getWxCode()
+                  }
                 }
-              }
-            ) */
+              )
+            })
           })
         },
         getWxCode() {
           const appId = 'wxf05800eea975a68b'
-          const redirect_uri = encodeURIComponent('https://h5-pay.ai160.com/reader-ios')
+          const redirect_uri = encodeURIComponent('https://h5-pay.ai160.com/reader-ios?uid=d83d947655f6455a96f4197d31afa6d4')
           const url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appId + '&redirect_uri=' + redirect_uri + '&response_type=code&scope=snsapi_base#wechat_redirect'
           location.href = url
         }