// Generated by CoffeeScript 1.8.0
(function() {
  var loadData;
  
  loadData = function() {
	  var item, noDataTpl, swp, top;
	    top = "<div class=\"top\">\n	<div class=\"am-flexbox\">\n		<div class=\"head\">\n			<div class=\"circle\" style=\"background-image: url({imgSrc});\" onclick=\"location.href='../product/photo.html'\"></div>  \n		</div>\n		<div class=\"am-flexbox-item top-right\" onclick=\"location.href='../user/userInfo.html'\">\n		    <div class=\"am-flexbox\">\n				<div class=\"name\"></div>\n				<div style='width:55px;height:27px;'><img id='roleImg' src=\"\" style=\"width:100%;\" /></div>\n			</div> \n			<div class=\"am-flexbox\">\n				<div class=\"am-flexbox-item am-ft-ellipsis\" id=\"author\"></div>\n				<div><i class=\"icon-jiantou-left\"></i></div>\n			</div>\n			\n		</div>\n	</div> \n</div>\n<div class=\"red_bd\"></div>\n<div class=\"am-flexbox btn\">\n	<div class=\"am-flexbox-item am-ft-ellipsis address\"><i class=\"icon-fangzi\"></i>合同邮寄地址</div>\n	<div class=\"am-flexbox-item bank\"><i class=\"icon-yinxingqia\"></i>我的银行卡</div>\n</div>";
	    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/product/noData_03.png\" width=\"140\" />\n			</div>\n			<div class=\"am-page-result-title\">暂无数据</div>\n			<div class=\"am-page-result-button\"><button class=\"am-button am-button-red\" onclick=\"location.href='./index.html'\">现在就去预约</button></div>\n		</div>\n	</div>\n</div> ";
	    item = $("#itemTpl")[0].innerHTML;
    swp = new $.compent.swiper("#productList", {
    	tpl: item,
        topHtml: top,
        refreshEnabled: false,
        noDataTpl: noDataTpl
    });
    swp.dataSource = (function(_this) {
      return function(pageIndex, s, opt) {
        return _this.Ajax({
          url: _this.baseUrl + '/api/order/get_orders.do',
          data: {
            page: pageIndex
          },
          type: 'get',
          callback: function(obj) {
        	  $.each(obj.datas,function(idx,item){
        		  item.postTime = item.postTime.substr(0,10);
        		  if(item.minorStatusName===null||item.minorStatusName==="N/A"||item.minorStatusName===undefined){
        			  item.minorStatusName="已完成";
        		  }
        	  });
        	  
        	  $.ajax({
        	    	url:baseUrl+'/api/user/get_user_info.do',
        	    	beforeSend: function() {
        	            $$.am_toast.innerHTML = tipTpl.loading;
        	            return toast.show();
        	          },
        	          complete:function(){
      	            	return toast.hide();
      	            },
        	    	success:function(data){
        	    		var user = data.data.userinfo;
        	    		if(user.portraitUri == null){
        	    			img="../../static/images/head.jpg";
        	    		}else{
        	    			img="/"+user.portraitUri;
        	    		}
        	    		if(user.isVerify===1){
        	    			roleImg="../../static/images/yi.png";
        	    			$("#author").html(user.companyName);
        	    		}else{
        	    			roleImg="../../static/images/wei.png";
        	    			$("#author").html("&nbsp;&nbsp;认证即享理财师特权");
        	    		}
        	    		name=user.name;
        	    		$(".name").html(name);
        	    		$(".circle").attr("style","background-image: url(" +
        	    				img +
        	    				")");
        	    		$("#roleImg").attr("src",roleImg);
        	    	}
        	    	
        	    });
        	
            return swp.dataList(obj.datas);
          },
          error: function(res) {
            opt.timeStatu = res.status;
            return swp.timeOut();
          }
        });
      };
    })(this);
    return swp.initData();
  };

  $(function() {
	  $("#text").html("个人中心");
    loadData();
    $(document).on("click", ".datum", function() {
      return location.href = "../user/userInfo.html";
    }).on("click", ".address", function() {
      return location.href = "../user/email.html";
    }).on("click", ".bank", function() {
      return location.href = "../user/bankCard.html";
    }).on("click", ".author", function() {
      return location.href = "../user/author.html";
    });
    return $(document).on("click", ".item", function() {
      return location.href = "./appointmentDetail.html?id=" + $(this).data("id");
    });
  });

}).call(this);
