// Generated by CoffeeScript 1.8.0
(function() {
	$(function(){
		$("#text").html("订单详情");
		$(".toast").hide();
		  var orderId =GetQueryString("id");
		  $.ajax({
		    	url:baseUrl+"/api/order/find_all_certificate.do",
		    	data:{orderId:orderId},
		    	success:function(data){
		    		if(data.status==200){
		    			var atta=data.datas;
		    			$("#span").html(atta.length);
		    		}else{
		    			wrongMsg(res.message);
		    		}
		    	}
		    	
		    });
		  
	    $.ajax({
	    	url:baseUrl+ '/api/order/get_order.do',
	        data: {
	          orderId: orderId
	        },
	        success: function(data) {
	        	var basic,html="",orderStatus;
	            basic = data.datas[0];
	            orderStatus = data.data.orderStatus;
	            $("#name").html(basic.userName);
	            if(basic.mobile===undefined||basic.mobile===null||basic.mobile==="null"){
	            	basic.mobile="";
	            }
	            $(".phone").html("<a href=\"tel:"+basic.mobile+"\"><font color=\"#333\">" + basic.mobile + "</font></a>");
	            $("#productName").html(basic.shorterName);
	            
	           
	            $("#call").tap(function() {
	              return location.href = "tel:" + basic.mobile;
	            });
	            $("#sms").tap(function() {
	              return location.href = "sms:" + basic.mobile;
	            });
	            $(".tel-cont").tap(function() {
	              return location.href = "tel:4001234123";
	            });
	            
	            if(basic.majorStatus===1070){
	            	$(".proceing").attr("style","background-image: url(../../static/images/product/proceing_01.png)");
	            	$("#1070").html(basic.minorStatusName);
	            }
	            if(basic.majorStatus===1071){
	            	$(".proceing").attr("style","background-image: url(../../static/images/product/proceing_02.png)");
	            	$("#1071").html(basic.minorStatusName);
	            }
	            if(basic.majorStatus===1072){
	            	$(".proceing").attr("style","background-image: url(../../static/images/product/proceing_03.png)");
	            	$("#1072").html(basic.minorStatusName);
	            }
	            if(basic.majorStatus===1073){
	            	$(".proceing").attr("style","background-image: url(../../static/images/product/proceing_04.png)");
	            	$("#1073").html(basic.minorStatusName);
	            }
	            if(basic.majorStatus===1074){
	            	$(".proceing").attr("style","background-image: url(../../static/images/product/proceing_04.png)");
	            	$("#1073").html(basic.majorStatusName);
	            }
	            
	            if(basic.minorStatus===1076||basic.minorStatus===1078||basic.minorStatus===1079||basic.minorStatus===1081||basic.minorStatus===1083){
	            	if(basic.minorStatus===1076){  
	            		$("#btn").html("索取合同");
	            		$("#btn").attr("class","btn bbtn");
	                	$("#btn").on("click", function() {
	                		location.href="../user/email.html?id="+orderId;
	                	});
	                }
	            	if(basic.minorStatus===1078){
		            	$("#btn").html("收到合同");   
		            	$("#btn").attr("class","btn bbtn");
		                $("#btn").on("click", function() {
		                	$.ajax({
		            			url:baseUrl+'/api/order/modify_status.do',
		            			data:{
		            				orderId:orderId,
		            				majorStatus:1072,
		            				minorStatus:1079
		            			},
		            			success:function(data){
		            				if(data.status===200){
		            					toast.success({msg:"请及时提醒客户打款"});
		            					setTimeout(function(){
		            						location.href="./appointmentDetail.html?id="+orderId;
		            					},2000);
		            				}
		            			}
		            		});
		                });
		            }
	            	if(basic.minorStatus===1079){ 
	            		$("#btn").html("客户已打款");
	            		$("#btn").attr("class","btn bbtn");
	                	$("#btn").on("click", function() {
	                		$.ajax({
	                			url:baseUrl+'/api/order/modify_status.do',
	                			data:{
	                				orderId:orderId,
	                				majorStatus:1072,
	                				minorStatus:1080
	                			},
	                			success:function(data){
	                				if(data.status===200){
	                					toast.success({msg:"请上传客户打款凭证"});
		            					setTimeout(function(){
		            						location.href="./certificate.html?id="+orderId;
		            					},2000);
	                				}
	                			}
	                		});

	                	});
	                }
	            	if(basic.minorStatus===1081){  
	            		$("#btn").html("索取佣金");
	            		$("#btn").attr("class","btn bbtn");
	                	$("#btn").on("click", function() {
	                		location.href="../user/bankCard.html?id="+orderId;
	                	});
	                }
	            	if(basic.minorStatus===1083){
		            	$("#btn").html("佣金已收到");   
		            	$("#btn").attr("class","btn bbtn");
		                $("#btn").on("click", function() {
		                	$.ajax({
		            			url:baseUrl+'/api/order/modify_status.do',
		            			data:{
		            				orderId:orderId,
		            				majorStatus:1074,
		            				minorStatus:1074
		            			},
		            			success:function(data){
		            				if(data.status===200){
		            					toast.success({msg:"本次前端认购费返佣已完成"});
		            					setTimeout(function(){
		            						location.href="./appointmentDetail.html?id="+orderId;
		            					},2000);
		            				}
		            			}
		            		});
		                });
		            }
	            }else{
	            	$("#btn").attr("class","");
	            }
	            

	            $.each(orderStatus,function(idx,item){ //循环对象取值
	            	html += "<dd><span class=\"icon-yuan\"></span>"+item.description+"&nbsp&nbsp&nbsp&nbsp&nbsp"+item.postTime+"</dd>";                
	            });
	            $("#list").html(html);

	        }
	    });
	    
	    $("#img").click(function(){
	    	history.back();
	    });
	   
	    $("#investor").attr("onclick",
	    	   	   'location.href="./certificate.html?id='+GetQueryString("id")+'"'
	    	     );
	});
 
}).call(this);
