<!DOCTYPE html>
<html lang="zh">
<head>
    <@meta/>
    <title>支付应用管理</title>
    <#include "admin/common/include_hplus.ftl">
    <#include "admin/common/include_form.ftl">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h3>${module.name}</h3><a href="javascript:history.back(-1);" class="btn btn-link">| 返回列表</a>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" action="<@contextPath/>/dmp/pay_apply/save" method="post">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">应用ID：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" value="${entity.app_id }" readonly>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>应用名称：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" required="" aria-required="true" name="app_name" value="${entity.app_name }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>应用密钥：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" required="" aria-required="true" name="app_secret" value="${entity.app_secret }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>签名方式：</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="radio" name="sign_type" value="" <#if entity.sign_type == ''>checked</#if>>无</label>
                                    <label><input type="radio" name="sign_type" value="MD5" <#if entity.sign_type == 'MD5'>checked</#if>>MD5</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>状态：</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="radio" name="status" value="1" checked>启用</label>
                                    <label><input type="radio" name="status" value="0" <#if entity.status == '0'>checked</#if>>禁用</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>支付渠道：</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="radio" name="channel_type" value="ALI_APP" <#if entity.channel_type == 'ALI_APP'>checked</#if>>支付宝-APP支付</label>
                                    <label><input type="radio" name="channel_type" value="ALI_WAP" <#if entity.channel_type == 'ALI_WAP'>checked</#if>>支付宝-H5支付</label>
                                    <label><input type="radio" name="channel_type" value="WX_APP" <#if entity.channel_type == 'WX_APP'>checked</#if>>微信-APP支付</label>
                                    <label><input type="radio" name="channel_type" value="WX_MWEB" <#if entity.channel_type == 'WX_MWEB'>checked</#if>>微信-H5支付</label>
                                    <label><input type="radio" name="channel_type" value="WX_JSAPI" <#if entity.channel_type == 'WX_JSAPI'>checked</#if>>微信-JSAPI支付</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">回调地址：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="business_notice_url" value="${entity.business_notice_url }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="desc" value="${entity.desc }">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">app_id：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="pay_config.app_id" value="${entity.pay_config.app_id }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商户号：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="pay_config.channel_account" value="${entity.pay_config.channel_account }">
                            </div>
                        </div>
                        <div class="form-group channel_type_wx">
                            <label class="col-sm-2 control-label">商户API密钥：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="pay_config.merchant_api_key" value="${entity.pay_config.merchant_api_key }">
                            </div>
                        </div>
                        <div class="form-group channel_type_wx">
                            <label class="col-sm-2 control-label">商户证书路径(退款用)：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="pay_config.cert_path" value="${entity.pay_config.cert_path }">
                            </div>
                        </div>

                        <div class="form-group channel_type_ali">
                            <label class="col-sm-2 control-label">应用私钥：</label>
                            <div class="col-sm-8">
                                <textarea class="form-control" name="pay_config.rsa_private_key">${entity.pay_config.rsa_private_key }</textarea>
                            </div>
                        </div>
                        <div class="form-group channel_type_ali">
                            <label class="col-sm-2 control-label">应用公钥：</label>
                            <div class="col-sm-8">
                                <textarea class="form-control" name="pay_config.ali_pay_application_public_key">${entity.pay_config.ali_pay_application_public_key }</textarea>
                            </div>
                        </div>
                        <div class="form-group channel_type_ali">
                            <label class="col-sm-2 control-label">支付宝公钥：</label>
                            <div class="col-sm-8">
                                <textarea class="form-control" name="pay_config.ali_pay_common_public_key">${entity.pay_config.ali_pay_common_public_key }</textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">支付成功后跳转URL：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="pay_config.return_url" value="${entity.pay_config.return_url }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">中途退出时返回的URL：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="pay_config.quit_url" value="${entity.pay_config.quit_url }">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                        <input type="hidden" name="id" value="${entity.app_id }">
                        <input type="hidden" name="editType" value="${editForm.editType }">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){

        $.form.render(function () {
            history.go(-1);
        });

        var changChannelType = function(channel_type) {
            if(channel_type == 'ALI_APP' || channel_type == 'ALI_WAP' || channel_type == '1' || channel_type == '2'){
                $('.channel_type_ali').show();
                $('.channel_type_wx').hide();
            }else{
                $('.channel_type_wx').show();
                $('.channel_type_ali').hide();
            }
        }

        //类型单选改变事件,要放在$.form.render()之后
        $('input').on('ifChecked', function(event){
            if($(this).attr('name') == 'channel_type'){
                var channel_type = $(this).val();
                changChannelType(channel_type);
            }
        });

        var channel_type = $('input[type=radio][name=channel_type]:checked').val();
        changChannelType(channel_type);
    });
</script>
</body>
</html>