<!DOCTYPE html>
<html lang="zh">
<#include "/include/header.html">
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <#include "/include/left.html">
        <!--End 左侧导航-->
        <!--头部信息-->
        <#include "/include/topbar.html">
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">
                <P style="text-align: center;color: #ff7b1a;font-size: initial">通知：结算中心于：2022年4月1日0点起生效，再此时间之前的订单还按之前方式结算！</P>
                <!--卡片数据部分：开始-->
                <div class="row">
                    <div class="col-lg-12">
                        <#include "/include/block/chart/cards.html">
                    </div>
                </div>
                <!--卡片数据部分:结束-->
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="panel" style="margin-bottom: auto">
                                <div class="panel-heading">
                                    <h3 class="panel-title">
                                        组合条件筛选
                                    </h3>
                                </div>
                                <!--组合条件组件-->
                                <#include "/include/table/table-query.html">
                            </div>
                            <div class="card-toolbar clearfix" style="padding: 0px 24px 0px 24px">
                                <div class="toolbar-btn-action" id="toolBar">
                                    <#include "/include/table/table-batch.html">
                                </div>
                            </div>
                            <!--快速搜索框-->
                            <div class="card-body" style="padding: 10px 15px">
                                <div class="pull-right" id="id_search_column"
                                     style="position: absolute;right: 295px;margin-top: 10px;">
                                    <input type="hidden" name="search_field" id="search-field" value="">
                                    <button class="btn btn-default dropdown-toggle" id="search-btn"
                                            data-toggle="dropdown" type="button" aria-haspopup="true"
                                            aria-expanded="false">
                                        全部 <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu" style="min-width: auto">
                                        <li><a tabindex="-1" href="javascript:void(0)" data-field="">全部</a></li>
                                        <#list pageTemplate.tableSearch as search>
                                            <li><a tabindex="-1" href="javascript:void(0)" data-field="${search.key!}">${search.name}</a></li>
                                        </#list>
                                    </ul>
                                </div>
                                <!--Bootstarp Table插入-->
                                <#include "/include/table/table-data.html">
                            </div>
                        </div>

                    </div>

                </div>
            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<!--收款账户列表模态框-->
<div id="id_user_build" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myLargeModalLabel">收款账户管理</h4>
            </div>
            <div class="modal-body">
                <div id="but_test">
                    <button type="button" class="btn btn-primary" onclick="showBuildCode()">绑定收款账户</button>
                </div>
                <table id="id_build_table"></table>
            </div>
            <div class="modal-footer">
                <P style="color: #f0ad4e;text-align: center">提示：重复绑定无效，必须先解绑，再绑定新的</P>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--收款账户扫码绑定模态框-->
<div id="id_user_build_code_view" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title">收款账户绑定</h4>
            </div>
            <div class="modal-body">
                <div class="card-body" style="padding: 0 0">
                    <ul class="nav nav-tabs nav-justified">
                        <li class="active">
                            <a data-toggle="tab" href="#code-wx">微信授权码</a>
                        </li>
                        <li class="nav-item">
                            <a data-toggle="tab" href="#code-zfb">支付宝授权码</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane fade active in" id="code-wx">
                            <div id="id_code_wx" style="text-align: -moz-center;"></div>
                            <P style="text-align: center;margin-top: 15px;font-size: initial;color: darkgray;">
                                请先关注：<a style="color: #da352f" href="#"onmouseout="hideImg()" onmouseover="showImg()">
                                <span>"同城急送"</span>
                                <img id="gzhImg" src="https://oss.bhynm.com/delivery/upload/2022/3/25/164820659348973.jpg" style="display:none;height:90px;back-ground:#f00;position:absolute;left: 22%;">
                                </a>
                                官方微信公众号后，再使用微信扫码绑定。
                            </P>
                        </div>
                        <div class="tab-pane fade" id="code-zfb">
                            <div id="id_code_zfb" style="text-align: -moz-center;"></div>
                            <p style="text-align: center;margin-top: 15px;font-size: initial;color: darkgray;">请使用：
                                <span style="color: #00A0E9">支付宝</span> APP进行扫码</p>
                        </div>

                    </div>

                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--安全验证模态框-->
<div id="id_un_build_model" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title">安全验证</h4>
            </div>
            <div class="modal-body">
                <div class="input-group">
                    <span class="input-group-addon">发送至:</span>
                    <input type="text" class="form-control" readonly value="${loginUser.userPhone!}">
                    <span class="input-group-btn">
                        <button class="btn btn-info" type="button" id="id_send_code_but" onclick="sendCode('${loginUser.userPhone!}')">  发送  </button>
                    </span>
                </div>
                <br>
                <div class="input-group">
                    <span class="input-group-addon">验证码:</span>
                    <input type="text" class="form-control" placeholder="输入短信验证码" maxlength="6" id="id_msg_code_text">
                    <span class="input-group-btn">
                        <button id="id_msg_code_verify" class="btn btn-success" type="button" onclick="verifyCode('${loginUser.userPhone!}')" disabled>确认</button>
                    </span>
                </div>
                <input id="id_hide_input_account" type="hidden">
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!--安全验证模态框结束-->
<#include "/include/footer.html">
<#include "/include/table/table-event.html">
<#include "/include/table/table-model.html">
<!--页面生成二维码插件-->
<script type="text/javascript" src="https://oss.bhynm.com/delivery/upload/2022/3/29/164852354402792.js"></script>
<!--以下为业务流程处理-->
<script>
    /**
     * 生成表格
     */
    createTable({
        id:"id_build_table",
        url:"${ctx}/company/fran/get/list/group",
        attribute:{
            toolbar: "#but_test"
        },
        query:{},
        columns:[
            {
                field:"userId",
                title:"用户",
                formatter:function (value, row, index){
                    let fran=getEntity("t_franchisee_information",value);
                    if (fran){
                        return fran.fran_type;
                    }
                }
            },
            {
                field: "wxAppType",
                title: "收款渠道",
                formatter:function (value, row, index){
                    if ("ZFB_WEB"===value){
                        return "支付宝余额";
                    }
                    if ("GZH"===value){
                        return "微信零钱";
                    }
                }
            },
            {
                field:"wxUserOpenid",
                title:"收款人识别号"
            },
            {
                field:"gmtCreate",
                title:"绑定时间"
            }
        ],
        operate:[
            {
                name:"解绑账户",
                method:'unbind'
            }
        ]
    });
    /**
     * 解绑定账户
     **/
    function unbind(row){
        $.confirm({
            title: '注意事项',
            content: "1、解绑后将会清除您的收款账户信息<br>2、解绑后需要重新绑定收款账户才能提现。<br>3、本次操作需要进行短信验证。",
            type: 'blue',
            typeAnimated: true,
            buttons: {
                tryAgain: {
                    text: '继续',
                    btnClass: 'btn-blue',
                    action: function(){
                        $("#id_hide_input_account").val(row.id);
                        $("#id_user_build").modal('hide');
                        $("#id_un_build_model").modal('show');
                        $('#id_un_build_model').on('hide.bs.modal',
                            function() {
                                $("#id_user_build").modal('show');
                            });
                    }
                },
                close: {
                    text: '取消'
                }
            }
        });
    }

    /**
     * 显示授权二维码模态框
     **/
    function showBuildCode(){
        makeCode("/company/fran/get/wx/auth/url","id_code_wx","#06AD56",'https://oss.bhynm.com/delivery/upload/2022/3/29/164852323024812.jpg');
        makeCode("/company/fran/get/zfb/auth/url","id_code_zfb","#00A0E9",'https://oss.bhynm.com/delivery/upload/2022/3/29/164852304400549.jpg');
        $("#id_user_build").modal('hide');
        $("#id_user_build_code_view").modal('show');
        $('#id_user_build_code_view').on('hide.bs.modal',
            function() {
            $("#id_user_build").modal('show');
        })
    }
    /**
     * 生成二维码
     */
    function makeCode(url,id,color,logo) {
        $("#"+id).empty();
        document.getElementById("js_load").style.display = "inline";
        $.ajax({
            data: {},
            type: "GET",
            url: "${ctx!}"+url,
            success : function (res) {
                if (res.status===200){
                    document.getElementById("js_load").style.display = "none";
                    new QRCode(document.getElementById(id), {
                        width : 400,
                        height : 400,
                        colorDark : color,
                        colorLight : "#ffffff",
                        correctLevel : 3,
                        text:res.body,
                        imgSrc: logo,
                        imgWidth: 60,
                        imgHeight: 60
                    });
                }
            }
        });
    }
    /**
     * 打开提现账户管理模态款
     **/
    function showBuildModel(){
        $("#id_user_build").modal('show');

    }

    /**
     * 发送验证码
     **/
    function sendCode(phone){
        sendAjax("${ctx}/company/fran/get/gms/code","GET",{phone:phone});
        let time=60;
        let but=$("#id_send_code_but");
        $("#id_msg_code_verify").removeAttr("disabled");
        but.attr({"disabled":"disabled"});
        let loop=setInterval (function () {
            but.text(time+"S");
            time-=1;
            if (time<0){
                clearInterval(loop);
                but.removeAttr("disabled");
                but.text("发送");
            }
        }, 1000);
    }
    /**
     * 验证验证码
     **/
    function verifyCode(phone){
        let code=$("#id_msg_code_text").val();
        if ((!code)||code.length<1){
            lightyear.notify("请输入验证码！", 'danger');
            return;
        }
        runAjax("${ctx}/company/fran/get/verify/code","GET",{phone:phone,code:code},function (res){
            runAjax("${ctx}/company/fran/get/del/build","GET",{id:$("#id_hide_input_account").val()},function (res){
                lightyear.notify("解绑成功！", 'success');
                $("#id_un_build_model").modal('hide');
                $('#id_build_table').bootstrapTable('refresh',{url: "${ctx}/company/fran/get/list/group"});
            })
        });
    }

    /**
     * 发起结算
     * */
    function toComp(){
        $.confirm({
            title: '注意事项',
            content: "1、发起结算后需要等待平台审核。<br>2、审核通过后收益金额将汇入您的任一收款账户。",
            type: 'blue',
            typeAnimated: true,
            buttons: {
                tryAgain: {
                    text: '继续',
                    btnClass: 'btn-blue',
                    action: function(){
                        runAjax("${ctx}/company/fran/get/check/account","GET",{},function (res){
                            runAjax("${ctx}/company/fran/get/to/company","GET",{},function (res){
                                lightyear.notify("申请成功，系统正在统计您的订单，您可以稍后刷新页面查看详情...", 'success');
                            });
                        });
                    }
                },
                close: {
                    text: '取消'
                }
            }
        });
    }

    /**
     * 撤销*
     *
     */
    function del(){
        sendAjax("${ctx}/company/fran/get/del/ids","GET",{id:getTableSelectOne().id})
    }

    /**
     *
     */
    function  showImg(){
        document.getElementById("gzhImg").style.display='block';
    }
    function hideImg() {
        document.getElementById("gzhImg").style.display = 'none';
    }
</script>
</body>
</html>