You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.2 KiB

<% this.title = '忘记密码' %>
7 years ago
<% this.noPreserveUrl = true; %>
<% include header %>
<div class="ui message" id="msgBox" hidden>
<p id="msgContent"></p>
</div>
<div class="ui middle aligned center aligned grid">
<div class="row">
<div class="column" style="max-width: 450px">
<h2 class="ui image header">
<div class="content">
忘记密码
</div>
</h2>
7 years ago
<form class="ui large form" id="forgetForm">
<div class="ui existing segment">
<div class="field">
<div class="ui left icon input">
<i class="at icon"></i>
7 years ago
<input name="email" placeholder="电子邮件地址" type="text" id="email">
</div>
</div>
7 years ago
<button type="submit" class="ui fluid large submit button" id="sendEmail">找回密码</div>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript">
function showMessage(mclass, content) {
$("#msgBox").addClass(mclass);
$("#msgContent").text(content);
$("#msgBox").show();
}
function submitForm() {
$("#sendEmail").addClass("loading");
$.ajax({
url: "/api/forget",
type: 'POST',
data: {
"email": $("#email").val(),
"_csrf": document.head.getAttribute('data-csrf-token')
},
async: true,
success: function(data) {
error_code = data.error_code;
switch (error_code) {
case 1:
showMessage("positive", "找回密码邮件已经发至你电子邮箱的垃圾邮件文件夹。");
break;
7 years ago
case 1001:
showMessage("error", "用户不存在");
break;
default:
showMessage("error", "未知错误" + error_code);
break;
}
7 years ago
$("#sendEmail").removeClass("loading");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.responseText);
}
});
}
$(document).ready(function() {
7 years ago
$("#forgetForm").submit(function(event) {
submitForm();
7 years ago
event.preventDefault();
});
});
</script>
<% include footer %>