vue.js 微信支付前端代码 vue.js 微信支付前端代码分享

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

vue.js 微信支付前端代码 vue.js 微信支付前端代码分享

呀呀呀耶   2021-03-28 我要评论
想了解vue.js 微信支付前端代码讲解的相关内容吗,呀呀呀耶在本文为您仔细讲解vue.js 微信支付前端代码的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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()
  }
 }

以上这篇vue.js 微信支付前端代码分享就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们