<%@ 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="">
    <link rel="stylesheet" href="/static/weixin/css/public.css">
    <link rel="stylesheet" href="/static/weixin/css/wechat_add_new.css">
    <link rel="stylesheet" href="/static/weixin/css/basic.css">
    <script src="/static/weixin/js/flexible.js"></script>
    <style>
        .hall-booth .hall-booth-content h2 span.name {
            white-space: normal;
        }
    </style>
    <title>展厅展位</title>
</head>
<body id="contain">
<div class="contain lm_contain">
    <div class="bai-head">
        <span>展厅展位</span>
        <a id="goback" class="left">
            <img src="/static/weixin/images/head-left.png"/>
        </a>
        <div class="search">
            <a href="/weixin/exhibition/exhibition-search-view?activityId=${p.activityId}">
                <img src="/static/weixin/images/search_white.png"/>
            </a>
        </div>
    </div>
    <div class="insurance_situation">
        <span class="situation">已投保</span>
        <span>未投保</span>
    </div>
    <div class="lm_booth_content">
       <%-- <div class="hall-booth">
            <div class="hall-booth-content">
                <h2>
                    <p class="tyu">
                        <span>建筑保险展会A01展厅</span><br/>
                        <i>投保展位<em>126</em>/210</i>
                    </p>
                    <span class="zhan">展厅设置</span>
                </h2>
                <div class="hall-add-kong">
                    <div class="add-kong">
                        <span class="add">+添加展位</span>
                        <span class="kong">清空展位</span>
                    </div>
                    <div class="lm_content">
                        <ul>
                            <li>
                                <span>A001</span>
                            </li>
                            <li>
                                <span>A002</span>
                            </li>
                            <li>
                                <span class="on">A003</span>
                            </li>
                            <li>
                                <span>A004</span>
                            </li>
                            <li>
                                <span>A005</span>
                            </li>
                            <li>
                                <span class="on">A006</span>
                            </li>
                            <li>
                                <span>A007</span>
                            </li>
                            <li>
                                <span class="on">A008</span>
                            </li>
                            <li>
                                <span class="on">A009</span>
                            </li>
                            <li>
                                <span>A0010</span>
                            </li>
                            <li>
                                <span class="on">A0011</span>
                            </li>
                            <li>
                                <span>A0012</span>
                            </li>
                            <li>
                                <span class="on">A0013</span>
                            </li>
                            <li>
                                <span>A0014</span>
                            </li>
                            <li>
                                <span>A0015</span>
                            </li>
                            <li>
                                <span>A0016</span>
                            </li>
                            <li>
                                <span>A0017</span>
                            </li>
                        </ul>
                    </div>

                    <div class="down-tip">
                        <a href="javascript:;" class="down-show">
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="hall-booth">
            <div class="hall-booth-content">
                <h2>
                    <p class="tyu">
                        <span>建筑保险展会A02展厅</span><br/>
                        <i>投保展位<em>126</em>/210</i>
                    </p>
                    <span class="zhan">展厅设置</span>
                </h2>
                <div class="hall-add-kong">
                    <div class="add-kong">
                        <span class="add none_number">+添加展位</span>
                    </div>
                    <div class="lm_content">
                        <ul></ul>
                    </div>
                    <div class="down-tip">
                        <a href="javascript:;" class="down-show">
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="hall-booth">
            <div class="hall-booth-content">
                <h2>
                    <p class="tyu">
                        <span>建筑保险展会A05展厅</span><br/>
                        <i>投保展位<em>126</em>/210</i>
                    </p>
                    <span class="zhan">展厅设置</span>
                </h2>
                <div class="hall-add-kong">
                    <div class="add-kong">
                        <span class="add">+添加展位</span>
                        <span class="kong">清空展位</span>
                    </div>
                    <div class="lm_content">
                        <ul>
                            <li>
                                <span>A001</span>
                            </li>
                            <li>
                                <span class="on">A002</span>
                            </li>
                            <li>
                                <span>A003</span>
                            </li>
                            <li>
                                <span class="on">A004</span>
                            </li>
                            <li>
                                <span>A005</span>
                            </li>
                            <li>
                                <span>A006</span>
                            </li>

                        </ul>
                    </div>

                    <div class="down-tip">
                        <a href="javascript:;" class="down-show">
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="hall-booth">
            <div class="hall-booth-content">
                <h2>
                    <p class="tyu">
                        <span class="name">建筑保险展会A05展厅</span><br/>
                        <i>投保展位<em>126</em>/210</i>
                    </p>
                    <span class="zhan">展厅设置</span>
                </h2>
                <div class="hall-add-kong">
                    <div class="add-kong">
                        <span class="add">+添加展位</span>
                        <span class="kong">清空展位</span>
                    </div>
                    <div class="lm_content">
                        <ul>
                            <li>
                                <span>A001</span>
                            </li>
                            <li>
                                <span>A002</span>
                            </li>
                            <li>
                                <span>A003</span>
                            </li>
                            <li>
                                <span>A004</span>
                            </li>
                            <li>
                                <span>A005</span>
                            </li>
                            <li>
                                <span>A006</span>
                            </li>

                        </ul>
                    </div>

                    <div class="down-tip">
                        <a href="javascript:;" class="down-show">
                        </a>
                    </div>
                </div>
            </div>
        </div>--%>
    </div>
</div>
<div class="pro-steps assigned-steps">
    <div class="steps">
        <button class="xia">+增加展厅</button>
    </div>
</div>

<!--弹窗-->
<!--展厅设置-->
<div class="exhibition_hall_setting lm_hall_detailed">
    <div class="hall_header">
        <p>展厅设置</p>
        <span><img src="/static/weixin/images/search-error.png"></span>
    </div>
    <div class="hall_content">
        <p>展厅名称</p>
        <input class="exhibition_hall_name" type="text" placeholder="请填写新的展厅名称">
    </div>
    <div class="hall_footer_one">
        <span class="strike_out">删除该展厅</span>
        <span class="sure">确定</span>
    </div>
</div>

<!--新增展厅-->
<div class="new_exhibition_hall lm_hall_detailed">
    <div class="hall_header">
        <p>新增展厅</p>
        <span><img src="/static/weixin/images/search-error.png"></span>
    </div>
    <div class="hall_content">
        <p>展厅名称</p>
        <input id="new_exhibiton_hall_name" type="text" placeholder="请填写展厅名称">
    </div>
    <div class="hall_footer_one">
        <span class="cancel">取消</span>
        <span id="new_exhibiton_hall_sure" class="sure">确定</span>
    </div>
</div>

<!--添加展位-->
<div class="add_booth lm_hall_detailed">
    <div class="hall_header">
        <p>添加展位</p>
        <span><img src="/static/weixin/images/search-error.png"></span>
    </div>
    <div class="hall_content">
        <%--<h2>填写规范：<br/>展位号标识：大写英文字母或中文组合--%>
            <%--<br/>展位号区间：001-999</h2>--%>
        <p>展位号标识</p>
        <%--<input class="mark" type="text" placeholder="如: A 或 特" onkeyup="value=value.replace(/[^A-Z\u4e00-\u9fa5]/g,'')">--%>
            <input class="mark" type="text" placeholder="如: A 或 特">
        <p>展位号区间</p>
        <div class="number_identification">
            <input class="start" type="text" placeholder="最小001" id="number_start">
            <i>-</i>
            <input class="end" type="text" placeholder="最大999"  id="number_end" >
        </div>
        <p class="red"></p>
    </div>
    <div class="hall_footer_one">
        <span class="cancel">取消</span>
        <span class="sure">确定</span>
    </div>
</div>

<!--展位设置-->
<div class="booth_settings lm_hall_detailed">
    <div class="hall_header">
        <p>展位设置</p>
        <span><img src="/static/weixin/images/search-error.png"></span>
    </div>
    <div class="hall_content">
        <p>展位号</p>
        <input type="text" placeholder="请填写要删除的展位号" id="settings_value">
    </div>
    <div class="hall_footer_one">
        <span class="shan">删除该展位号</span>
        <span class="sure">确定</span>
    </div>
</div>

<!--已投保展位不能编辑-->
<div class="insured_booth lm_hall_detailed">
    <div class="hall_content">
        <img src="/static/weixin/images/lm_Promotion-s4.png">
        <p>XXX展厅未添加展位，请添加展位后再提交！</p>
    </div>
    <div class="hall_footer_one hall_footer_two">
        <span class="sure">我知道了</span>
    </div>
</div>

<!--清空展位-->
<div class="empty_booth lm_hall_detailed">
    <div class="hall_content">
        <img src="/static/weixin/images/lm_Promotion-s3.png">
        <p>清空XXXX展厅的所有展位号，清空可再次设置展位。已投保展位不清空，是否确认清空？</p>
    </div>
    <div class="hall_footer_one">
        <span class="cancel">取消</span>
        <span class="sure">确定</span>
    </div>
</div>

<!--保存展位-->
<div class="save_booth lm_hall_detailed">
    <div class="hall_content">
        <img src="/static/weixin/images/lm_Promotion-s4.png">
        <p>XXX展厅未添加展位，请添加展位后再提交！</p>
    </div>
    <div class="hall_footer_one hall_footer_two">
        <span class="sure">我知道了</span>
    </div>
</div>

<!--蒙版-->
<div class="mask_block"></div>
<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>

    $("#goback").click(function () {
        if("${p.mark}"=="upd"){
            window.location.href = "/weixin/activity/activityUpd?id=${p.activityId}";
        }else{
            window.location.href = "/weixin/activity/activityDetatil?id=${p.activityId}";
        }
    });

    $("#number_start").on("keyup",function(){
        limitNum(3,this);
    });
    $("#number_end").on("keyup",function(){
        limitNum(3,this);
    });
    function limitNum(num,obj){
        var  value = $(obj).val();
        value=value.replace(/[^\d]/g,'');
        if(value.length>num){
            value = value.substr(0,value.length-1);
        }
        $(obj).val(value);
    }

    //初始化所有的事件
    function initAllEvent(){
        //点击弹窗上的X或者取消，弹窗与蒙版消失隐藏
        $('.lm_hall_detailed .hall_header span').unbind("click").click(function () {
            $('.mask_block').hide();
            $('.lm_hall_detailed').hide();
            $('.hall-add-kong ul li span').removeClass('active');
        });
        $('.lm_hall_detailed .hall_footer_one .cancel').unbind("click").click(function () {
            $('.mask_block').hide();
            $('.lm_hall_detailed').hide();
        });
        $('.lm_hall_detailed .hall_footer_two .sure').unbind("click").click(function () {
            $('.mask_block').hide();
            $('.lm_hall_detailed').hide();
        });

        //点击新增展厅，新增展厅弹窗出现
        $('.assigned-steps.pro-steps .xia').unbind("click").click(function () {
            $('.mask_block').show();
            $('.new_exhibition_hall').show();
            $('.new_exhibition_hall .hall_footer_one span.sure').unbind("click").click(function () {
                input_val = $.trim($('#new_exhibiton_hall_name').val());
                if (input_val !== '') {
//                    var str = "";
//                    str +=
//                          '<div class="hall-booth">'
//                        + '	<div class="hall-booth-content">'
//                        + '		<h2>'
//                        + '			<p class="tyu">'
//                        + '				<span class="name">'+input_val+'</span><br/>'
//                        + '				<i>投保展位<em>126</em>/210</i>'
//                        + '			</p>'
//                        + '			<span class="zhan">展厅设置</span>'
//                        + '		</h2>'
//                        + '		<div class="hall-add-kong">'
//                        + '			<div class="add-kong">'
//                        + '				<span class="add none_number">+添加展位</span>'
//                        + '			</div>'
//                        + '			<div class="lm_content">'
//                        + '				<ul></ul>'
//                        + '			</div>'
//                        + '			<div class="down-tip">'
//                        + '				<a href="javascript:;" class="down-show">'
//                        + '				</a>'
//                        + '			</div>'
//                        + '		</div>'
//                        + '	</div>'
//                        + '</div>';
//                    $('.lm_booth_content').append(str);
                    layer.open({type: 2});
                    g_ajax('/weixin/exhibition/save-exhibition',{exhibition_hall_name:input_val,activity_id:"${p.activityId}"},function(json){
                        layer.closeAll();
                        if(json.retType=="-1"){
                            layer.open({content:json.msg,btn: '我知道了'});
                        }else{
                            $('.mask_block').hide();
                            $('.lm_hall_detailed').hide();
                            $('.new_exhibition_hall .hall_content input').val('');
                            refresh();
                        };
                    });
                    initAllEvent();
                }else{
                    layer.open({content:"不能输入空格或不填写",btn: '我知道了'});
                }
            });
        });

        //点击展位号，展位设置弹窗出现
        $('.hall-add-kong ul li span').unbind("click").click(function () {
            var that = this;
            if($(this).hasClass('on')){
                $('.insured_booth').show();
                $('.mask_block').show();
                zhan_name = $(this).parents('.hall-add-kong').siblings('h2').find('p.tyu span').text();
                this_name = $(this).text();
                text_describle = zhan_name + '-' + this_name + '展位已投保无法编辑。';
                $('.insured_booth .hall_content p').text(text_describle);
            }else{
                $('.mask_block').show();
                $('.booth_settings').show();
                $('.booth_settings .hall_content input').val($(this).text());
                $('.hall-add-kong ul li span').removeClass('active');
                $(this).addClass('active');

                //点击展位设置弹窗上的删除展位号
                booth_index = $(this).parents('.hall-booth').index();
                li_index = $(this).parent('li').index();
                $('.booth_settings .hall_footer_one span.shan').unbind("click").click(function () {
                    if(li_index !== null){
                        $(that).remove();
                    }
                    $('.mask_block').hide();
                    $('.booth_settings').hide();
                    $('.hall-add-kong ul li span').removeClass('active');
                    li_index = null;
                    var posId = $(that).attr("posId");
                    //删除展位
                    layer.open({type: 2});
                    g_ajax('/weixin/exhibition/del-exhibition-pos',{exhibition_hall_pos_ids:posId},function(json){
                        layer.closeAll();
                        if(json.retType=="-1"){
                            layer.open({content:json.msg,btn: '我知道了'});
                            layer.closeAll();
                            refresh();
                        }else{
                            refresh();
                        };
                    });
                });

                //点击展位设置弹窗上的确定
                $('.booth_settings .hall_footer_one span.sure').unbind("click").click(function () {
                    sd_val = $('.booth_settings .hall_content input').val();
                    console.log('1234',li_index);
                    // if(li_index !== null){
                    //     $(that).text(sd_val);
                    // }
                    $('.mask_block').hide();
                    $('.booth_settings').hide();
                    $('.hall-add-kong ul li span').removeClass('active');
                    li_index = null;
                    //修改展位数据
                    var posId = $(that).attr("posId");
                    layer.open({type: 2});
                    //展厅id
                    var hallId = $(that).parent().parent().parent().parent().parent().find("span.name").attr("hallId")+"";
                    g_ajax('/weixin/exhibition/save-exhibition-pos-single',{exhibition_hall_pos_id:posId,exhibition_pos_name:sd_val,exhibition_hall_id:hallId,activity_id:"${p.activityId}"},function(json){
                        layer.closeAll();
                        if(json.retType=="-1"){
                            layer.open({content:json.msg,btn: '我知道了'});
                            //layer.closeAll();
                            //refresh();
                        }else{
                            refresh();
                        };
                    });
                });
            }
        });

        //点击添加展位，添加展位弹窗出现
        $('.hall-add-kong .add-kong span.add').unbind("click").click(function () {
            var that = this;
            $('.mask_block').show();
            $('.add_booth').show();
            ert_booth_index = $(this).parents('.hall-booth').index();
            $('.add_booth span.sure').unbind("click").click(function () {
                sdf = $.trim($('.add_booth input.mark').val());
                wed_s1 = $.trim($('.add_booth input.start').val());
                wed_s2 = $.trim($('.add_booth input.end').val());
                if(sdf === ''){
                    $('.add_booth p.red').css({"display":'block'}).text('展位号标识不能为空');return;
                }
                // else if(!(/^[\u4e00-\u9fa5A-Z]+$/.test(sdf))){
                //     $('.add_booth p.red').css({"display":'block'}).text('展位号标识需要大写英文字母或中文组合');return;
                // }
                else if(wed_s1 === ''){
                    $('.add_booth p.red').css({"display":'block'}).text('起始展位号不能为空');return;
                }else if(wed_s2 === ''){
                    $('.add_booth p.red').css({"display":'block'}).text('终止展位号不能为空');return;
                }else if(parseInt(wed_s1) > parseInt(wed_s2)){
                    $('.add_booth p.red').css({"display":'block'}).text('起始展位号不得大于终止展位号');return;
                }else{
                    $('.add_booth p.red').css({"display":'none'}).text('');
                    var hallPosNames = "",html="";
                    for(var i=parseInt(wed_s1);i<=parseInt(wed_s2);i++){
                        if(i<10){
                            i = '00'+i;
                        }else if(i>=10 && i < 100){
                            i = '0'+i;
                        }
                        html+= "<li>" +  "<span>" + sdf + i + "</span>" +  "</li>";
                        hallPosNames+=sdf+i+",";
                    }

//                    $('.lm_booth_content .hall-booth').eq(ert_booth_index).find('.lm_content ul').append(html);
//                    testHeight();
//                    if($('.lm_booth_content .hall-booth').eq(ert_booth_index).find('.add-kong .add').hasClass('none_number')){
//                        $('.lm_booth_content .hall-booth').eq(ert_booth_index).find('.add-kong .add').removeClass('none_number');
//                        $('.lm_booth_content .hall-booth').eq(ert_booth_index).find('.add-kong').append('<span class="kong">清空展位</span>');
//                    }
//                    $('.mask_block').hide();
//                    $('.lm_hall_detailed').hide();
//                    $('.add_booth input.mark').val('');
//                    $('.add_booth input.start').val('');
//                    $('.add_booth input.end').val('');
                    initAllEvent()

                    //保存展位数据
                    hallPosNames = hallPosNames.substr(0,hallPosNames.length-1);
                    var hallId = $(that).parent().parent().parent().find("span.name").attr("hallId")+"";
//                    console.log(">>>>>>>>>>>>>>>>>>"+hallId);
                    layer.open({type: 2});
                    g_ajax('/weixin/exhibition/insert-exhibition-pos-batch',{exhibition_hall_id:hallId,exhibition_pos_names:hallPosNames,activity_id:"${p.activityId}"},function(json){
                        layer.closeAll();
                        if(json.retType=="-1"){
                            layer.open({content:json.msg,btn: '我知道了'});
//                            refresh();
                        }else{
                            $('.mask_block').hide();
                            $('.lm_hall_detailed').hide();
                            $('.add_booth input.mark').val('');
                            $('.add_booth input.start').val('');
                            $('.add_booth input.end').val('');
                            refresh();
                        }
                    });

                }
            })
        });

        //点击展厅设置，展厅设置弹窗出现
        $('.lm_booth_content .hall-booth-content h2 span.zhan').unbind("click").click(function () {
            var that = this;
            var old = $(that).prev().find("span.name").html();
            $(".exhibition_hall_setting .exhibition_hall_name").val(old);
            $('.mask_block').show();
            $('.exhibition_hall_setting').show();
            var boothWed_index = $(this).parents('.hall-booth').index();
            $('.exhibition_hall_setting span.sure').unbind("click").click(function () {
                input_val = $.trim($('.exhibition_hall_setting .hall_content input').val());
                if(input_val !== ''){
//                    $(that).prev().find("span.name").html(input_val); //不用更新页面
                    //判断展厅名称的情况
                    if(!/^[\u4e00-\u9fa5\-A-Za-z0-9]{1,50}$/.test(input_val)) {
                        layer.open({content:"展厅名称只能是1-50中英文数字",btn: '我知道了'}); return;
                    }
                    //修改展厅
                    var hallId = $(that).prev().find("span.name").attr("hallId")+"";
//                    console.log(">>>>>>>>>>>>>>>>>>"+hallId);
                    layer.open({type: 2});

                    g_ajax('/weixin/exhibition/save-exhibition',{exhibition_hall_id:hallId,activity_id:"${p.activityId}",exhibition_hall_name:input_val},function(json){
                        layer.closeAll();
                        if(json.retType=="-1"){
                            layer.open({content:json.msg,btn: '我知道了'});
                        }else{
                            refresh();
                        };
                    });

                }
            });
            //删除展厅
            $('.exhibition_hall_setting span.strike_out').unbind("click").click(function () {
                var hallId = $(that).prev().find("span.name").attr("hallId")+"";
                var value = $(that).prev().find("span.name").text();
                layer.open({
                    content: '确定删除'+value+'展厅吗？' ,btn: ['确定', '取消'] ,yes: function(index){
                        layer.open({type: 2});
                        g_ajax('/weixin/exhibition/del-exhibition',{exhibition_hall_id:hallId},function(json){
                            layer.closeAll();
                            if(json.retType=="-1"){
                                layer.open({content:json.msg,btn: '我知道了'});
                            }else{
                                refresh();
                            };
//                            $(that).parent().parent().parent().remove();
                        });
                        layer.close(index);
                    }
                });
            })
        });

        //点击清空展位，清空展位弹窗出现
        $('.lm_booth_content .hall-add-kong .add-kong span.kong').unbind("click").click(function () {
            var that = this;
            $('.mask_block').show();
            $('.empty_booth').show();
            zhan_name = $(this).parents('.hall-add-kong').siblings('h2').find('p.tyu span').text();
            text_desc = "清空"+zhan_name+"的所有展位号，清空可再次设置展位。已投保展位不清空，是否确认清空？";
            $('.empty_booth .hall_content p').text(text_desc);
            //点击清空展会弹窗上的确定，清空这个展厅下的所有展会
            sd_index = $(this).parents('div.hall-booth').index();
            console.log('下标',sd_index);
            $('.empty_booth span.sure').unbind("click").click(function () {
//            $('.lm_booth_content .hall-booth').eq(sd_index).find('li').remove();
                var posIds = "";
                $('.lm_booth_content .hall-booth').eq(sd_index).find('li').each(function () {
                    if(!($(this).children('span').hasClass('on'))) {
                       posIds += $(this).children('span').attr("posId")+",";
//                        $(this).remove();
                    }
                });
//                $('.lm_booth_content .hall-booth').eq(sd_index).find('.add-kong span.add').addClass('none_number');
//                $('.lm_booth_content .hall-booth').eq(sd_index).find('.add-kong span.kong').remove();
//                testHeight();
                posIds = posIds.substr(0,posIds.length-1);
                var hallId = $(that).parent().parent().parent().find("span.name").attr("hallId")+"";
                layer.open({
                    content: '确定清空展位吗？' ,btn: ['确定', '取消'] ,yes: function(index){
                        layer.open({type: 2});
                        g_ajax('/weixin/exhibition/del-exhibition-pos',{exhibition_hall_id:hallId,exhibition_hall_pos_ids:posIds},function(json){
                            layer.closeAll();
                            if(json.retType=="-1"){
                                layer.open({content:json.msg,btn: '我知道了'});
//                                refresh();
                            }else{
                                refresh();
                            }
                            layer.close(index);
                        });

                    }
                });
            });
        });

        //点击保存
        $('.assigned-steps.pro-steps .save').unbind("click").click(function () {
            $('.mask_block').show();
            $('.save_booth').show();
        });


        //点击折叠展开或收起
        $('.down-tip a').unbind("click").click(function () {
            booth_index = $(this).parents('.hall-booth').index();
            sd_dom = $('.lm_booth_content .hall-booth').eq(booth_index);

            ul_height = Math.ceil(sd_dom.find($('.lm_content ul')).height());
            li_height = sd_dom.find($('.lm_content ul li')).height();
            span_height = parseFloat(sd_dom.find($('.lm_content ul li span')).css('marginBottom'));
            partial_height = parseInt(li_height) * 3 + Math.ceil(span_height) * 4;
            if ($(this).hasClass('down-hide')) {
                $(this).removeClass('down-hide');
                sd_dom.find($('.lm_content')).css({'overflow': 'hidden'}).animate({height: partial_height + 'px'});
            } else {
                $(this).addClass('down-hide');
                sd_dom.find($('.lm_content')).animate({height: ul_height + 'px'});
            }
        });
        testHeight();
        function testHeight() {
            $('.lm_booth_content .hall-booth').each(function () {
                ul_height = Math.ceil($(this).find($('.lm_content ul')).height());
                li_height = $(this).find($('.lm_content ul li')).height();
                span_height = parseFloat($(this).find($('.lm_content ul li span')).css('marginBottom'));
                partial_height = parseInt(li_height) * 3 + Math.ceil((span_height) * 3.1);
                if(ul_height > partial_height){
                    $(this).find($('.down-tip')).css({"display":'block'});
                    $(this).find($('.lm_content')).css({"height":partial_height + 'px','overflow':'hidden'});
                }else{
                    $(this).find($('.down-tip')).css({"display":'none'});
                    $(this).find($('.lm_content')).css({"height":ul_height + 'px','overflow':'visible'});
                }
            });
        }
    };


    function refresh(callback){
        //查询数据库
        layer.open({type: 2});
        g_ajax("/weixin/exhibition/get-activity-exhibitions",{activity_id:"${p.activityId}"},function(data){
            renderHallPos(data);
            if(callback) callback();
            initAllEvent();
            layer.closeAll();
            $('.mask_block').hide();
            $('.lm_hall_detailed').hide();
        });
        function renderHallPos(data){
            console.log(data.data);
            var list = data.data;
            var  objByPos={},objByHall={},objByHallName={},objByHallInsCnt={};
            for(var i in list){
                objByPos[list[i].exhibition_hall_pos_id]=list[i]; //得到展位的列表
                objByHall[list[i].exhibition_hall_id]=[]; //得到展厅的列表
                objByHallInsCnt[list[i].exhibition_hall_id]=0; //展厅的投保次数
                objByHallName[list[i].exhibition_hall_id] = list[i].exhibition_hall_name;
            }
            for(var i in list){ //遍历展厅
                var arr = objByHall[list[i].exhibition_hall_id];
                if(list[i].exhibition_hall_pos_id!=undefined){arr.push(list[i])};
                if(list[i].blb_order_id!=undefined&&list[i].blb_order_id!=''){
                    objByHallInsCnt[list[i].exhibition_hall_id] = objByHallInsCnt[list[i].exhibition_hall_id] + 1;
                }
            }
            console.log(objByHall,objByHallName);
            var str = "";
            for(var i in objByHall){
                var isDisplay=true ,none_number="";
                if(objByHall[i].length==0){
                    isDisplay=false, none_number="none_number";
                }
                str +=
                    '<div class="hall-booth">'
                    + '	<div class="hall-booth-content">'
                    + '		<h2>'
                    + '			<p class="tyu">'
                    + '				<span hallId="'+i+'" class="name">'+objByHallName[i]+'</span><br/>'
                    + '				<i>投保展位<em>'+objByHallInsCnt[i]+'</em>/'+objByHall[i].length+'</i>'
                    + '			</p>'
                    + '			<span class="zhan">展厅设置</span>'
                    + '		</h2>'
                    + '		<div class="hall-add-kong">'
                    + '			<div class="add-kong">'
                    + '				<span class="add '+none_number+'">+添加展位</span>';
                    if(isDisplay){str+= '<span class="kong">清空展位</span>';}
                    str+=
                      '			</div>'
                    + '			<div class="lm_content">'
                    + '				<ul>';
                for(var j in objByHall[i]){
                    var ctl =''; //判断保险是否购买
                    if(objByHall[i][j].blb_order_id!=null){
                        ctl = 'class="on"';
                    }
                    str+='<li><span posId="'+objByHall[i][j].exhibition_hall_pos_id+'" '+ctl+'>'+objByHall[i][j].exhibition_pos_name+'</span></li>';
                }
                str +=
                    '		       </ul>'
                    + '			</div>'
                    + '			<div class="down-tip">'
                    + '				<a href="javascript:;" class="down-show">'
                    + '				</a>'
                    + '			</div>'
                    + '		</div>'
                    + '	</div>'
                    + '</div>';
            }
//        console.log(str);
            $(".lm_booth_content").html(str);
        }
    }(refresh())

    //修改展厅名称

    //删除展厅

    //新增展厅

    //修改展位名称

    //清空展位

    //新增展位







</script>
</body>
</html>