// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
    $(".toast").hide();
    $("#text").html("添加邮寄地址");
    return $("button.am-button").click(function() {
        if (!isValidMobile($("#phone")[0], "手机号")) {
        	 toast.hide();
          return;
        }
        if(!isNotNull($("#address")[0],"地址")){
        	 toast.hide();
        	return;
        }
        return Ajax({
          url: baseUrl + '/api/user/add_address.do',
          data: $("#emailAdd").serialize(),
          success: function(data) {
            if (data.status === 200) {
              getBackUrl();
              toast.success({msg:"添加成功"});
              setTimeout(function(){
            	  var id=localStorage.getItem("orderId");
            	  if(id!=null){
                  	localStorage.clear();
                  	return location.href ="./email.html?id="+id;
                  }else{
                	return location.href ="./email.html";
                  }
              },1000);
            }else{
          	  wrongMsg(data.message);
          	 toast.hide();
            }
          }
        });
       
      });
    
  });
 
}).call(this);
