// 去支付
goPayFun() {
var data = {
pathway: 'h5',
out_trade_no: this.orderMessage.order_code,
total_amount: (this.orderMessage.total_amount / 100).toFixed(2)
}
if (this.type == 1) { // 微信支付
data.pay_method = 'wechat'
}
if (this.type == 2) {
data.pay_method = 'alipay'
}
wxPay(data).then(res => {
if (this.type == 1) { // 微信支付
this.wxpayFun(res)
}
if (this.type == 2) {
this.alipayFun(res)
}
})
},
// 微信支付
wxpayFun(res) {
const _html = res.data.html;
const div = document.createElement("div");
div.innerHTML = _html;
document.body.appendChild(div);
},
// 支付宝支付
alipayFun(res) {
const form = res.data.html;
const div = document.createElement("div");
div.id = "alipay";
div.innerHTML = form;
document.body.appendChild(div);
document.querySelector("#alipay").children[0].submit();
},
网友评论