您好,欢迎来到微智科技网。
搜索
您的当前位置:首页通过vue.js实现微信支付

通过vue.js实现微信支付

来源:微智科技网


下面我就为大家分享一篇vue.js 微信支付前端代码。具有很好的参考价值。希望对大家有所帮助。

实例如下所示:

onBridgeReady: function () {
 const openId = localStorage.getItem('openId')
 payService.payment(this.$route.params.orderId, 1, openId).then(rt => { //1:支付类型,可不填
 this.message = rt.t
 WeixinJSBridge.invoke(
 'getBrandWCPayRequest', {
 'appId': this.message.appId,
 'timeStamp': this.message.timeStamp,
 'nonceStr': this.message.nonceStr,
 'package': this.message.package,
 'signType': this.message.signType,
 'paySign': this.message.paySign
 },
 function (res) {
 console.log(res)
 if (res.err_msg === 'get_brand_wcpay_request:ok') {
 Toast('微信支付成功')
 this.$router.push('/MineOrder')
 } else if (res.err_msg === 'get_brand_wcpay_request:cancel') {
 Toast('用户取消支付')
 // window.location.href = 'gift_failview.do?out_trade_no=' + this.orderId
 } else if (res.err_msg === 'get_brand_wcpay_request:fail') {
 Toast('网络异常,请重试')
 }
 }
 )
 })
 },
 callpay: function () {
 if (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()
 }
 }

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

在angularjs中如何实现table增加tr的方法

在angular中如何使用json对象push到数组中的方法

在angularjs数组中如何判断是否含有某个元素

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务