废话不多说,直接上代码
ALIpayOrder() {
var urlStr = '接口地址';
var data = {
'alipayUserid': this.userInfo.alipayUserid,
'alipayNickname': this.userInfo.alipayNickname,
'alipayHead': this.userInfo.alipayHead,
'orderId': this.orderId
}; //相关订单信息
//重点是下面这段代码,后端返回的form表单通过下面的代码展现在页面上,就是调起的支付宝支付页面。
axios.get(urlStr, { params: data }).then((response) => {
vm.btnPay = false;
var form = response.data;
const div = document.createElement('div')//创建div
div.innerHTML = form//将返回的form 放入div
document.body.appendChild(div);
document.forms[0].submit();
}).catch(function (error) {
console.log('失败', error);
});
},