Browse Source

支付功能开发4

JXDS18FUJT 1 năm trước cách đây
mục cha
commit
54888632b4
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      src/views/home/index.tsx

+ 9 - 2
src/views/home/index.tsx

@@ -26,14 +26,21 @@ export const Home: React.FC = (props: any) => {
   }])
   const [userInfo, setUserInfo] = useState({ "openid": "", "nickname": "未知用户", "sex": "0", "province": "", "city": "", "country": "", "headimgurl": "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKZYiaibphiayqRhARSnicqI2bHNYWfnuGTDLagIUfNSncS5H8m097t5qSHwkGeRLn8D0uV14ACfibVCZg/132", "privilege": [], "unionid": "" })
   const wxPay = () => {
+    // WX.config()
     api.studentWxGzhPrepareOrder({
       "foreType": 2,
       "goodsId": 5,
       "goodsType": 1,
       "phoneType": 2
     }).then(res=>{
-      console.log(res.data.data)
-       WX.chooseWXPay({...res.data.data})
+      WeixinJSBridge.invoke("getBrandWCPayRequest", res.data.data, async function (res: any) {
+        if (res.err_msg == "get_brand_wcpay_request:ok") {
+          // 使用以上方式判断前端返回,微信团队郑重提示:
+          //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+         console.log('支付成功')
+        }
+      });
+      //  WX.chooseWXPay({...res.data.data})
     })
     // wx.chooseWXPay()
   }