{% if setting('consult.enabled', 0) and (consultDisplay|default(false) or siteNav|default() == '/' ) %}
{% set consult = setting('consult') %}
  <div id="float-consult" class="float-consult">
    <div class="btn-group-vertical">

      {% set break = 0 %}
      {% for qq in consult.qq if qq.name is not empty and break == 0 %}
        <span class="btn btn-{{consult.color}} float-consult-qq-btn" data-container=".float-consult-qq-btn" data-title="QQ客服" data-content-element="#consult-qq-content"><span class="icon icon-qq"></span></span>
        {% set break = 1 %}
      {% endfor %}

      {% set break = 0 %}
      {% for qqgroup in consult.qqgroup if qqgroup.name is not empty and break == 0 %}
        <span class="btn btn-{{consult.color}} float-consult-qqgroup-btn" data-container=".float-consult-qqgroup-btn" data-title="QQ群" data-content-element="#consult-qqgroup-content"><span class="icon icon-qqgroup"></span></span>
        {% set break = 1 %}
      {% endfor %} 

      {% set break = 0 %}
      {% for phone in consult.phone if phone.name is not empty and break == 0 %} 
        <span class="btn btn-{{consult.color}} float-consult-phone-btn" data-container=".float-consult-phone-btn" data-title="电话客服" data-content-element="#consult-phone-content"><span class="icon icon-phone"></span></span>
        {% set break = 1 %}
      {% endfor %} 

      {% if consult.webchatURI is not empty %}
        <span class="btn btn-{{consult.color}} float-consult-weixin-btn" data-container=".float-consult-weixin-btn" data-title="微信公众号" data-content-element="#consult-weixin-content"><span class="icon icon-weixin"></span></span>
      {% endif %}
      
      {% if consult.email is not empty %}
        <span class="btn btn-{{consult.color}} float-consult-email-btn" data-container=".float-consult-email-btn" data-title="电子邮箱" data-content-element="#consult-email-content"><span class="icon icon-email"></span></span>
      {% endif %}
    </div>

    <div class="consult-contents">
      <div id="consult-qq-content">
        {% for qq in consult.qq if qq.name is not empty %}
          <p>
            <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin={{ qq.number }}&site=qq&menu=yes" >
              <img border="0" src="http://wpa.qq.com/pa?p=2:{{ qq.number }}:52" alt="" title="点击这里给我发消息"/>
              {{ qq.name }}
            </a>
          </p>
        {% endfor %}
      </div>

      <div id="consult-qqgroup-content">
        {% for qqgroup in consult.qqgroup if qqgroup.name is not empty %}
          <p>
            <span class="icon icon-qqgroup text-muted" style="font-size:14px;"></span>
            {{qqgroup.name}} 
            <br> <span class="text-info" style="margin-left:20px;">{{qqgroup.number}}</span>
          </p>
        {% endfor %}
      </div>
      <div id="consult-phone-content">
        <p>
          <strong>服务时间：</strong> {{ consult.worktime }}
        </p>

        {% for phone in consult.phone if phone.name is not empty %}
          <p>
            {{ phone.name }}： {{ phone.number }}
          </p>
        {% endfor %}
      </div>

      
      <div id="consult-weixin-content">
        <img src="{{ asset(consult.webchatURI) }}" class="qrcode center-block">
      </div>

      <div id="consult-email-content">
       <a href="mailto:{{consult.email}}">{{ consult.email }}</a>
      </div>

    </div>
  </div>
{% endif %}

<script>
  var app = {};
  app.debug = {% if app.debug %}true{% else %}false{% endif %};
  app.version = '{{ assets_version() }}';
  app.httpHost = '{{ app.request.getSchemeAndHttpHost() }}';
  app.basePath = '{{ app.request.getBasePath() }}';
  app.theme = '{{ setting("theme.uri"|default("default")) }}';
  app.themeGlobalScript = '{{ theme_global_script() }}';
  app.jsPaths = {{ js_paths()|json_encode|raw }};

  app.crontab = '{{ path('common_crontab') }}';
  {% set crontabNextExecutedTime = setting('crontab_next_executed_time', 0) %}
  {% if crontabNextExecutedTime > 0 %}
    {% if date(crontabNextExecutedTime|date('Y-m-d H:i:s')) < date() %}
      app.scheduleCrontab = '{{ path('common_crontab') }}';
    {% endif %}
  {% endif %}

  var CKEDITOR_BASEPATH = app.basePath + '/assets/libs/ckeditor/4.6.7/';

  app.config = {{
    {
      api:{
        weibo:{key:setting('login_bind.weibo_key', '')},
        qq:{key:setting('login_bind.qq_key', '')},
        douban:{key:setting('login_bind.douban_key', '')},
        renren:{key:setting('login_bind.renren_key', '')}
      },
      cloud: {
        video_player: parameter('cloud.video_player'),
        video_player_watermark_plugin: parameter('cloud.video_player_watermark_plugin'),
        video_player_fingerprint_plugin: parameter('cloud.video_player_fingerprint_plugin')
      },
      loading_img_path: asset('assets/img/default/loading.gif'),
    }|json_encode|raw
  }};

  app.arguments = {};
  {% if script_controller is defined %}
    app.controller = '{{ script_controller }}';
  {% endif %}
  {% if script_arguments is defined %}
    app.arguments = {{ script_arguments|json_encode|raw }};
  {% endif %}
  
  app.scripts = {{ export_scripts()|default(null)|json_encode|raw }};

  app.mainScript = '{{ script_main }}';
</script>
{% if setting('cdn.enabled') %} {% set cdnUrl = setting('cdn.url') %} {% else %} {% set cdnUrl = '' %} {% endif %}
<script src="{{ cdnUrl }}{{ asset('assets/libs/seajs/seajs/2.2.1/sea.js') }}"></script>
<script src="{{ cdnUrl }}{{ asset('assets/libs/seajs/seajs-style/1.0.2/seajs-style.js') }}"></script>
<script src="{{ cdnUrl }}{{ asset('assets/libs/seajs-global-config.js') }}"></script>
<script>
  seajs.use(app.mainScript);
</script>