1、支付寶支付:前端發起一個請求,后台返回一個頁面,直接將返回的頁面(一個表單),再執行表單提交
okFryOtherPayHandler(){
let reqBody = {};
reqBody.orderId = this.orderId;
reqBody.payType = this.payType;
fetchOrderPayMsg(reqBody).then((res) => {
let resData = res.data;
if(resData.respHeader.resultCode == 0){
document.querySelector('#submitFormDiv').innerHTML = resData.respBody;
this.executeScript(resData.respBody);
}else{
this.submitActive = false;
Toast({
message: resData.respHeader.message,
});
}
});
},
executeScript(html){
let reg = /<script[^>]*>([^\x00]+)$/i;
let htmlBlock = html.split("<\/script>");
for (let i in htmlBlock){
let blocks;
if (blocks = htmlBlock[i].match(reg)){
let code = blocks[1].replace(/<!--/, '');
try{
eval(code) //執行腳本
}
catch (e){
}
}
}
},
fetchOrderPayMsg() axios 返回的參數如下:

