如何设置网站关键字,wordpress 文章字体,大连做网站报价,品牌推广的目的和意义记录下微信JSAPI支付的流程 1、判断是微信浏览器则直接请求微信授权的链接#xff0c;需要传递给微信重定向回的页面#xff0c;及订单id // 微信浏览器直接调用
if (this.isWeixin) {let redirectUri http://192.168.1.6/weChatwindow.location.href https://open.weixin.… 记录下微信JSAPI支付的流程 1、判断是微信浏览器则直接请求微信授权的链接需要传递给微信重定向回的页面及订单id // 微信浏览器直接调用
if (this.isWeixin) {let redirectUri http://192.168.1.6/weChatwindow.location.href https://open.weixin.qq.com/connect/oauth2/authorize?appidwxe0701b98700ac86eredirect_uri encodeURI(redirectUri) response_typecodescopesnsapi_basestate this.order.orderId #wechat_redirect
} 2、上一步获取授权之后就会拿到code及传递的订单id会以query的形式拼在重定向的路由上然后通过拿到的code和订单id去请求后台获取该支付对应的需要的参数后台返回。 created () {let _query this.$route.queryif (Object.keys(_query).length 0 _query.code) {wxChatPublicPayApi({code: _query.code,orderId: _query.state}).then(res {this.params res.dataif (typeof WeixinJSBridge undefined) {if (document.addEventListener) {document.addEventListener(WeixinJSBridgeReady, this.onBridgeReady, false)} else if (document.attachEvent) {document.attachEvent(WeixinJSBridgeReady, this.onBridgeReady)document.attachEvent(onWeixinJSBridgeReady, this.onBridgeReady)}} else {this.onBridgeReady()}})}
} 3、拿到后台返回的参数之后直接调用微信的api即可 onBridgeReady () {let _this thisWeixinJSBridge.invoke(getBrandWCPayRequest, _this.params, function (res) {if (res.err_msg get_brand_wcpay_request:ok) {// 使用以上方式判断前端返回,微信团队郑重提示// res.err_msg将在用户支付成功后返回ok但并不保证它绝对可靠。_this.checkPayStatus()} else {_this.$message({message: res.err_msg 支付失败,type: error})_this.$router.push(/orderDetail/ _this.$route.query.state)}})
}, 详细参数可以查看下面微信支付官方文档https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter7_7index6 转载于:https://www.cnblogs.com/goloving/p/10632020.html