<?php $__env->startSection('content'); ?>
<link href="<?php echo e(asset('css/cardInfo.css')); ?>" rel="stylesheet" type="text/css">
<link href="<?php echo e(asset('css/cardInfo.css')); ?>" rel="stylesheet" type="text/css">
    <body class="withdrawPage">

        <div class="app h5MaxWidth">
            <header>
                <div class="header h5MaxWidth clear display alignCenter">
                    <div class="back display alignCenter" onclick="jumpLink('-1',9)">
                        <i class="iconfont icon-arrow-left"></i>
                    </div>
                    <h3 class="flex1">Withdraw</h3>
                    <div class="navskip" id="sideMenu"></div>
                </div>
            </header>
            <div class="subject">
                <div class="groundSkin display alignStart justifyEnd">
                    <img src="<?php echo e(asset('img/1.png')); ?>" alt="">
                </div>
            </div>
            <div class="main">

                <div class="balanceCard radius15PX">
                    <div class="capitalItem">

                        <div class="gongGeNAV">
                            <ul class="display alignEnd">
                                <li class="flex1">
                                    <div>
                                        <h3 id="canWithdraw"><em class="currency">₦</em><?php echo e(number_format(auth()->user()->bonus_balance,2)); ?></h3>
                                        <span>Withdrawable amount</span>
                                    </div>
                                </li>

                            </ul>
                        </div>

                    </div>
                </div>

                <div class="drawmoney radius15PX forms">
                    <form id="drawmoney" action="<?php echo e(route('user.withdraw')); ?>" method="post" onsubmit="">
                        <?php echo csrf_field(); ?>
                        <input type="hidden" name="balance" value="2">
                        <input type="hidden" name="method_code" value="1">
                        <ul>
                            <li>
                                <div class="thisCard display alignStretch" id="thisCard">
                                    <div class="cardInfo bankCard radius15PX flex1"
                                    onclick="jumpLink('-1',9)">
                                        <div class="display alignStart">
                                            <div class="c_Name flex1">
                                                <h4><?php echo e(auth()->user()->bankAccount->bank_name); ?></h4>
                                            </div>
                                            <div class="chipIcon radius7PX">
                                                <img src="<?php echo e(asset('img/chip.svg')); ?>" alt="">
                                            </div>
                                        </div>

                                        <div class="cardFaceInfo" data-cardnumber="">
                                            <div class="c_Number">
                                                <p><?php echo e(chunk_split(auth()->user()->bankAccount->account_number, 4, ' ')); ?></p>
                                            </div>
                                            <div class="holder" data-holder="">
                                                <p><?php echo e(auth()->user()->bankAccount->bank_name); ?></p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </li>

                            <li>
                                <div class="formTitleBar">
                                    <h4>Withdrawal Amount</h4>
                                </div>
                                <div class="inputArea linearFrame display alignCenter">
                                    <div class="trueInpt display alignCenter flex1">
                                        <input type="number" name="amount" id="withdrawalAmount"
                                            class="withdrawalAmount fillArea inrICO inputIcon flex1"
                                            placeholder="Withdrawal Amount" maxlength="10" size="10">
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <div class="actionBar display alignCenter justifyEnd">
                            <button type="submit" class="drawmoneyBtn flex1 clickBtn display alignCenter justifyCenter">
                                <p>Submit withdraw </p>
                            </button>
                        </div>
                    </form>
                </div>
                <div class="tipsBox">
                    <div id="tips" class="tips">
                        <div class="titleBar display alignCenter">
                            <h3>Explain</h3>
                        </div>
                        <div class="explain">
                            <p>1. Withdrawal time is from 8:00 to 18:00 daily.</p>
                            <p>2. You can initiate a withdrawal request once a day, with each request amounting to 1,000
                                naira to 10,000,000 naira.</p>
                            <p>3. The platform charges 5% of the withdrawal amount as income tax.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="./../js/common.js" type="text/javascript"></script>
        <script src="./../js/api.js" type="text/javascript"></script>
        <script type="text/javascript">
            var currentPageData = [];
            var withdrawalAmount;
            var typePIN = '';
            var destinationID = {};

            function buildPage() {
                if (currentPageData.bankcard == null && currentPageData.usdt == null) {
                    toast('', "You haven't bound your withdrawal bank account yet, please go and bind it!", 'withdraw', 2000,
                    1);
                    setTimeout(function() {
                        window.location.href = "./cardBag.html"
                    }, 2000)
                }

                $("#canWithdraw").html("<em class='currency'>₦</em>" + moneyFormat(currentPageData.customer.balance_out_s));
                $("#balance").html("<em class='currency'>₦</em>" + moneyFormat(currentPageData.customer.balance_s));
                $("#cannotWithdraw").html("<em class='currency'>₦</em>" + moneyFormat(currentPageData.customer.balance_in_s));

                if (isEmpty(currentPageData.bankcard) && isEmpty(currentPageData.usdt)) {
                    $("#thisCard").html(addDccess(currentPageData.customer.is_v));
                } else {
                    if (!isEmpty(currentPageData.bankcard)) {
                        $("#thisCard").html(`
                        <div class="cardInfo bankCard radius15PX flex1" onclick="jumpLink('./cardBag.html',1)">
                            <div class="display alignStart">
                                <div class="c_Name flex1" data-bankid="${currentPageData.bankcard.bank.id}" data-code="${currentPageData.bankcard.bank.bank_code}">
                                    <h4>${currentPageData.bankcard.bank.bank_name}</h4>
                                </div>
                                <div class="chipIcon radius7PX">
                                    <img src="./../images/chip.svg" alt="" />
                                </div>
                            </div>

                            <div class="cardFaceInfo" data-cardnumber="">
                                <div class="c_Number">
                                    <p>${longNumberFormat(currentPageData.bankcard.card_number)}</p>
                                </div>
                                <div class="holder" data-holder="">
                                    <p>${currentPageData.bankcard.card_holder_name}</p>
                                </div>
                            </div>
                        </div>
                    `);
                    } else if (!isEmpty(currentPageData.usdt)) {
                        $("#thisCard").html(`
                        <div class="cardInfo usdtCard radius15PX flex1" onclick="jumpLink('./cardBag.html',1)">
                            <div class="display alignStart">
                                <div class="c_Name" data-usdtid="${currentPageData.usdt.id}">
                                    <h4>Tether (USDT)</h4>
                                </div>
                                <div class="chipIcon radius7PX">
                                    <i class="iconfont icon-usdt"></i>
                                </div>
                            </div>
                            <div class="cardFaceInfo" data-cardnumber="">
                                <div class="c_Number">
                                    <p>${currentPageData.usdt.usdt_address}</p>
                                </div>
                            </div>
                        </div>
                    `);
                    }

                }
            }
            //获取数据
            function withdrawConfig() {
                _api.visitWithdraw(res => {
                    if (res.code === 0) {
                        currentPageData = res.data;
                        if (!isEmpty(currentPageData.bankcard)) {
                            destinationID.id = currentPageData.bankcard.id;
                            destinationID.type = 1;
                            destinationID.tag = 'Bank Card ID';
                        }
                        if (!isEmpty(currentPageData.usdt)) {
                            destinationID.id = currentPageData.usdt.id;
                            destinationID.type = 2;
                            destinationID.tag = 'USDT';
                        }
                        buildPage();
                    }
                });
            }

            //提交提现
            function commitConfirm(t) {
                withdrawalAmount = $('#withdrawalAmount').val();

                if (isEmpty(destinationID.id)) {
                    toast('', 'The ' + destinationID.tag + ' cannot be empty', 'withdraw_T', 2000, 1);
                    return;
                }

                if (isEmpty(withdrawalAmount)) {
                    toast('', 'Please enter the withdrawal amount', 'withdraw_T', 2000, 1);
                    return;
                }

                if (t == 1) {
                    /*Open the payment password box*/
                    typePIN = 1;
                    tradePIN_pay.open({
                        title: 'transaction password',
                        enablePrompt: 'withdrawal amount is ' + withdrawalAmount,
                    });
                }
            }

            function submit(data) {
                _api.doWithdraw(data, res => {
                    if (res.code === 0) {
                        // removePrompt("payPasswordBox");
                        toast('', 'Withdrawal application has been submitted', 'withdraw', 2000, 2);
                        setTimeout(function() {
                            jumpLink('./../index.html', 4);
                        }, 2000);
                    } else {
                        toast('', res.msg, 'withdraw', 2000, 1);
                    }
                });
            }

            var tradePIN_pay = new paymentDialog(function(ret, err) {
                var tradePassword = ret.password;
                tradePIN_pay.empty();
                tradePIN_pay.close();
                toast("", "LOADING...", "loding", 3000, 4);
                if (isEmpty(tradePassword)) {
                    toast('', 'Please enter transaction password', 'withdraw', 2000, 1);
                    return false;
                }

                switch (typePIN) {
                    case 1:

                        if (+destinationID.type == 1) {
                            var data = {
                                "withdraw_type": 1,
                                "bankcard_id": destinationID.id,
                                "withdraw_money": withdrawalAmount,
                                "password_trade": tradePassword,
                            }
                        }
                        if (+destinationID.type == 2) {
                            var data = {
                                "withdraw_type": 2,
                                "usdt_id": destinationID.id,
                                "withdraw_money": withdrawalAmount,
                                "password_trade": tradePassword,
                            }
                        }
                        submit(data);
                        break;
                    default:
                        console.log('---2')
                        break;
                }

            });

            $(document).ready(function() {
                $.when(withdrawConfig()).done(function() {
                    // 当两个请求都成功完成时执行
                    console.log("结果");
                }).fail(function(error) {
                    // 当任意一个请求失败时执行
                    console.log("请求失败:", error);
                }).always(function() {
                    // 不管成功还是失败，总是会执行
                    console.log("请求完成");
                    $('.currency').html(dollarSign);
                });

                $("body").on("click", '#thisCard', function() {
                    $('#thisCard').toggleClass('controlled');
                });
            });
        </script>
        <div class="payBody">
            <div class="pay-box et-04s radius7700PX">

                <div class="titleBar display alignStart">
                    <div class="title flex1">
                        <h4></h4>
                        <span></span>
                    </div>
                    <div class="pb-close">
                        <i class="iconfont icon-ErrorClose"></i>
                    </div>
                </div>

                <div class="enablePrompt">
                    <p></p>
                </div>

                <div class="pb-int">
                    <ul class="display alignStart alignStretch justifyCenter">
                        <li>
                            <div class="radius7PX display alignCenter justifyCenter"></div>
                        </li>
                        <li>
                            <div class="radius7PX display alignCenter justifyCenter"></div>
                        </li>
                        <li>
                            <div class="radius7PX display alignCenter justifyCenter"></div>
                        </li>
                        <li>
                            <div class="radius7PX display alignCenter justifyCenter"></div>
                        </li>
                        <li>
                            <div class="radius7PX display alignCenter justifyCenter"></div>
                        </li>
                        <li>
                            <div class="radius7PX display alignCenter justifyCenter"></div>
                        </li>
                    </ul>
                </div>
                <div class="pb-keyboard">
                    <ul class="display alignStart alignStretch">
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>1</p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>2</p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>3</p>
                        </li>
                    </ul>
                    <ul class="display alignStart alignStretch">
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>4</p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>5</p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>6</p>
                        </li>
                    </ul>
                    <ul class="display alignStart alignStretch">
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>7</p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>8</p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>9</p>
                        </li>
                    </ul>
                    <ul class="display alignStart alignStretch">
                        <li class="pb-empty flex1 display alignCenter justifyCenter">
                            <p></p>
                        </li>
                        <li class="figure flex1 display alignCenter justifyCenter">
                            <p>0</p>
                        </li>
                        <li class="pb-del flex1 display alignCenter justifyCenter">
                            <p><i class="iconfont icon-DeletePassword"></i></p>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="overallShade"></div>
        </div>


    </body>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.users', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/AMPPS/www/anchoor/core/resources/views/templates/basic/user/withdraw/methods.blade.php ENDPATH**/ ?>