// Generated by CoffeeScript 1.8.0
(function() {
	var _flag=true;
	
  $(function() {
    $(".toast").hide();
    $("#text").html("邮寄地址");
    this.Ajax({
      url:baseUrl+ '/api/user/get_address.do',
      success: function(res) {
        var obj, _i, _len, _ref,tpl,noDataTpl;
        tpl = "";
	    noDataTpl = "<div class=\"noData\">\n	<div class=\"am-page-result\">\n		<div class=\"am-page-result-wrap\">\n			<div class=\"am-page-result-pic\">\n				<img src=\"../../static/images/noData_03.png\" width=\"140\" />\n			</div>\n			<div class=\"am-page-result-title\">暂无数据</div>\n			</div>\n	</div>\n</div> ";
        _ref = res.datas;
        if(_ref!=null && _ref!=undefined){
        	for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                obj = _ref[_i];
                tpl += "<div class=\"am-flexbox am-flexbox2 "+ (obj.isDefault==1? "active" :"")  +"\">\n	<div><i class=\"icon-duigou\" data-id=\"" + obj.addressId + "\"></i></div>\n	<div class=\"am-flexbox-item item\" data-id=\"" + obj.addressId + "\">\n		<div>" + obj.contact + "</div>\n		<div>    "+obj.address+"</div>\n	</div>\n	<div class=\"edit\">\n		<button class=\"am-button am-button-yellow fn-edit\" data-id=\"" + obj.addressId + "\">编辑</button> \n\n	</div>\n</div>";
              }
        }else{
        	if(tpl==""){
            	tpl=noDataTpl;
            }
        	_flag=false;
        } 
        address(_flag);
        return $(".email").append(tpl);
      }
    });
    $(document).on("tap" ,".fn-edit", function() {
      var id;
      id = $(this).data("id");
      localStorage.setItem("orderId", GetQueryString("id"));
      return location.href = "../user/updateEmail.html" + (id ? "?id="+id  : "");
    });
   
    $("#cancle").on("click", function() {
      return $("#mask").hide();
    });
   
   
  });
  
}).call(this);
