Files
ipms-sjy/yudao-user-server/src/main/resources/static/pay_alipay_wap.html
2021-11-04 08:47:41 +08:00

67 lines
2.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<title>支付测试页</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
<div>点击如下按钮,发起支付的测试</div>
<div>
<button id="alipay_wap">支付宝h5</button>
</div>
<div id="dynamic_form"></div>
</body>
<script>
// TODO @jasoncopy 过来后,有些注释要改过来哈
let shopOrderId = undefined;
let payOrderId = undefined;
let server = 'http://127.0.0.1:28080';
//let server = 'http://niubi.natapp1.cc';
// TODO openid
//let openid = "ockUAwIZ-0OeMZl9ogcZ4ILrGba0";
$(function() {
// 自动发起商城订单编号
$.ajax({
url: server + "/api/shop/order/create",
method: 'POST',
success: function( result ) {
if (result.code !== 0) {
alert('创建商城订单失败,原因:' + result.msg)
return;
}
shopOrderId = result.data.id;
payOrderId = result.data.payOrderId;
console.log("商城订单:" + shopOrderId)
console.log("支付订单:" + payOrderId)
}
})
});
// 微信公众号
$( "#alipay_wap").on( "click", function() {
// 提交支付
$.ajax({
url: server + "/api/pay/order/submit",
method: 'POST',
dataType: "json",
contentType: "application/json",
data: JSON.stringify({
"id": payOrderId,
"channelCode": 'alipay_wap'
}),
success: function( result ) {
if (result.code !== 0) {
alert('提交支付订单失败,原因:' + result.msg)
return;
}
alert('点击确定,开始支付');
// 开始调用微信支付
let data = result.data.invokeResponse;
$("#dynamic_form").html(data.body);
}
})
});
</script>
</html>