微信H5支付

//微信支付
wechatPay(id){
    this.show=false;
    id=this.id;
    this.$request.post({
        url: '/wechat/pay/user/weChatPay',
        params: {id},
        success: res=>{
            this.wechat= res;
            var _this = this;
            WeixinJSBridge.invoke('getBrandWCPayRequest', {
                "appId" : _this.wechat.appid, //公众号名称,由商户传入     
                "timeStamp" : _this.wechat.timeStamp, //时间戳,自1970年以来的秒数     
                "nonceStr" : _this.wechat.nonceStr, //随机串     
                "package" : _this.wechat.packageValue,
                "signType" : "MD5", //微信签名方式:     
                "paySign" : _this.wechat.sign //微信签名 
            }, function(res) {
                if (res.err_msg == "get_brand_wcpay_request:ok") {
                    alert('支付成功')
                    _this.clear();
                    _this.$router.replace('/order')
                } else if (res.err_msg == "get_brand_wcpay_request:fail") {
                    alert('支付失败')
                } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    alert('支付取消')
                } else {
                    alert(res.err_msg);
                }
            })
            
        },
        finally: ()=>{
        }
    })
},

适用于在h5,微信公众号里调起微信支付

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值