// Generated by CoffeeScript 1.8.0
(function() {
  $(function() {
    $(".toast").hide();
    $("#text").html("上传凭证");
    localStorage.clear();
    
    var orderId=GetQueryString("id");
    $("#img").attr("onclick","location.href='./appointmentDetail.html?id="+orderId+"'");
    $.ajax({
    	url:baseUrl+"/api/order/find_all_certificate.do",
    	data:{orderId:orderId},
    	success:function(data){
    		if(data.status==200){
    			var atta=data.datas;
    			for(i=0;i<atta.length;i++){
    				var ref=atta[i];
    				$("#aflag"+ref.reserveId).attr("href", "./fileView.html?flag=" + ref.reserveId)
    				$("#flag"+ref.reserveId).css("color","#D6AD3D;").html("已上传");
    			}
    			var name=data.data.bankName;
    			if(name!=null&&name!=undefined){
    				$("#field").val(name);
    			}
    		}else{
    			if(data.status==311){
    				wrongMsg(data.message);
    				setTimeout(function(){
    					return location.href="../user/login.html";
    				},1000);
    			}else{
    				wrongMsg(data.message);
    				setTimeout(function(){
    					toast.hide();
    				},1000);
    			}
    		}
    	}
    	
    });
    
     $(".click").on("tap",function(){
    	 localStorage.setItem("orderId", GetQueryString("id"));
     });
     
     $("#confirm").on("click",function(){
    	 if(!isNotNull($("#field")[0],"开户行")){
     		return;
     	 }
    	 var bankName=$("#field").val();
    	 return Ajax({
    		 url:baseUrl+"/api/order/add_investor.do",
    		 data:{
    			 orderId:orderId,
    			 bankName:bankName
    	       },
    		 success:function(data){
    			 if(data.status==200){
    				 toast.success({msg:"上传成功"});
    				 setTimeout(function(){
    					 return location.href="./appointmentDetail.html?id="+orderId;
    				 },1000);
    			 }else{
    				 wrongMsg(res.message);
    			 }
    		 }
    	 });
     });
  });

}).call(this);
