<?php
/* @var $this \yii\web\View */    

$this->title = '同名账号';
?>
<?php $this->beginBlock('header_script'); ?>
    <link href="<?= STATIC_URL ?>/ui/css/plugins/dataTables/datatables.min.css" rel="stylesheet">
    <style>
        label.error {
            display: none !important;
        }

        #datatables {
            width: 100% !important;
        }
    </style>
<?php $this->endBlock(); ?>
<div class="row">
    <div class="col-md-3">
        <?= $this->render('/common/_left_menu.php') ?>
    </div>
    <div class="col-md-9">
        <div class="tabs-container">
            <ul class="nav nav-tabs">
                <li class="active" style="background:none;"><a data-toggle="tab" href="#tab-1"> <i class="fa fa-retweet"></i> 开设同名账号</a></li>
            </ul>
            <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                    <div class="panel-body">
                        <br><br><br><br>
                        <form id="form">
                            <div class="row">
                                <div class="col-sm-1"></div>
                                <div class="col-sm-4">
                                    <div class="input-group">
                                                <span class="input-group-btn">
                                                    <button type="button" class="btn btn-primary "><i class="fa fa-user"></i> 杠杆</button>
                                                </span>
                                        <select name="lever" id="lever" class="form-control">
                                            <option value="">请选择</option>
                                            <option value="100">1:100</option>
                                            <option value="200">1:200</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-sm-4">
                                    <div class="input-group">
                                         <div id="submit" class="btn btn-danger"><i class="fa fa-upload"></i> 提交申请</div>
                                    </div>
                                </div>
                                <div class="col-sm-1"></div>
                            </div>

                        </form>
                        <br><br>
                    </div>
                </div>

            </div>
        </div>

    </div>

</div>

<?php $this->beginBlock('footer_script'); ?>
<script>

    $("#submit").on("click", function() {
        if($("#form").valid()){
            $.ajax({
                type: "POST",
                url: "<?= \yii\helpers\Url::to(['/user/sameaccount/save']) ?>",
                data: $('#form').serialize(),
                dataType: "json",
                beforeSend: function() {},
                success: function(data) {
                    console.log(data.data);
                    if(data.code == 1) {
                        toastr.success(data.message, "提示");
                        var surl = '/user/sameaccount/success?login=' + data.data.login + '&mt4LoginPwd=' + data.data.mt4LoginPwd + '&mt4ViewPwd=' + data.data.mt4ViewPwd;
                        console.log(surl);
                        window.location.href = surl;
                        //window.location.reload();
                    } else {
                        toastr.error(data.message, "提示");
                    }
                },
                complete: function(XMLHttpRequest, textStatus) {},
                error: function() {
                    toastr.error(data.message, "提示");
                }
            });
        }
    });

    var table;
    $(document).ready(function() {
        $("#form").validate({
            rules: {
                "lever": {
                    required: true
                },
            }
        });

    });

</script>
<?php $this->endBlock(); ?>
