{template "header.html"}
<style>
.dr-pay-wrap .portlet-body { padding-top: 0; }
.dr-pay-wrap .dr-pay-layout {
    display: flex;
    align-items: flex-start;
}
.dr-pay-side {
    width: 200px;
    flex: 0 0 200px;
    border-right: 1px solid #eef1f5;
    padding: 8px 0 20px;
    min-height: 0;
}
.dr-pay-side .nav-pills > li { float: none; margin: 0; }
.dr-pay-side .nav-pills > li > a {
    border-radius: 0;
    color: #666;
    padding: 11px 12px 11px 14px;
    border-left: 2px solid transparent;
    margin: 0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.dr-pay-side .nav-pills > li > a:hover {
    background: #f7f9fc;
    color: #333;
}
.dr-pay-side .nav-pills > li.active > a,
.dr-pay-side .nav-pills > li.active > a:hover,
.dr-pay-side .nav-pills > li.active > a:focus {
    background: #f0f7ff;
    color: #2890ff;
    border-left-color: #28b6ff;
    font-weight: 600;
}
.dr-pay-side .nav-pills > li > a .dr-pay-icon {
    margin-right: 4px;
    color: #8896a6;
}
.dr-pay-side .nav-pills > li.active > a .dr-pay-icon {
    color: #2890ff;
}
.dr-pay-side .badge {
    float: right;
    margin-top: 1px;
    margin-left: 6px;
    background: #eef1f5;
    color: #8896a6;
    font-weight: 500;
    font-size: 11px;
    padding: 3px 6px;
}
.dr-pay-side .badge.dr-pay-on {
    background: #28b6ff;
    color: #fff;
}
.dr-pay-side .ui-sortable-helper {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.dr-pay-side .ui-sortable-placeholder {
    visibility: visible !important;
    background: #f0f7ff;
    border-left: 2px dashed #28b6ff;
    height: 40px;
    margin: 0;
}
.dr-pay-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0;
    padding: 8px 10px 20px 20px;
    overflow: hidden;
}
.dr-pay-main .dr-pay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0 14px;
    margin-bottom: 10px;
    border-bottom: 1px solid #eef1f5;
}
.dr-pay-main .dr-pay-head h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}
.dr-pay-main .dr-pay-head .dr-pay-sort-tip {
    color: #8896a6;
    font-size: 12px;
}
/* 配置区拉满右侧宽度；用 flex 避免与侧栏 float/clear 互相影响 */
.dr-pay-main .form-body > .form-group {
    display: flex;
    align-items: flex-start;
    margin-left: 0;
    margin-right: 0;
}
.dr-pay-main .form-body > .form-group:before,
.dr-pay-main .form-body > .form-group:after {
    display: none !important;
    content: none !important;
}
.dr-pay-main .form-body > .form-group > .control-label.col-md-2 {
    width: 140px;
    flex: 0 0 140px;
    float: none !important;
    padding-top: 7px;
}
.dr-pay-main .form-body > .form-group > .col-md-9 {
    flex: 1 1 auto;
    width: auto !important;
    float: none !important;
    margin-left: 0;
    padding-left: 15px;
    padding-right: 0;
}
.dr-pay-main .form-control,
.dr-pay-main .form-control.input-large,
.dr-pay-main .form-control.input-xlarge,
.dr-pay-main .form-control.input-medium,
.dr-pay-main textarea.form-control {
    width: 100% !important;
    max-width: 100%;
}
.dr-pay-tip {
    margin-bottom: 12px;
}
@media (max-width: 991px) {
    .dr-pay-wrap .dr-pay-layout {
        display: block;
    }
    .dr-pay-side {
        width: 100%;
        flex: none;
        border-right: 0;
        border-bottom: 1px solid #eef1f5;
        margin-bottom: 10px;
        padding-bottom: 0;
    }
    .dr-pay-main {
        padding-left: 0;
    }
}
</style>

<div class="note note-danger dr-pay-tip">
    <p><a href="javascript:dr_update_cache('member', '');">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
</div>

<form action="" class="form-horizontal" method="post" name="myform" id="myform">
    {$form}
    <div class="myfbody">
        <div class="portlet light bordered dr-pay-wrap">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-credit-card font-green"></i>
                    <span class="caption-subject font-green sbold">{dr_lang('支付接口')}</span>
                </div>
                <div class="actions">
                    {if !IS_OEM_CMS}
                    <a href="https://www.xunruicms.com/api/xunrui.php?at=pay" class="btn blue btn-sm" target="_blank">
                        <i class="fa fa-cloud-download"></i> {dr_lang('更多支付接口')}
                    </a>
                    {/if}
                </div>
            </div>
            <div class="portlet-body">
                <div class="dr-pay-layout">
                    <div class="dr-pay-side">
                        <ul class="nav nav-pills nav-stacked field-sort-items" id="dr_pay_nav" role="tablist">
                            {php $dr_pay_n = 0;}
                            {loop $data $dir $t}
                            {if is_file(ROOTPATH.'api/pay/'.$dir.'/setting.php')}
                            <li class="{if !$dr_pay_n}active{/if}" data-dir="{$dir}">
                                <a href="#dr_pay_tab_{$dir}" data-toggle="tab" title="{dr_lang($t.config.name)}">
                                    <span class="dr-pay-icon">{$t.config.icon}</span>{dr_lang($t.config.name)}
                                    <span class="badge {if $t['use']}dr-pay-on{/if}">{if $t['use']}{dr_lang('启用')}{else}{dr_lang('关闭')}{/if}</span>
                                </a>
                            </li>
                            {php $dr_pay_n++;}
                            {/if}
                            {/loop}
                        </ul>
                    </div>
                    <div class="dr-pay-main">
                        <div class="tab-content" id="dr_pay_content">
                            {php $dr_pay_n = 0;}
                            {loop $data $dir $t}
                            {if is_file(ROOTPATH.'api/pay/'.$dir.'/setting.php')}
                            <div class="tab-pane {if !$dr_pay_n}active{/if}" id="dr_pay_tab_{$dir}" data-dir="{$dir}">
                                <div class="dr-pay-head">
                                    <h4>{$t.config.icon}&nbsp;{dr_lang($t.config.name)}</h4>
                                    <span class="dr-pay-sort-tip"><i class="fa fa-arrows"></i> {dr_lang('左侧可拖动排序')}</span>
                                </div>
                                <div class="form-body">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">{dr_lang('启用')}</label>
                                        <div class="col-md-9">
                                            <input type="checkbox" name="data[{$dir}][use]" value="1" {if $t['use']}checked{/if} data-on-text="{dr_lang('启用')}" data-off-text="{dr_lang('关闭')}" data-on-color="success" data-off-color="danger" class="make-switch dr-pay-use" data-size="small" data-dir="{$dir}">
                                        </div>
                                    </div>
                                    <?php require ROOTPATH.'api/pay/'.$dir.'/setting.php';?>
                                </div>
                            </div>
                            {php $dr_pay_n++;}
                            {/if}
                            {/loop}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="portlet-body form myfooter">
        <div class="form-actions text-center">
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}&page='+$('#dr_page').val(), 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存')}</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(function() {
        $("#dr_pay_nav").sortable({
            axis: 'y',
            helper: 'clone',
            update: function() {
                var $content = $('#dr_pay_content');
                $('#dr_pay_nav > li').each(function() {
                    var id = $(this).find('a').attr('href');
                    $content.append($(id));
                });
            }
        });

        $('.dr-pay-use').on('switchChange.bootstrapSwitch', function(e, state) {
            var dir = $(this).data('dir');
            var $badge = $('#dr_pay_nav > li[data-dir="'+dir+'"] .badge');
            if (state) {
                $badge.addClass('dr-pay-on').text('{dr_lang('启用')}');
            } else {
                $badge.removeClass('dr-pay-on').text('{dr_lang('关闭')}');
            }
        });
    });
</script>
{template "footer.html"}
