{include file="public/layout" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page" style="min-width: auto;">
    {include file="member/bar" /}
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>接口配置</h3>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <div class="sDiv">
                <div class="sDiv2 addartbtn fl" style="margin-right: 6px;">
                    <input type="button" class="btn selected" value="接口配置" onclick="window.location.href='{:url("Member/pay_set")}';">
                </div>
                <div class="sDiv2 addartbtn fl" style="margin-right: 6px;">
                    <input type="button" class="btn current" value="账户充值记录" onclick="window.location.href='{:url("Member/money_index")}';">
                </div>
            </div>
        </div>
        <form class="form-horizontal" id="postWechatForm" action="{:url('Member/wechat_set')}" method="post">
            <div class="hDiv">
                <div class="hDivBox">
                    <table cellspacing="0" cellpadding="0" style="width: 100%">
                        <thead>
                        <tr>
                            <th class="sign w10" axis="col0">
                                <div class="tc"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="w10">
                                <div class="tc">微信支付配置</div>
                            </th>
                            <th abbr="ac_id" axis="col4">
                                <div class=""></div>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">
                        <label>支付方式</label>
                    </dt>
                    <dd class="opt">
                        <div class="onoff">
                            <label for="is_open_wechat0" class="cb-enable {if condition="!isset($wechat.is_open_wechat) || empty($wechat.is_open_wechat)"}selected{/if}">开启</label>
                            <label for="is_open_wechat1" class="cb-disable {if condition="$wechat.is_open_wechat == 1"}selected{/if}">关闭</label>
                            <input id="is_open_wechat0" name="wechat[is_open_wechat]" value="0" type="radio" {if condition="!isset($wechat.is_open_wechat) || empty($wechat.is_open_wechat)"} checked="checked"{/if}>
                            <input id="is_open_wechat1" name="wechat[is_open_wechat]" value="1" type="radio" {if condition="$wechat.is_open_wechat == 1"} checked="checked"{/if}>
                        </div>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="username"><em>*</em>微信AppId</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="wechat[appid]" id="appid" value="{$wechat.appid}" class="input-txt">
                        <p class="notic">请输入您的微信公众平台中的微信AppId,用于微信支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="username"><em>*</em>微信商户号</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="wechat[mchid]" id="mchid" value="{$wechat.mchid}" class="input-txt">
                        <p class="notic">请输入您的微信公众平台中的微信商户号,用于微信支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="username"><em>*</em>微信KEY值</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" name="wechat[key]" id="key" value="{$wechat.key}" class="input-txt">
                        <p class="notic">请输入您的微信公众平台中的微信KEY值,用于微信支付。</p>
                    </dd>
                </dl>
                <dl class="row">
                    <div class="bot" style="padding-bottom:0px;">
                        <a href="JavaScript:void(0);" onclick="wechatset();" class="ncap-btn-big ncap-btn-green" id="submitWechatBtn">确认提交</a>
                        &nbsp;<a href="JavaScript:void(0);" onclick="click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid=8829','微信支付配置教程')" style="font-size: 12px;padding-left: 10px;position:absolute;top: 30px">不会配置?</a>
                    </div>
                </dl>
            </div>
        </form>  
        <form class="form-horizontal" id="postAlipayForm" action="{:url('Member/alipay_set')}" method="post">
            <div class="hDiv">
                <div class="hDivBox">
                    <table cellspacing="0" cellpadding="0" style="width: 100%">
                        <thead>
                        <tr>
                            <th class="sign w10" axis="col0">
                                <div class="tc"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="w10">
                                <div class="tc">支付宝支付配置</div>
                            </th>
                            <th abbr="ac_id" axis="col4">
                                <div class=""></div>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        
            <div class="ncap-form-default">
                <dl class="row">
                    <dt class="tit">
                        <label>支付方式</label>
                    </dt>
                    <dd class="opt">
                        <div class="onoff">
                            <label for="is_open_alipay0" class="cb-enable {if condition="!isset($alipay.is_open_alipay) || empty($alipay.is_open_alipay)"}selected{/if}">开启</label>
                            <label for="is_open_alipay1" class="cb-disable {if condition="$alipay.is_open_alipay == 1"}selected{/if}">关闭</label>
                            <input id="is_open_alipay0" name="alipay[is_open_alipay]" value="0" type="radio" {if condition="!isset($alipay.is_open_alipay) || empty($alipay.is_open_alipay)"} checked="checked"{/if}>
                            <input id="is_open_alipay1" name="alipay[is_open_alipay]" value="1" type="radio" {if condition="$alipay.is_open_alipay == 1"} checked="checked"{/if}>
                        </div>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label for="uname"><em></em>使用支付宝版本</label>
                    </dt>
                    <dd class="opt">
                        <label>
                            <input type="radio" name="alipay[version]" onclick="switch_set(this);" value="0" {if condition="empty($php_version) && empty($alipay.version)"}checked="checked"{/if} />新版接口
                            <span style="padding-left: 10px; color: #C0C0C0;">支持<font color="red">php5.5.0</font>或更高版本!(阿里云空间必须php7.0或以上)</span>
                        </label>
                        <br/>
                        <label>
                            <input type="radio" name="alipay[version]" onclick="switch_set(this);" value="1" {if condition="$alipay.version == 1 || $php_version == 1"}checked="checked"{/if} />旧版接口
                            <span style="padding-left: 10px; color: #C0C0C0;">可支持<font color="red">php5.4</font>或更高版本!</span>
                        </label>
                    </dd>
                </dl>

                <div id="new_version" {if condition="$alipay.version == 1 || $php_version == 1"}class="none"{/if}>
                    <dl class="row">
                        <dt class="tit">
                            <label for="username"><em>*</em>支付宝APPID</label>
                        </dt>
                        <dd class="opt">
                            <input type="text" name="alipay[app_id]" id="app_id" value="{$alipay.app_id}" class="input-txt">
                            <p class="notic">请输入您的支付宝APPID,用于支付宝支付。</p>
                        </dd>
                    </dl>
                    <dl class="row">
                        <dt class="tit">
                            <label for="username"><em>*</em>商户私钥</label>
                        </dt>
                        <dd class="opt">
                            <textarea rows="5" cols="80" id="merchant_private_key" name="alipay[merchant_private_key]" style="height:120px;">{$alipay.merchant_private_key}</textarea>
                            <p class="notic">请输入您的商户私钥,用于支付宝支付。</p>
                        </dd>
                    </dl>
                    <dl class="row">
                        <dt class="tit">
                            <label for="username"><em>*</em>支付宝公钥</label>
                        </dt>
                        <dd class="opt">
                            <textarea rows="5" cols="80" id="alipay_public_key" name="alipay[alipay_public_key]" style="height:106px;">{$alipay.alipay_public_key}</textarea>
                            <p class="notic">请输入您的支付宝公钥,用于支付宝支付。</p>
                        </dd>
                    </dl>
                </div>

                <div id="old_version" {if condition="empty($php_version) && empty($alipay.version)"}class="none"{/if}>
                    <dl class="row">
                        <dt class="tit">
                            <label for="username"><em>*</em>支付宝账号</label>
                        </dt>
                        <dd class="opt">
                            <input type="text" name="alipay[account]" id="account" value="{$alipay.account}" class="input-txt">
                            <p class="notic">请输入您的支付宝账号,用于支付宝支付。</p>
                        </dd>
                    </dl>
                    <dl class="row">
                        <dt class="tit">
                            <label for="username"><em>*</em>交易安全校验码</label>
                        </dt>
                        <dd class="opt">
                            <input type="text" name="alipay[code]" id="code" value="{$alipay.code}" class="input-txt">
                            <p class="notic">请输入您的交易安全校验码,用于支付宝支付。</p>
                        </dd>
                    </dl>
                    <dl class="row">
                        <dt class="tit">
                            <label for="username"><em>*</em>合作者身份ID</label>
                        </dt>
                        <dd class="opt">
                            <input type="text" name="alipay[id]" id="id" value="{$alipay.id}" class="input-txt">
                            <p class="notic">请输入您的合作者身份ID,用于支付宝支付。</p>
                        </dd>
                    </dl>
                </div>
                <dl class="row">
                    <div class="bot">
                        <a href="JavaScript:void(0);" onclick="alipayset();" class="ncap-btn-big ncap-btn-green" id="submitAlipayBtn">确认提交</a>
                    </div>
                </dl>
            </div>
        </form>
    </div>
</div>
<script>
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    /*微信支付配置*/
    function wechatset(){
        if($('#postWechatForm input[id=appid]').val() == ''){
            layer.alert('微信AppId不能为空!', {icon: 2, title:false});
            return false;
        }

        if($('#postWechatForm input[id=mchid]').val() == ''){
            layer.alert('微信商户号不能为空!', {icon: 2, title:false});
            return false;
        }

        if($('#postWechatForm input[id=key]').val() == ''){
            layer.alert('微信KEY值不能为空!', {icon: 2, title:false});
            return false;
        }

        layer_loading('正在处理');
        $.ajax({
            url: "{:url('Member/wechat_set', ['_ajax'=>1])}",
            type: 'POST',
            dataType: 'JSON',
            data: $('#postWechatForm').serialize(),
            success: function(res){
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {icon: 1, time: 1000});
                    return false;
                } else {
                    layer.alert(res.msg, {icon: 2, title:false});
                    return false;
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorMsg(e.responseText);
                return false;
            }
        });
    }

    function php_version(is){
        var php_version = {$php_version};
        // php_version=1,表示php本版低于5.5.0,不可用新版支付方式
        if (php_version == 1) {
            if (is == true) {
                layer.alert('PHP版本低于5.5.0,不可用新版支付方式,请使用旧版!', {icon: 2, title:false});
            }
            $("#postAlipayForm input[name='alipay[version]'][value=1]").attr("checked","checked");
            return false;
        }
        return true;
    }

    function switch_set(obj){
        var switch_set = $(obj).val();
        if (switch_set == 0) {
            if (php_version(true)) {
                $("#postAlipayForm #new_version").show();
                $("#postAlipayForm #old_version").hide();
            }
        }else if (switch_set == 1) {
            $("#postAlipayForm #new_version").hide();
            $("#postAlipayForm #old_version").show();
        }
    }

    function alipayset(){
        var switch_set = $("#postAlipayForm input[name='alipay[version]']:checked").val();
        if (switch_set == 0) {
            // 新版判断
            if($('#postAlipayForm #app_id').val() == ''){
                layer.alert('支付APPID不能为空!', {icon: 2, title:false});
                return false;
            }

            if($('#postAlipayForm #merchant_private_key').val() == ''){
                layer.alert('商户私钥不能为空!', {icon: 2, title:false});
                return false;
            }

            if($('#postAlipayForm #alipay_public_key').val() == ''){
                layer.alert('支付宝公钥不能为空!', {icon: 2, title:false});
                return false;
            }
        }else if (switch_set == 1) {
            // 旧版判断
            if($('#postAlipayForm #account').val() == ''){
                layer.alert('支付宝账号不能为空!', {icon: 2, title:false});
                return false;
            }

            if($('#postAlipayForm #code').val() == ''){
                layer.alert('交易安全校验码不能为空!', {icon: 2, title:false});
                return false;
            }

            if($('#postAlipayForm #id').val() == ''){
                layer.alert('合作者身份ID不能为空!', {icon: 2, title:false});
                return false;
            }
        }

        layer_loading('正在处理');
        $.ajax({
            url: "{:url('Member/alipay_set', ['_ajax'=>1])}",
            type: 'POST',
            dataType: 'JSON',
            data: $('#postAlipayForm').serialize(),
            success: function(res){
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {icon: 1, time: 1000});
                    return false;
                } else {
                    layer.alert(res.msg, {icon: 2, title:false});
                    return false;
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorMsg(e.responseText);
                return false;
            }
        });
    }

</script>

{include file="public/footer" /}