define(['zepto','medtap'],function($,medtap){
	var myConsult = {
		init:function(){
			myConsult.getMyConsultList();
			myConsult.bindEve();
		},
		getMyConsultList:function(){
			medtap.loading(1);
			medtap.submitAjax({
				url:'https://testdevgw.medtap.cn/trade/imageConsultOrder/listOrder',
				type:'post',
				async: false,
				contentType: 'application/json',
				data:{
					pageNum:1,
					pageSize:20,
					condtion:{
						
					}
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
						var orderList = res.content.list;
						var html = '';
						if(orderList.length == 0){
							$('#content').hide();
							$('.no_order').show();
						}else{
							$('#content').show();
							$('.no_order').hide();
							for(var i = 0;i < orderList.length;i++){
								var status = orderList[i].serviceStatus.key;
								if(status == '10'){
									html += '<div class="consult_item clearfix close" data-id="'+orderList[i].orderSn+'" data-doctorId="'+orderList[i].doctorId+'" data-status="'+orderList[i].serviceStatus.key+'">'+
												'<img src="'+orderList[i].doctorProfile+'" class="doctor_profile">'+
												'<div class="doctor_info clearfix">'+
													'<p class="doctor_info_item01 clearfix">'+
														'<span class="doctor_name">'+orderList[i].doctorName+'</span>'+
														'<span class="doctor_title">'+orderList[i].technologyProfessionalName+'</span>'+
														'<span class="create_time">'+orderList[i].createTime.substring(0,11)+'</span>'+
													'</p>'+
													'<p class="consult_content">'+orderList[i].describe+'</p>'+
												'</div>'+
												'<div class="close_warp">'+
													'<img src="../images/consult_list_finish_png@2x.png" >'+
												'</div>'+
											'</div>';
								}else{
									html += '<div class="consult_item clearfix" data-id="'+orderList[i].orderSn+'" data-doctorId="'+orderList[i].doctorId+'" data-status="'+orderList[i].serviceStatus.key+'">'+
												'<img src="'+orderList[i].doctorProfile+'" class="doctor_profile">'+
												'<div class="doctor_info clearfix">'+
													'<p class="doctor_info_item01 clearfix">'+
														'<span class="doctor_name">'+orderList[i].doctorName+'</span>'+
														'<span class="doctor_title">'+orderList[i].technologyProfessionalName+'</span>'+
														'<span class="create_time">'+orderList[i].createTime.substring(0,11)+'</span>'+
													'</p>'+
													'<p class="consult_content">'+orderList[i].describe+'</p>'+
												'</div>'+
											'</div>';
								}
							}
							$('.consult_list').html(html);
						}
					}
				}
			})
		},
		bindEve:function(){
			$('.consult_item').unbind().bind('click',function(){
				var id = $(this).attr('data-id');
				var doctorId = $(this).attr('data-doctorId');
				var status = $(this).attr('data-status');
				//medtap.pushWindow('../../wechat_lung_imgConsult/pages/imgConsultDetail.html?id=' + id + '&wechatId=' + medtap.getRequest('wechatId'));
				if(status == 2){
					medtap.pushWindow('../../wechat_lung_imgConsult/pages/imgConsultDetail.html?id=' + id + '&wechatId=' + medtap.getRequest('wechatId'));
				}else if(status == 10 || status == 3){
					medtap.pushWindow('../../wechat_lung_chat/pages/imgConsultChat.html?orderSn=' + id + '&doctorId=' + doctorId);
				}
			});
			
			$('.link_icon').unbind().bind('click',function(){
				medtap.pushWindow('https://review-formal.iplusmed.com/wechatForLungCancer/dev/findDoctor/choseDoctorByThree.html?linkType=wx&wechatId=' + medtap.getRequest('wechatId'));
			});
				
			$('.twzx').unbind().bind('click',function(){
				medtap.pushWindow('https://review-formal.iplusmed.com/wechatForLungCancer/dev/findDoctor/choseDoctorByThree.html?linkType=wx&wechatId=' + medtap.getRequest('wechatId'));
			});
			$('.dhzx').unbind().bind('click',function(){
				medtap.pushWindow('https://review-formal.iplusmed.com/wechatForLungCancer/dev/findDoctor/choseDoctorByThree.html?linkType=wx&wechatId=' + medtap.getRequest('wechatId'));
			});
		}
	}
	myConsult.init();
})