// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
    $(".toast").hide();
    $("#text").html("个人信息");
    localStorage.clear();
    
    $("#img").attr("onclick","location.href='./userCenter.html'");
    $.ajax({
    	url:baseUrl+"/api/user/get_user_info.do",
       
        success:function(data){
        	if(data.status==200){
        		var user=data.data.userinfo;
        		$("#uname").html(user.name);
        		$("#mobile").html(user.mobile);
        		if (user.email != null) {
        			$("#email").html(user.email);
        		}
        		if(user.isVerify==1){
        			$("#verify").html("已认证");
        		}else{
        			$("#verify").html("认证即享理财师特权");
        		}
        		if(user.email && typeof(user.email)!="undefined" && user.email!=0){
        			$("#email").val(user.email);
        		}
        		if(user.cardUri!=null){
        			$("#author").attr("href","./author.html?src=/"+user.cardUri);
        		}
        		 $("#author").on("tap",function(){
        			  localStorage.setItem("verify", user.isVerify); 
        		  });
        	}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 location.href="./userInfo.html";
          }else{
        	  wrongMsg(obj.message);
          }
        }
      });
    });
    
  });
  
}).call(this);
