{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block title %}登录 - {{ parent() }}{% endblock %}
{% set script_controller = 'auth/login-bind-choose' %}

{% block content %}
<div class="row row-6">
  <div class="col-md-6 col-md-offset-3">

    <div class="panel panel-default panel-page">
      <div class="panel-heading"><h2>登录</h2></div>

        <div class="well well-sm">

          <div class="media">
            <a class="pull-left" href="javascript:">
              <img class="media-object" src="{{ oauthUser.smallAvatar }}">
            </a>
            <div class="media-body">
              <div><strong>{{ oauthUser.name }}</strong></div>
              <div class="text-muted">您正在使用<strong class="text-primary"> {{ clientMeta.name }} </strong>登录{{ setting('site.name') }}</div>
            </div>
          </div>

        </div>

      {% if setting('login_bind.' ~ type ~ '_set_fill_account') == 1 %}

       <form id="set-bind-exist-form" class="form-vertical" method="post" >
          <div class="form-group">
            <label class="control-label" for="set-bind-nickname-field">昵称</label>
            <div class="controls">
              <input id="set-bind-nickname-field" class="form-control" type="text" name="nickname" value="{{ oauthUser.name }}" data-url="{{ path('register_nickname_check') }}" />
              <p class="help-block">推荐用现在这个，也可以另外取一个。最长14个英文或者7个汉字</p>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="set-bind-email-field">邮箱地址</label>
            <div class="controls">
              <input id="set-bind-email-field" class="form-control" type="text" name="email" data-url="{{path('register_email_check')}}">
               {# <p class="help-block">如空缺，补充一个</p> #}
            </div>
          </div>

          {% endif %}


          {% if setting('auth.user_terms') == 'opened' %}
              <label id="user_terms">
                <input type="checkbox"  checked="checked">我已阅读并同意<a href="{{ path('user_terms') }}" target="_blank">《服务协议》</a>
              </label>
          {% endif %}

        <div class="tac pvl">
          <div class="alert alert-danger" id="bind-new-form-error" style="display:none;"></div>

       {% if setting('login_bind.' ~ type ~ '_set_fill_account') == 1 %}

            <button id="set-bind-new-btn" class="btn btn-primary btn-lg" data-url="{{ path('login_bind_newset', {type:type}) }}" data-loading-text="正在登录..." data-goto="{% if hasPartnerAuth %}{{ path('partner_login') }}{% else %}{{ path('homepage') }}{% endif %}">确认登录</button>
        
        </form>

        {% else %}

            <button id="bind-new-btn" class="btn btn-primary btn-lg" data-url="{{ path('login_bind_new', {type:type}) }}" data-loading-text="正在登录..." data-goto="{% if hasPartnerAuth %}{{ path('partner_login') }}{% else %}{{ path('homepage') }}{% endif %}">直接登录</button>

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

        <p class="text-primary">
          已有帐号？绑定到已有帐号：
          <a href="{{ path('login_bind_exist', {type: type}) }}"></a>
        </p>

        <form id="bind-exist-form" class="form-vertical" method="post" action="{{ path('login_bind_exist', {type:type}) }}" data-goto="{% if hasPartnerAuth %}{{ path('partner_login') }}{% else %}{{ path('homepage') }}{% endif %}">

          <div class="alert alert-danger" id="bind-exist-form-error" style="display:none;"></div>


          <div class="form-group">
            <label class="control-label" for="bind-email-field">Email地址</label>
            <div class="controls">
              <input id="bind-email-field" class="form-control" type="text" name="email">
              <p class="help-block">请填写在{{ setting('site.name') }}注册时填写的Email地址</p>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="bind-password-field">密码</label>
            <div class="controls">
              <input id="bind-password-field" class="form-control" type="password" name="password">
            </div>
          </div>

          <div class="form-group">
            <div class="controls">
              <button class="btn btn-fat btn-default btn-lg" type="submit" data-loading-text="正在提交...">绑定</button>
            </div>
          </div>

          <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
        </form>

        <div class="form-group">

        </div>

    </div>

  </div>
</div>
{% endblock %}