// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
    $(".toast").hide();
    $("#text").html("找回密码");
    $("button.am-button").click(function() {
      if (!isMobile($("#phone")[0], "手机号")) {
          return;
      }
      if (!isNotNull($("#verifyCode")[0], "校验码")) {
        return;
      } else if (!verifyPassword($("#pwd")[0],"密码" )) {
        return;
      }
      return Ajax({
        url: baseUrl + '/api/user/reset_pwd.do',
        data: $("#reset_pwd").serialize(),
        success: function(obj) {
          if (obj.status === 200) {
            return location.href = "./login.html";
          }else{
        	  wrongMsg(obj.message);
          }
        }
      });
    });
    return $("#verCode").on("tap", function() {
      if (!isMobile($("#phone")[0], "手机号")) {
        return;
      }
      return $.ajax({
          url: baseUrl + '/api/user/send_sms.do',
          data: {
            mobile: $("#phone").val(),
            smsType:2
          },
          beforeSend: function() {
              toast.innerHTML = tipTpl.loading;
              return toast.show();
          },
          success: function(data) {
        	  if(data.status==200){
        		  toast.success({msg:"短信已发送，请稍候!"});
        		  setTimeout(function(){
        			  toast.hide();
        		  }, 3000);
        		  return settime($("#verCode"));
        	  }else{
        		  wrongMsg(data.message);
        	  }
          }
      });
    });
  });

}).call(this);
