H5网页支付直接调后台接口返回跳转微信的url地址,但是这里有个坑,不能直接location.href="url"。
而是在html的a标签跳转然后赋值href。document.getElementById("a").setAttribute("href",url);
页面1
$.ajax({
type:'GET',
url:"https://xxxxxxxxxxxxxxxxx",
data:{
url:"https://xxxxxxxxxxx?test" + test +"&test2=" + test2
},
success:function(data)
//data参数是你想要跳转的页面,发送给后台,然后重定,再次跳转
window.location.href = data.data;
}
})
页面2
$.ajax({
type:'POST',
url:"https://xxxxxxxxxxxxxx",
data:{
phone:"xxxxxxxxx",
Id:"5",
},
success:function(data){
这时的ajax,给后台发送用户账号和充值id返回一个地址,赋值到页面上的a标签
点击即可付款
document.getElementById("test").setAttribute("href",mwebUrl);
}
})
}