<div class="new_content">
  <div class="email_verify">
    <p class="email_verify_prompt"><span class="icons_email_prompt"></span>您的账号尚未激活，请先进入您的注册邮箱，激活您的账号。</p>
    <button class="email_verify_btn mt30 ml30" onclick = "resendMail('<%= resendmail_path(@user) %>','<%= @user.id %>');">重新发送激活邮件</button>
    <%#= link_to l(:label_mail_resend), { :controller => 'account', :action => 'resendmail',:user => @user}, :class=>"email_verify_btn mt30 ml30", :remote => true, :method => 'get' %>
    <ul class="email_prompt_txt ml30 mt30">
      <p class="email_prompt_p">如果您尚未收到激活邮件，请按照以下步骤操作：</p>
      <li>检查邮箱的“订阅邮件”、“垃圾邮件”，可能会发现激活邮件。 </li>
      <li>如果激活邮件已无效，请点击重新发送激活邮件按钮。</li>
      <li>如果您无法收到激活邮件，请您直接给我们管理员留言：</li>
      <div class="  mt10">
        <textarea style="resize: none;" class="email_prompt_mes" placeholder="请管理员尽快帮我解决邮箱激活问题"></textarea>
        <button class="email_sub_btn fr" onclick="leave_email_activation_message('<%= leave_email_activation_message_path(1)%>','<%= @user.id %>');">确定</button>
        <div class="cl"></div>
      </div>
    </ul>
  </div>
</div>
<script type="text/javascript">
  function resendMail(url,id)
  {
      $.get(
              url,
              {user: id },
              function (data) {
                  //邮箱@之前用a**b格式显示
                  var mail = data.email;
                  var pos = mail.indexOf("@");
                  var restr = mail.substring(1,pos-1);
                  if( mail.split("@")[0].length > 2 ){
                      mail = mail.replace(restr,"***");
                  }

                  $(".email_verify_btn").replaceWith("<p class='email_verify_p mt30 ml30'>激活邮件已发送至您的注册邮箱("+mail+")，请及时登录邮箱进行验证。</p>");
              }
      );
  }
  function leave_email_activation_message(url,user)
  {
      if ($(".email_prompt_mes").val().length == 0){
        //弹框请他输入文字
          var htmlvalue = "</br><div style='width:550px;text-align:center'>您的留言不能为空</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>";
          pop_up_box(htmlvalue,580,30,50);
          return;
      }

      $.ajax({
          url: url,
          data: {user: user, text: $(".email_prompt_mes").val() },
          type: "POST",
          success: function (data) {
              var htmlvalue = "<div class='email_tancon'><h2 class='email_tan_title'>您的留言已发送</h2><p class='email_tan_p'>我们将尽快处理好，并通过邮件通知您。感谢您的反馈！</p></div>"
              pop_up_box(htmlvalue, 580, 30, 45);
              $(".email_prompt_mes").val("");
          }
      });
  }
</script>
