// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
    $(".toast").hide();
    $("#text").html("用户登录");
    $("#img").click(function(){
    	if(localStorage.getItem("userCenter")!=null){
    		history.go(-2);
    	}else{
    		history.back();
    	}
    });
    return $("button.am-button").click(function() {
      if (!isMobile($("#phone")[0], "手机号")) {
        return;
      } else if (!isNotNull($("#pwd")[0], "密码")) {
        return;
      }
      return Ajax({
        url: baseUrl + '/api/user/login.do',
        data: $("#userLogin").serialize(),
        beforeSend: function() {
            $$.am_toast.innerHTML = tipTpl.loading;
            return toast.show();
          },
          complete:function(){
          	return toast.hide();
          },
        success: function(data) {
          if (data.status === 200) {
            getBackUrl();
            if(localStorage.getItem("appointmentSuc")=="success"){
            	localStorage.clear();
            	return location.href ="./../product/appointmentList.html";
            }
            if(localStorage.getItem("id")!=null){            	
            	return location.href ="./../product/product.html?id="+localStorage.getItem("id");
            }
            if(localStorage.getItem("meetingId")!=null){            	
            	return location.href ="./../meeting/detail.html?meetingId="+localStorage.getItem("meetingId");
            }
            if(localStorage.getItem("newsId")!=null){            	
            	return location.href ="./../news/newsInfo.html?newsId="+localStorage.getItem("newsId");
            }
            if(localStorage.getItem("applypartner")!=null){            	
            	return location.href ="./../user/applypartner.html";
            }
            	return location.href = "./../product/index.html";          
          }else{
        	  wrongMsg(data.message);
          }
        }
      });
    });
  });

}).call(this);
