<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fns" uri="/WEB-INF/tld/fns.tld" %>
<div class="product-center pro-none" style="display: none;" id="product-center-ert">
    <ul class="product-s clearfix">
        <li class="on">
            <a href="javascript:;">保证保险</a>
            <div class="line"></div>
        </li>
        <li class="">
            <a href="javascript:;">信用保险</a>
            <div class="line"></div>
        </li>
        <li>
            <a href="javascript:;">责任保险</a>
            <div class="line"></div>
        </li>
        <li>
            <a href="javascript:;">员福保险</a>
            <div class="line"></div>
        </li>
        <%--<li>
            <a href="javascript:;">个人保险</a>
            <div class="line"></div>
        </li>--%>
    </ul>
    <div class="center-content">
        <div class="center-icon clearfix" style="display: block;">
            <div class="s1-left fl">
                <%--<p>投标保证保险</p>
                <div class="rt_s1 clearfix gctb">
                </div>--%>
                <%--<ol class="clearfix">
                    <li class="yui"><a href="<c:url value='/insurance/product/productInfo/1001013' />">太平洋投标保证保险保函</a></li>
                    <li class="yui"><a href="<c:url value='/insurance/product/productInfo/917654202130763778' />">阳光工程投标保证保险保函</a></li>
                    <li class="yui"><a href="<c:url value='/insurance/product/productInfo/938242814941503490' />">都邦工程投标保证保险保函</a></li>
                </ol>--%>
                <%--<p class="mt-20">履约保证保险</p>
                <div class="rt_s1 clearfix gcly">
                </div>--%>
                <%--<ol class="clearfix">
                    <li class="yui"><a href="<c:url value='/insurance/product/productInfo/1001014' />">建设合同履约保证保险保函</a></li>
                </ol>--%>
            </div>
            <div class="s1-right fl">
            </div>
        </div>
        <div class="center-icon s-none" style="display: none;">
            <div class="s1-left fl">
                <%--<p>信用保险</p>
                <div class="rt_s1 clearfix xyx">
                </div>--%>
                <%--<ol class="clearfix">
                    <li class="yui"><a href="<c:url value='/insurance/product/productInfo/1001012' />">小微企业出口信用保险</a>
                    </li>
                    <li class="yui"><a
                            href="<c:url value='/insurance/product/productInfo/1001011' />">短期出口信用保险</a></li>
                </ol>--%>
            </div>
            <div class="s1-right fl">
            </div>
        </div>
        <div class="center-icon s-none" style="display: none;">
            <div class="s1-left fl">
                <p>公众责任保险</p>
                <div class="rt_s1 clearfix gzx">
                </div>
                <p class="mt-20">雇主责任保险</p>
                <div class="rt_s1 clearfix gzzrx">
                </div>
            </div>
            <div class="s1-right fl">
                <p>展会责任保险</p>
                <div class="rt_s1 clearfix zzx">
                </div>
                <p class="mt-20">其他责任保险</p>
                <div class="rt_s1 clearfix ssbq">
                </div>
            </div>
        </div>
        <div class="center-icon s-none" style="display: none;">
            <div class="s1-left fl clearfix">
                <p>意外保险</p>
                <div class="rt_s1 clearfix tyx">
                </div>
            </div>
            <div class="s1-right fl">
                <p>综合意外险</p>
                <div class="rt_s1 clearfix gyx">
                </div>
            </div>
        </div>
        <div class="center-icon s-none" style="display: none;">
            <div class="s1-left fl">
            </div>
            <div class="s1-right fl">
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="<c:url value='/resources/script/jquery-1.10.2.min.js' />"></script>
<script type="text/javascript" src="<c:url value='/resources/commonJS/con-common.js' />"></script>
<script>
    var baseUrl = '${pageContext.request.contextPath }';
    var _com_key = 'pZoxm3Il5idd5vDriwgSEYcSgTDjtcOBaqurw+';
    var _token = '';
    if('${ACCESS_TOKEN}'!=''){
        _token = '?ACCESS_TOKEN=${ACCESS_TOKEN}';
    }
    /*if(window.localStorage && localStorage.getItem(_com_key+'value')){
        var _v = localStorage.getItem(_com_key+'value');
        if(_v != 'undefined'){
            // console.log(_v);
            $('.center-content').html(_v);
            $(".center-content a[href]").each(function(){
                $(this).attr('href','${fns:getResource('BUSINESS_URL')}'+$(this).attr('href')+_token)
            })
            /!*$(".center-content a").each(index=>{
                var href=$(".center-content a").eq(index).attr("href");
                $(".center-content a").eq(index).attr("href",href+'?ACCESS_TOKEN=${ACCESS_TOKEN}')
            })*!/
        }
    }*/
    getProductBySg();
    function getProductBySg(){//方法总耗时1~2秒
        //配套js(/resources/commonJS/con-common.js)1.表单参数，2.请求地址，3.是否同步，4.是否遮盖，5.返回处理
        setParamDatas('',baseUrl+'/synopsis/product/productList',true,false,function(data){
            setData(data);
            /*if(! window.localStorage){
                setData(data);
            }else{
                var _com_key_key = localStorage.getItem(_com_key+'key');//拿已经存在的菜单列表对应的key
                var _com_key_value = localStorage.getItem(_com_key+'value');//拿已经存在的菜单列表html
                var kText = filterKeyInformation(data);
                if(_com_key_value=='undefined' || _com_key_key!=kText){
                    setData(data);
                    localStorage.setItem(_com_key+'key',kText);
                    localStorage.setItem(_com_key+'value',$('.center-content').html());
                }else{
                   // setData(data);
                    localStorage.setItem(_com_key+'key',kText);
                    localStorage.setItem(_com_key+'value',_com_key_value);
                }
            }*/
            /*$(".center-content a[href]").each(function(){
                var _hrf = $(this).attr('href').split('?')[0];
                $(this).attr('href','${fns:getResource('BUSINESS_URL')}'+_hrf+_token)
            })*/
        });
    }

    function setData(data){
        zzHtml(data,'gctb','BZX-TB,BZX-YG,BZX-DB');
        zzHtml(data,'gcly','BZX-GCLY');
        zzHtml(data,'xyx','XYX-DQCK,XYX-XWCK');
        zzHtml(data,'gzzrx','GZZRX-ZH,GZZRX-PAC,GZZRX-CA,GZZRX-TB,GZZRX-QH');
        zzHtml(data,'ssbq','BZX-SSBQ');
        zzHtml(data,'gzx','GZX-HT,GZX-PAC,GZX-CA');
        zzHtml(data,'zzx','ZZX-HT,ZZX-ZA,ZZX-PAC,ZZX-YA,ZZX-CA');
        zzHtml(data,'tyx','TYX-HT,TYX-QH,TYX-RB,TYX-TK,TYX-PAS,TYX-PAC,TYX-CA');
        zzHtml(data,'gyx','GYX-TB,GYX-CA');
    }

    function filterKeyInformation(_data){
        var key = '';
        if(_data){
            $.each(_data, function(i, obj){
                var onc = obj.product_name+obj.product_code+obj.oid;
                key = key+onc;
            });
            return key!=''?key.replace(/-/ig,''):key;
        }
        return key;
    }

    //组装html列
    function zzHtml(_data,_class,_type){
        var _html = '';
        var at = _type.split(',');
        var arrayObj = new Array();
        $.each(at, function(n, t){
            var _hs = '';
            $.each(_data, function(i, obj){
                if(obj.product_code != ''&&obj.product_code!=null&&obj.product_code!=undefined){
                    if(obj.product_code.indexOf(t)!=-1&&obj.product_code.indexOf('GZZRX-CA-DQ')==-1){
                        var _headurl = obj.headurl == undefined? '' : obj.headurl;
                        var _url = _headurl+"/insurance/product/productInfo/" + obj.oid+_token;
                        _hs = _hs + "<li class='yui'><a  href='" + _url + "' ";
                        _hs = _hs + ">" + obj.product_name + "</a></li>";
                        arrayObj.push(i);
                    }
                    /*if(obj.product_code.indexOf(t)!=-1 && (obj.product_code==(t+'-1')||obj.product_code.split('-').length==2)){
                        var _url = "${fns:getResource('BUSINESS_URL')}/insurance/product/productInfo/" + obj.oid+_token;
                        _hs = _hs + "<li class='yui'><a  href='" + _url + "' ";
                        _hs = _hs + ">" + obj.product_name.replace('计划一','') + "</a></li>";
                        arrayObj.push(i);
                    }*/
                }else {
                    arrayObj.push(i);
                }
            });
            if(_hs != ''){
                _html = _html + '<div class="rt_s1_div"><ol class="clearfix">'+_hs+'</ol></div>';
            }
        });
        arrayObj = arrayObj.sort(sortNumber);
        $.each(arrayObj, function(x, rj){
            _data.remove(rj);
        });
        $('.'+_class).html(_html);
    }
    function sortNumber(a, b)
    {
        return b - a
    }
    //数组去重
    function unique(arr){
        // 遍历arr，把元素分别放入tmp数组(不存在才放)
        var tmp = new Array();
        for(var i in arr){
            //该元素在tmp内部不存在才允许追加
            if(arr[i].length>0){
                var _nm = Number(arr[i]);
                if(tmp.indexOf(_nm)==-1){
                    tmp.push(_nm);
                }
            }
        }
        return tmp.sort(sortNum);
    }
    function sortNum(a,b) {
        return b - a; //升序，如降序，把“a - b”该成“b - a”
    }
    //根据下标删除数组对应元素
    Array.prototype.remove=function(obj){
        for(var i =0;i <this.length;i++){
            var temp = this[i];
            if(!isNaN(obj)){
                temp=i;
            }
            if(temp == obj){
                for(var j = i;j <this.length;j++){
                    this[j]=this[j+1];
                }
                this.length = this.length-1;
            }
        }
    }

</script>