<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <script src="/static/weixin/js/flexible.js"></script>
    <link rel="stylesheet" href="/static/weixin/css/public.css">
    <link rel="stylesheet" href="/static/weixin/css/new_basic.css">
    <title>收入管理</title>
    <style>
        .left{
            float: left;
            position: absolute;
            top: 25px;
            left: 25px;
        }
        .product-cont{
            display:none;
        }

    </style>

</head>
<body id="contain">
<div class="new-head-bill">
    <span>收入管理</span>
    <a href="/weixin/primaryPage/list" class="left">
        <img src="/static/weixin/images/head-left.png"/>
    </a>
</div>
<div class="new-bill-main">
    <img src="/static/weixin/images/home_background.png" />


    <div class="lmb-zhang-content">
        <h2>总收入</h2>
        <p class="money">${total.sum}</p>
        <span>共<font style="padding:0 0.2rem">${total.cnt}</font>笔</span>
    </div>


    <div class="main-content" >
        <div class="main-left" style="text-align: center;">
            <p>本月收益</p>
            <span>${row.sum}</span>
            <p>共<i>${row.cnt}</i>笔</p>
        </div>
        <c:if test="${p.weixin_login_distribution_level!='3' }">
            <c:if test="${p.weixin_login_company_type!=4}">
                <div class="main-right" style="text-align: center;">
                    <p>下级收入</p>
                    <span id="lowLevelSum"></span>
                    <p>共<i id="lowLevelCnt"></i>笔</p>
                </div>
            </c:if>
        </c:if>

    </div>
</div>
<div class="bill-product">
    <div class="product-cont blb">
        <a id="blb">
            <div class="product-head">
                <img src="/static/weixin/images/new_bill-banner-s1.png"/>
                <span>保险产品</span>
            </div>
            <div class="product-ert">
                <div class="ert-trans">
                    <p>本月交易:</p>
                    <span>${row.ins_cnt} 笔</span>
                </div>
                <div class="ert-income">
                    <p>收入:</p>
                    <span>${row.ins_sum} </span>
                </div>
            </div>
        </a>
    </div>
    <div class="product-cont pss">
        <a id="pss">
            <div class="product-head">
                <img src="/static/weixin/images/new_bill-banner-s2.png"/>
                <span>风评产品</span>
            </div>
            <div class="product-ert">
                <div class="ert-trans">
                    <p>本月交易:</p>
                    <span>${row.risk_cnt} 笔</span>
                </div>
                <div class="ert-income">
                    <p>收入:</p>
                    <span>${row.risk_sum}</span>
                </div>
            </div>
        </a>
    </div>
    <div class="product-cont sts">
        <a id="sts">
            <div class="product-head">
                <img src="/static/weixin/images/new_bill-banner-s3.png"/>
                <span>培训产品</span>
            </div>
            <div class="product-ert">
                <div class="ert-trans">
                    <p>本月交易:</p>
                    <span>${row.train_cnt} 笔</span>
                </div>
                <div class="ert-income">
                    <p>收入:</p>
                    <span>${row.train_sum}</span>
                </div>
            </div>
        </a>
    </div>
</div>
</body>
<script src="/static/weixin/js/jquery-1.8.3.min.js"></script>
<script src="/static/weixin/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weixin/common/layer_mobile/need/right.css">
<script src="/static/weixin/common/jquery.formHelper.js"></script>
<script type="text/javascript" src="/static/weixin/js/g.js"></script>
<script>


    $(function () {
        //清空查询条件缓存
        function clearConditionCache(){
            sessionStorage.removeItem("sel_region");
            sessionStorage.removeItem("sel_startTime");
            sessionStorage.removeItem("sel_endTime");
            sessionStorage.removeItem("sel_project");
            sessionStorage.removeItem("sel_company");
        }(clearConditionCache())

        $("#blb").click(function () {
            sessionStorage.setItem("sel_product_type",6);
            window.location.href="/weixin/bill/list?product_type=6";
        })
        $("#pss").click(function () {
            sessionStorage.setItem("sel_product_type",7);
            window.location.href="/weixin/bill/list?product_type=7";
        })
        $("#sts").click(function () {
            sessionStorage.setItem("sel_product_type",8);
            window.location.href="/weixin/bill/list?product_type=8";
        })

//        $(".product-cont").hide();
        layer.open({type:2})
        g_ajax("/weixin/bill/getProductTypeByCompanyId",{},function(json){
            console.log(json);
            for(var i in json){
                if(json[i].product_type=="6"){
                    $(".blb").show();
                }
                if(json[i].product_type=="7"){
                    $(".pss").show();
                }
                if(json[i].product_type=="8"){
                    $(".sts").show();
                }
            }
            layer.closeAll();
            checkBill();
        },true);

        function checkBill(){
            //查询账单信息
            layer.open({type:2})
            $.ajax({
                type: 'POST',
                url: "/weixin/bill/query-sum-belwo-bill",
                dataType: "json",
                async: true,
                success: function (json) {
                    layer.closeAll();
                    if(json!=null && json[0].total_below!=null && json[0].total_below!=undefined) {
                        $("#lowLevelSum").html(json[0].total_below.toFixed(2));
                    }else{
                        $("#lowLevelSum").html("0.00");
                    }
                    if(json!=null && json[0].total_cnt!=undefined && json[0].total_cnt!=null) {
                        $("#lowLevelCnt").html(json[0].total_cnt);
                    }else{
                        $("#lowLevelCnt").html(0);
                    }
//                $("#lowLevelNum").html(data.total);
                }
            });
        }

    });
</script>
</html>