//微信支付
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,微信公众号里调起微信支付