<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>MiniCheckout</title>
    <link rel="stylesheet" type="text/css" href="../styles/pinus.css">
</head>
<body>
<header>
    <div class="h_content">
        <span></span>
    </div>
</header>
<section class="block">
    <div class="content2">
        <div class="app">
            <span class="iphone"><img src="../img/bgpic.jpg" width="100%" height="auto"></span>
            <label class="text_amount">
                <input id="amount" type="text" placeholder="金 额"/>
            </label>

            <div class="ch">
                <span class="up" onclick="wap_pay('upacp_pc')">银联网页支付</span>
                <span class="up" onclick="wap_pay('alipay_pc_direct')">支付宝网页支付</span>
                <br>
                <span class="up" onclick="wap_pay('cp_b2b')">企业网银支付</span>
            </div>
        </div>
    </div>
</section>
<script src="../../src/pingpp-pc.js" type="text/javascript"></script>
<script>
    function wap_pay(channel) {
        var amount = document.getElementById('amount').value * 100;

        var xhr = new XMLHttpRequest();
        xhr.open("POST", "http://127.0.0.1/nera/public/pay/pingpp-php-master/engine/pay.php", true);
        xhr.setRequestHeader("Content-type", "application/json");
        xhr.send(JSON.stringify({
            channel: channel,
            amount: amount
        }));

        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200) {
                console.log(xhr.responseText);
                pingppPc.createPayment(xhr.responseText, function(result, err) {
                    console.log(result);
                    console.log(err);
                });
            }
        }
    }
</script>
</body>
</html>
