define(['zepto','medtap'],function($,medtap){
	var doctor = {
		wechatId:'',
		init:function(){
			doctor.getDoctorList();
			doctor.bindEve();
		},
		bindEve:function(){
			$('.doctor_item').unbind().bind('click',function(){
				var id = $(this).attr('data-id');
				medtap.pushWindow('https://review-formal.iplusmed.com/wechatForLungCancer/dev/wechat_lung_push_doctor/pages/doctorHomePage.html?doctorId=' + id + '&wechatId=' + medtap.getRequest('wechatId'));
			});
			
			$('.find_doctor').unbind().bind('click',function(){
				medtap.pushWindow('https://review-formal.iplusmed.com/wechatForLungCancer/dev/findDoctor/choseDoctorByThree.html?linkType=wx&wechatId=' + medtap.getRequest('wechatId'));
			});
			
			$('.search_doctor').unbind().bind('click',function(){
				medtap.pushWindow('https://review-formal.iplusmed.com/wechatForLungCancer/dev/findDoctor/choseDoctorByThree.html?linkType=wx&wechatId=' + medtap.getRequest('wechatId'));
			})
		},
		getDoctorList:function(){
			medtap.loading(1);
			medtap.submitAjax({
				url:'https://testdevgw.medtap.cn/user/friend/listMyDoctor',
				type:"post",
				contentType: "application/json",
				async:false,
				data:{
					
				},
				success:function(res){
					medtap.loading(0);
					var data = res.content;
					var html = '';
					var attentionHtml = '';
					
					/* if(data.hasOwnProperty('inviteDoctor') || data.hasOwnProperty('buddyDoctorList') ||data.hasOwnProperty('attentionDoctorList')){
						$('#content').show();
						$('.no_doctor').hide();
					}else{
						$('#content').hide();
						$('.no_doctor').show();
					} */
					
					if(data.hasOwnProperty('inviteDoctor')){
						var str1 = '';
						var str2 = '';
						var str3 = '';
						if(data.inviteDoctor.openPmd == true){
							str1 = '<span class="service_icon pmd">私人医生</span>';
						}else{
							str1 = '<span class="service_icon pmd none">私人医生</span>';
						}
						if(data.inviteDoctor.isOpenImageConsult == true){
							str2 = '<span class="service_icon img_consult">图文咨询</span>';
						}else{
							str2 = '<span class="service_icon img_consult none">图文咨询</span>';
						}
						if(data.inviteDoctor.openConsult == true){
							str3 = '<span class="service_icon consult">电话咨询</span>';
						}else{
							str3 = '<span class="service_icon consult none">电话咨询</span>';
						}
						html += '<div class="doctor_list_consult">'+
									'<img src="../images/my_doctor_default_png@2x.png" class="default_icon">'+
									'<div class="doctor_item clearfix" data-id="'+data.inviteDoctor.doctorId+'"><img src="'+data.inviteDoctor.profile+'"class="doctor_profile">'+
										'<div class="doctor_info">'+
											'<span class="doctor_name">'+data.inviteDoctor.doctorName+'</span>'+
											'<span class="doctor_title">'+(!!data.inviteDoctor.hasOwnProperty('technologyProfessionalName') ? data.inviteDoctor.technologyProfessionalName : '')+'</span>'+
											'<p class="doctor_hospital">'+ (!!data.inviteDoctor.hasOwnProperty('hospitalName') ? data.inviteDoctor.hospitalName : '')+ ' '+(!!data.inviteDoctor.hasOwnProperty('departmentName') ? data.inviteDoctor.departmentName : '') +'</p>'+
										'</div>'+
										'<div class="clearfix" style="margin-top:0.3rem;float:left">'+
											'<span class="doctor_info_tag">擅长</span>'+
											'<span class="doctor_goodAt">'+(data.inviteDoctor.hasOwnProperty('goodAt') ? data.inviteDoctor.goodAt : '')+'</span>'+
										'</div>'+
										'<div class="service_list clearfix">'+
											str1+
											str2+
											str3+
										'</div>'+
									'</div>'+
								'</div>';
					}else{
						html = '';
					}
					if(data.hasOwnProperty('buddyDoctorList')){
						for(var i = 0;i < data.buddyDoctorList.length;i++){
							var str1 = '';
							var str2 = '';
							var str3 = '';
							if(data.buddyDoctorList[i].openPmd == true){
								str1 = '<span class="service_icon pmd">私人医生</span>';
							}else{
								str1 = '<span class="service_icon pmd none">私人医生</span>';
							}
							if(data.buddyDoctorList[i].isOpenImageConsult == true){
								str2 = '<span class="service_icon img_consult">图文咨询</span>';
							}else{
								str2 = '<span class="service_icon img_consult none">图文咨询</span>';
							}
							if(data.buddyDoctorList[i].openConsult == true){
								str3 = '<span class="service_icon consult">电话咨询</span>';
							}else{
								str3 = '<span class="service_icon consult none">电话咨询</span>';
							}
							html += '<div class="doctor_list_consult">'+
										'<div class="doctor_item clearfix" data-id="'+data.buddyDoctorList[i].doctorId+'"><img src="'+data.buddyDoctorList[i].profile+'"class="doctor_profile">'+
											'<div class="doctor_info">'+
												'<span class="doctor_name">'+data.buddyDoctorList[i].doctorName+'</span>'+
												'<span class="doctor_title">'+(!!data.buddyDoctorList[i].hasOwnProperty('technologyProfessionalName') ? data.buddyDoctorList[i].technologyProfessionalName : '')+'</span>'+
												'<span class="attention_status">互相关注</span>'+
												'<p class="doctor_hospital">'+ (!!data.buddyDoctorList[i].hasOwnProperty('hospitalName') ? data.buddyDoctorList[i].hospitalName : '')+ ' '+(!!data.buddyDoctorList[i].hasOwnProperty('departmentName') ? data.buddyDoctorList[i].departmentName : '') +'</p>'+
											'</div>'+
											'<div class="clearfix" style="margin-top:0.3rem;float:left">'+
												'<span class="doctor_info_tag">擅长</span>'+
												'<span class="doctor_goodAt">'+(data.buddyDoctorList[i].hasOwnProperty('goodAt') ? data.buddyDoctorList[i].goodAt : '')+'</span>'+
											'</div>'+
											'<div class="service_list clearfix">'+
												str1+
												str2+
												str3+
											'</div>'+
										'</div>'+
									'</div>';
						}
					}else{
						html = '';
					}
					
					//
					if(html == ''){
						$('.myDoctor').hide();
					}else{
						$('.doctor_list_pmd').html(html);
					}
					
					if(data.hasOwnProperty('attentionDoctorList') && data.attentionDoctorList.length>0){
						for(var i = 0;i<data.attentionDoctorList.length;i++){
							var str1 = '';
							var str2 = '';
							var str3 = '';
							if(data.attentionDoctorList[i].openPmd == true){
								str1 = '<span class="service_icon pmd">私人医生</span>';
							}else{
								str1 = '<span class="service_icon pmd none">私人医生</span>';
							}
							if(data.attentionDoctorList[i].isOpenImageConsult == true){
								str2 = '<span class="service_icon img_consult">图文咨询</span>';
							}else{
								str2 = '<span class="service_icon img_consult none">图文咨询</span>';
							}
							if(data.attentionDoctorList[i].openConsult == true){
								str3 = '<span class="service_icon consult">电话咨询</span>';
							}else{
								str3 = '<span class="service_icon consult none">电话咨询</span>';
							}
							attentionHtml += '<div class="doctor_list_consult">'+
										'<div class="doctor_item clearfix" data-id="'+data.attentionDoctorList[i].doctorId+'"><img src="'+data.attentionDoctorList[i].profile+'"class="doctor_profile">'+
											'<div class="doctor_info">'+
												'<span class="doctor_name">'+data.attentionDoctorList[i].doctorName+'</span>'+
												'<span class="doctor_title">'+(!!data.attentionDoctorList[i].hasOwnProperty('technologyProfessionalName') ? data.attentionDoctorList[i].technologyProfessionalName : '')+'</span>'+
												'<span class="attention_status">已关注</span>'+
												'<p class="doctor_hospital">'+ (!!data.attentionDoctorList[i].hasOwnProperty('hospitalName') ? data.attentionDoctorList[i].hospitalName : '')+ ' '+(!!data.attentionDoctorList[i].hasOwnProperty('departmentName') ? data.attentionDoctorList[i].departmentName : '') +'</p>'+
											'</div>'+
											'<div class="clearfix" style="margin-top:0.3rem;float:left">'+
												'<span class="doctor_info_tag">擅长</span>'+
												'<span class="doctor_goodAt">'+(data.attentionDoctorList[i].hasOwnProperty('goodAt') ? data.attentionDoctorList[i].goodAt : '')+'</span>'+
											'</div>'+
											'<div class="service_list clearfix">'+
												str1+
												str2+
												str3+
											'</div>'+
										'</div>'+
									'</div>';
						}
						$('.my_attention_list').html(attentionHtml);
					}else{
						$('.myAttention').hide();
					}
					
					if(html == '' && attentionHtml == ''){
						$('.no_doctor').show();
						$('#content').hide();
					}else{
						$('#content').show();
						$('.no_doctor').hide();
					}
				}
			})
		}
	}
	doctor.init();
})
