<!-- header start -->
<include file="Public/Header" />
<!-- header end -->

<!-- header nav start -->
<include file="Public/HeaderNav" />
<!-- header nav end -->

<div class="am-cf user-main" <if condition="!empty($max_width_style)">style="{{$max_width_style}}"</if>>
  <!-- user menu start -->
  <include file="Public/UserMenu" />
  <!-- user menu end -->

  <!-- content start -->
  <div class="user-content">
    <div class="user-content-body p-10">
      <!-- form start -->
      <form class="am-form form-validation view-save" action="{{:U('Home/Student/PolyQuery')}}" method="POST" request-type="ajax-fun" request-value="StudentPolyWin">
        <legend>
          <span class="fs-16">{{:L('student_operation_binding_text')}}</span>
          <a href="{{:U('Home/Student/Index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> {{:L('common_operation_back')}}</a>
        </legend>
        <div class="am-form-group">
          <label>{{:L('student_username_text')}}</label>
          <input type="text" name="username" placeholder="{{:L('student_username_text')}}" minlength="2" maxlength="16" data-validation-message="{{:L('student_username_format')}}" class="am-radius" required />
        </div>
        <div class="am-form-group">
          <label>{{:L('common_view_student_number_text')}}</label>
          <input type="text" name="student_number" placeholder="{{:L('common_view_student_number_text')}}" data-validation-message="{{:L('student_student_number_format')}}" class="am-radius" required />
        </div>
        <div class="am-form-group">
          <label>{{:L('common_view_id_card_text')}}</label>
          <input type="text" name="id_card" placeholder="{{:L('common_view_id_card_text')}}" pattern="{{:L('common_regex_id_card')}}" data-validation-message="{{:L('common_view_id_card_format')}}" class="am-radius" required />
        </div>
        <div class="am-form-group">
          <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'{{:L('common_form_loading_tips')}}'}">{{:L('common_operation_query')}}</button>
        </div>
      </form>
      <!-- form end -->

      <!-- win start -->
      <div class="am-popup am-radius" id="student-poly-win">
        <div class="am-popup-inner">
          <div class="am-popup-hd">
            <h4 class="am-popup-title">{{:L('student_operation_binding_text')}}</h4>
            <span data-am-modal-close class="am-close">&times;</span>
          </div>
          <div class="am-popup-bd">
            <form class="am-form form-validation-win" action="{{:U('Home/Student/Poly')}}" method="POST" request-type="ajax-url" request-value="{{:U('Home/Student/Index')}}">
              <div class="am-form-group">
                <label>{{:L('student_username_text')}}</label>
                <input type="text" name="username" placeholder="{{:L('student_username_text')}}" class="am-radius" disabled required />
              </div>
              <div class="am-form-group">
                <label>{{:L('common_view_student_number_text')}}</label>
                <input type="text" name="student_number" placeholder="{{:L('common_view_student_number_text')}}" class="am-radius" disabled required />
              </div>
              <div class="am-form-group">
                <label>{{:L('common_view_id_card_text')}}</label>
                <input type="text" name="id_card" placeholder="{{:L('common_view_id_card_text')}}" class="am-radius" disabled required />
              </div>
              <div class="am-form-group">
                <label>{{:L('student_accounts_text')}}</label>
                <select name="accounts"></select>
              </div>
              <label>{{:L('common_verify_text')}}</label>
              <div class="am-input-group am-input-group-sm am-form-group">
                <input type="number" name="verify" class="am-radius" placeholder="{{:L('common_verify_text')}}" minlength="6" maxlength="6" data-validation-message="{{:L('common_verify_tips')}}" required />
                <span class="am-input-group-btn">
                  <button class="am-btn am-btn-default am-radius btn-loading-example verify-submit" type="button" data-am-loading="{spinner:'circle-o-notch', loadingText:'{{:L('common_send_tips')}}'}" data-url="{{:U('Home/Student/PolyVerifySend')}}" data-verify="{{:MyC('home_img_verify_state')}}" data-text="{{:L('common_get_verify_text')}}" data-send-text="{{:L('common_send_time_tips')}}" data-time="{{:MyC('common_verify_time_interval', 30, true)}}">{{:L('common_get_verify_text')}}</button>
                </span>
              </div>
              <div class="am-form-group">
                <input type="hidden" name="id" value="" />
                <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'{{:L('common_form_loading_tips')}}'}">{{:L('common_operation_confirm')}}</button>
              </div>
            </form>
          </div>
        </div>
      </div>
      <!-- win end -->

      <!-- verify win start -->
      <div class="am-modal am-modal-no-btn" tabindex="-1" id="verify-win">
        <div class="am-modal-dialog am-radius">
          <div class="am-modal-hd">
            <a href="javascript:;" class="am-close am-close-spin" data-am-modal-close>&times;</a>
          </div>
          <div class="am-modal-bd o-h">
            <div class="o-h m-t-15">
              <input type="text" placeholder="{{:L('common_img_verify_text')}}" maxlength="6" id="verify-img-value" data-validation-message="{{:L('common_img_verify_tips')}}" class="am-form-field am-radius" />
              <div class="fl">
                <img src="{{:U('Home/Student/PolyVerifyEntry')}}" class="am-radius c-p" id="verify-img" onClick='this.src="{{:U('Home/Student/PolyVerifyEntry')}}"' />
                <a href="javascript:;" class="fs-12 c-p" onClick="document.getElementById('verify-img').src='{{:U('Home/Student/PolyVerifyEntry')}}'">{{:L('common_img_verify_submit_text')}}</a>
              </div>
            </div>
            <button type="button" class="am-btn am-btn-secondary am-radius am-btn-sm block m-t-20 btn-loading-example verify-submit-win" data-am-loading="{spinner:'circle-o-notch', loadingText:'{{:L('common_send_tips')}}'}" data-win="1">{{:L('common_operation_confirm')}}</button>
          </div>
        </div>
      </div>
      <!-- verify win end -->
    </div>
  </div>
  <!-- content end -->
</div>

<!-- layuot common module start -->
<include file="Public/CommonModule" />
<!-- layuot common module end -->

<!-- footer start -->
<include file="Public/Footer" />
<!-- footer end -->

<script>
/**
 * [StudentPolyWin 学生关联数据查询回调方法（公共表单方法校验需要放在这里，不能校验其它文件的方法）]
 * @author   Devil
 * @blog     http://gong.gg/
 * @version  0.0.1
 * @datetime 2017-02-11T21:46:50+0800
 * @param    {[object]}    result [回调数据]
 */
function StudentPolyWin(result)
{
  if(result.code == 0)
  {
    var $form = $('.form-validation');
    var $form_win = $('.form-validation-win');
    $form_win.find('input[name="username"]').val($form.find('input[name="username"]').val());
    $form_win.find('input[name="student_number"]').val($form.find('input[name="student_number"]').val());
    $form_win.find('input[name="id_card"]').val($form.find('input[name="id_card"]').val());
    $form_win.find('input[name="id"]').val(result.data.id);
    if(result.data.contact_list.length > 0)
    {
      var html = '';
      for(var i in result.data.contact_list)
      {
        html += '<option value="'+result.data.contact_list[i]+'">'+result.data.contact_list[i]+'</option>';
      }
      $form_win.find('select[name="accounts"]').html(html);
    }
    $('#student-poly-win').modal('open');
  } else {
    Prompt(result.msg);
  }
  $.AMUI.progress.done();
  $('.form-validation').find('button[type="submit"]').button('reset');
}
</script>