// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
    $(".toast").hide();
    $("#text").html("修改个人信息");
    $.ajax({
    	url:baseUrl+"/api/user/get_user_info.do",
       
        success:function(data){
        	if(data.status==200){
        		var user=data.data.userinfo;
        		$("#uname").val(user.name);
        		
        		if(user.email && typeof(user.email)!="undefined" && user.email!=0){
        			$("#email").val(user.email);
        		}
        	}else{
        		wrongMsg(data.message);
        		setTimeout(function(){
        			return location.href="./login.html";
        		},1000);
        		
        	}
        }
    });
    $("button.am-button").click(function(){
    	if(!isNotNull($("#uname")[0], "姓名")){
    		return;
    	}
    	if(!isEmail($("#email")[0],"邮箱")){
    		return;
    	}
      return Ajax({
        url: baseUrl + '/api/user/update_user_info.do',
        data: $("#userinfo").serialize(),
        success: function(obj) {
          if (obj.status === 200) {
        	  return history.back();
          }else{
        	  wrongMsg(obj.message);
          }
        }
      });
    });
    });
  
}).call(this);
