<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta content="telephone=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <script src="../lib/fsize.js"></script>
    <script src="../lib/jquery-3.1.1.min.js"></script>
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/fireflyPay.css?v='2018060681'">
    <link rel="stylesheet" href="../css/layer.css">
    <title></title>
    <style>
        body {
            background: #11101A;
        }

        .p-w {
            background-color: #11101A;
        }

        .gash-for-ul {
            margin: 0 auto;
            width: 10rem;
        }

        .gash-for-ul li {
            height: 1.45rem;
            line-height: 1.45rem;
            color: #00F8DC;
            background: #11101A;
            margin-bottom: 0.05rem;
            border: 0.04rem solid transparent;
        }

        .p-active {
            border: 0.04rem solid #1cebd1 !important;
        }

        .gash-for-ul li img {
            width: 0.5rem;
            vertical-align: middle;
            margin-top: -0.1rem;
            margin-left: 0.5rem;
        }

        .gash-for-ul li span {
            margin-left: 0.3rem;
            font-size: 0.45rem;
        }

        .gash-for-ul li button {
            height: 0.73rem;
            line-height: 0.75rem;
            width: 2.2rem;
            background: linear-gradient(to right, #00f088, #00a0e9);
            border-radius: 2rem;
            color: #fff;
            float: right;
            margin-top: 0.35rem;
            margin-right: 0.46rem;
            font-size: 0.4rem;
        }

        .gash-rid {
            visibility: hidden;
        }

        .login-tips {
            color: #00a0e9;
        }
    </style>
</head>

<body>
    <div class="p-w alipay">
        <!--<div>-->
        <!--<p class="apple-top">優惠充值</p>-->
        <!--</div>-->

        <ul class="gash-for-ul clearfix">
            <img src="../img/loading.png" alt="">

        </ul>
        <!--<div class="paypal">
        <button class="login-btn"></button>
    </div>-->

        <p class="login-tips"></p>
    </div>
</body>
<script src="../lib/jquery-3.1.1.min.js"></script>
<script src="../lib/payLangchange.js?v=202008181027"></script>
<script src="../layer-v3.1.0/layer/layer.js"></script>
<script>
    $('title').text(langList[langType].paytitle);
    //$('.login-btn').text(langList[langType].next);
    $('.login-tips').text(langList[langType].ques);


    var btnOk = false;
    $.ajax({
        url: $ip + "/setting/getRecharge.html",
        type: "post",
        data: {
            'cid': "web_gw",
            'os': "h5",
            lang: sessionStorage.lang,
            'vest': 0,
            'paytype': sessionStorage.pay
        },
        error: function (msg) {
            console.log('erroe!');
        },
        success: function (msg) {
            var data = JSON.parse(msg);
            var html = [];
            for (var i = 0; i < data.data.length; i++) {
                html += '<li>'
                html += '<img src="../img/zuan.png"><span>' + data.data[i].diamond + '</span>'
                html += '<button>' + data.data[i].price[0].currency + '<i style="font-style:normal">' + data.data[i].price[0].price + '</i></button>';
                html += '<span class="gash-rid">' + data.data[i].rid + '</span>';

                html += '</li>'
            }
            $(".gash-for-ul").html(html);

            $(".gash-for-ul li").on("click", function () {

                $(this).siblings("li").removeClass("p-active");
                $(this).addClass("p-active");
                rid = $(this).find('.gash-rid').text();
                console.log(rid);
                money = $(this).find('button i').text();
                console.log(money);
                btnOk = true;
                if (btnOk == true) {
                    if (sessionStorage.pay == "PAYPALPAY") {
                        $.ajax({
                            url: $ip + "/pay/getPayPreid.html",
                            type: "post",
                            data: {
                                lang: sessionStorage.lang,
                                'uid': sessionStorage.uid,
                                'product': "橙钻充值",
                                'country': "86",
                                'rid': rid,
                                'payType': sessionStorage.pay,
                                'payTypeSub': "NAVITE",
                                'amount': money * 100,
                                'extend': "0",
                            },
                            success: function (msg) {
                                var data = JSON.parse(msg);
                                //                        $.cookie('oid',data.orderId,{expires:1});
                                sessionStorage.oid = data.orderId;
                                key = data.payInfo.key;
                                var html1 = [];
                                html1 += "<div style=' text-align: center;margin-top: 1.7rem;' class='paypalpay'>";
                                html1 += "<div id=paypal-button-container></div>";
                                html1 += "</div>";
                                $(".paypal").html(html1);
                                paypal.Button.render({

                                    env: 'production', // sandbox | production

                                    // PayPal Client IDs - replace with your own
                                    // Create a PayPal app: https://developer.paypal.com/developer/applications/create
                                    client: {
                                        production: key,
                                        //            production: '<insert production client id>'
                                    },
                                    style: {
                                        color: 'gold',
                                        size: 'large',
                                        shape: 'rect',
                                        locale: 'zh_US',

                                    },
                                    // Show the buyer a 'Pay Now' button in the checkout flow
                                    commit: true,

                                    // payment() is called when the button is clicked
                                    payment: function (data, actions) {



                                        // Make a call to the REST api to create the payment
                                        return actions.payment.create({
                                            payment: {
                                                transactions: [
                                                    {
                                                        amount: { total: money, currency: 'USD' },
                                                        custom: sessionStorage.oid,
                                                    }
                                                ]
                                            }
                                        });
                                    },

                                    // onAuthorize() is called when the buyer approves the payment
                                    onAuthorize: function (data, actions) {

                                        // Make a call to the REST api to execute the payment
                                        return actions.payment.execute().then(function () {
                                            setInterval(function () {
                                                window.location.href = 'payend.html';
                                            }, 100)

                                        });
                                    }

                                }, '#paypal-button-container');
                            }
                        })
                    }
                    else if (sessionStorage.pay == "ALIPAY") {
                        $.ajax({
                            url: $ip + "/pay/getPayPreid.html",
                            type: "post",
                            data: {
                                lang: sessionStorage.lang,
                                'uid': sessionStorage.uid,
                                'product': "橙钻充值",
                                'country': "86",
                                'rid': rid,
                                'payType': sessionStorage.pay,
                                'payTypeSub': "H5",
                                'amount': money * 100,
                                'extend': "https://events.yabolive.net/phonepay/payend.html",
                            },
                            success: function (msg) {
                                console.log(msg);
                                var data = JSON.parse(msg);
                                //                        $.cookie('oid',data.orderId,{expires:1});
                                if (data.code == 1) {
                                    sessionStorage.oid = data.orderId;
                                    var html = [];
                                    console.log(data);
                                    html += data.payInfo.h5
                                    $(".alipay").html(html);
                                } else {
                                    layer.msg(data.msg);
                                }
                            }
                        })
                    }
                    else if (sessionStorage.pay == "WECHATPAY") {
                        $.ajax({
                            url: $ip + "/pay/getPayPreid.html",
                            type: "post",
                            data: {
                                'cid': "web_gw",
                                'os': "h5",
                                lang: sessionStorage.lang,
                                'uid': sessionStorage.uid,
                                'product': "橙钻充值",
                                'country': "86",
                                'rid': rid,
                                'payType': sessionStorage.pay,
                                'payTypeSub': "MWEB",
                                'amount': money * 100,
                                'extend': "https://events.yabolive.net/phonepay/payend.html",
                            },
                            success: function (msg) {
                                var data = JSON.parse(msg);
                                //                        $.cookie('oid',data.orderId,{expires:1});
                                sessionStorage.oid = data.orderId;
                                var url = data.payInfo.mweb_url;
                                window.location.href = url;
                            }

                        })
                    }
                    else if (sessionStorage.pay == 'MOLPAY') {
                        $.ajax({
                            url: $ip + "/pay/getPayPreid.html",
                            type: "post",
                            data: {
                                'cid': "web_gw",
                                'os': "h5",
                                lang: sessionStorage.lang,
                                "uid": sessionStorage.uid,
                                "product": "橙钻货币充值",
                                "country": "86",
                                "rid": rid,
                                "lang": 2,
                                "payType": sessionStorage.pay,
                                "payTypeSub": "H5",
                                "amount": money * 100,
                                "extend": "0",
                                "returnUrl": "https://www.firefly.live/phonepay/payend.html",
                            },
                            success: function (msg) {
                                var data = JSON.parse(msg);
                                console.log(data);
                                window.location.href = data.payInfo.url;
                            }
                        })
                    }
                } else {
                    layer.msg(langList[langType].select);
                }
            })


        }
    })

    $(".payfor-ul").on("click", function () {
        if (sessionStorage.pay == 'PAYPALPAY') {
            $(".paypal").html('<button class="login-btn">下一步</button>')
            $(".login-btn").unbind("click")
            $(".login-btn").on("click", function () {
                if (btnOk == true) {
                    if (sessionStorage.pay == "PAYPALPAY") {
                        $.ajax({
                            url: $ip + "/pay/getPayPreid.html",
                            type: "post",
                            data: {
                                'cid': "web_gw",
                                'os': "h5",
                                lang: sessionStorage.lang,
                                'uid': sessionStorage.uid,
                                'product': "橙钻充值",
                                'country': "86",
                                'rid': rid,
                                'payType': sessionStorage.pay,
                                'payTypeSub': "NAVITE",
                                'amount': money * 100,
                                'extend': "0",
                            },
                            success: function (msg) {
                                var data = JSON.parse(msg);
                                //                        $.cookie('oid',data.orderId,{expires:1});
                                sessionStorage.oid = data.orderId;
                                key = data.payInfo.key;
                                var html1 = [];
                                html1 += "<div style=' text-align: center;margin-top: 1.7rem;' class='paypalpay'>";
                                html1 += "<div id=paypal-button-container></div>";
                                html1 += "</div>";
                                $(".paypal").html(html1);
                                paypal.Button.render({

                                    env: 'production', // sandbox | production

                                    // PayPal Client IDs - replace with your own
                                    // Create a PayPal app: https://developer.paypal.com/developer/applications/create
                                    client: {
                                        production: key,
                                        //            production: '<insert production client id>'
                                    },
                                    style: {
                                        color: 'gold',
                                        size: 'large',
                                        shape: 'rect',
                                        locale: 'zh_US',

                                    },
                                    // Show the buyer a 'Pay Now' button in the checkout flow
                                    commit: true,

                                    // payment() is called when the button is clicked
                                    payment: function (data, actions) {



                                        // Make a call to the REST api to create the payment
                                        return actions.payment.create({
                                            payment: {
                                                transactions: [
                                                    {
                                                        amount: { total: money, currency: 'USD' },
                                                        custom: sessionStorage.oid,
                                                    }
                                                ]
                                            }
                                        });
                                    },

                                    // onAuthorize() is called when the buyer approves the payment
                                    onAuthorize: function (data, actions) {

                                        // Make a call to the REST api to execute the payment
                                        return actions.payment.execute().then(function () {
                                            setInterval(function () {
                                                window.location.href = 'payend.html';
                                            }, 100)

                                        });
                                    }

                                }, '#paypal-button-container');
                            }
                        })
                    }
                } else {
                    layer.msg(langList[langType].select);
                }

            })
        }
    })
</script>

</html>