var d = dialog({contentType:'load', skin:'bk-popup'}); $(function(){ var pageIndex = 1; var pageSize = 100; var doclist = 0; var request = GetRequest(); var hospitalId =request["hospitalId"]; var deptId = request["deptId"]; bindEvents(); initDoctors(); var isResult = true; var scroller1 = new IScrollPullUpDown('wrapper3',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, scrollbars:true, fadeScrollbars:true, click:true, interactiveScrollbars:false },pullDownAction,pullUpAction); //下拉刷新 function pullDownAction(theScrollerTemp) { if(isResult==false){ dialog({contentType:'tipsbox', skin:'bk-popup' , content:'数据加载中请勿重复刷新!',bottom:true}).show(); return false; } if(isResult==true){ isResult = false; } $(".pullDown").show(); $(".pullUp").hide(); setTimeout(function () { initDoctors(); }, 1000); } //上拉加载数据 function pullUpAction(theScrollerTemp) { // $(".pullDown").hide(); // $(".pullUp").show(); // if(doclist%100==0){ // getDoc(); // }else{ // dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); // } } function bindEvents(){ $(".c-list").on("click","li",function(event){ var doctorId = $(this).attr("data-id"); var target = $(event.target); if(target.closest(".div-timeList").length==0){//跳转到医生简介 location.href = "doctor-detail.html?type=1&doctorId="+doctorId+"&hospitalId="+hospitalId+"&hosDeptId="+deptId; }else{//跳转到门诊预约 var id = target.closest("div").eq(0).attr("data-id"); location.href = "doctor-detail.html?type=2&id="+id+"&doctorId="+doctorId+"&hospitalId="+hospitalId+"&hosDeptId="+deptId; } }) } function initDoctors(){ pageIndex = 1 ; $(".c-list").html(""); getDoc(); } function getDoc(){ d.show(); var data={}; data.city = "350200"; data.filter =""; data.hospitalId = hospitalId; data.hosDeptId = deptId; data.pageIndex = pageIndex; data.pageSize = pageSize; sendPost('wlyy_service/third/smjk/RegDeptSpeDoctorList', data, 'json', 'post', getListFail, successFun); } function successFun(res){ $(".pullDown").hide(); $(".pullUp").hide(); d.close(); if(res.status==200){ var dataList = res.data; if(dataList&&dataList.length>0){ pageIndex = pageIndex+1; appendDoc(dataList); doclist = doclist+dataList.length; }else{ if(doclist==0||doclist.length==0){ $(".div-no-info").show(); } dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); } }else{ getListFail(res); } } function getListFail(res){ d.close(); if (res && res.msg) { if((res.msg).indexOf("SOAP")>=0){ dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show(); return false; } dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show(); } else { dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show(); } } function appendDoc(dataList){ var dochtml =""; if(pageIndex==1){ $(".c-list").html(""); } for(var j in dataList){ var data = dataList[j]; getDocTime(data); } isResult = true; } function getDocTime(data){ var params={}; params.city ="350200"; params.hospitalId = hospitalId; params.hosDeptId = deptId; params.doctorId = data.id; sendPostAsync('third/guahao/GetDoctorArrange', params, 'json', 'post', getListFail, function(res){ if(res.status==200){ var title = ""; var introduce = ""; var img = getImgUrl(data.photo); if(!img){ var img = "noSexDoctor.jpg"; if(data.sex==1){ img = "d-male.png"; }else if(data.sex==2){ img = "d-female.png"; } } if(data.title){ title = '('+data.title+')'; } if(data.introduce){ introduce = '
'+ '擅长:'+ data.introduce+ ''+ '
'; } var dochtml = '
  • '+ '
    '+ '
    '+ '
    '+ '
    '+ ''+ '
    '+ '
    '+ '
    '+ '
    '+ ''+data.name+''+ title+ '
    '+ '
    '+data.hospitalName+'
    '+ '
    '+data.hosDeptName+'
    '+ '
    '+ '
    '+ introduce+ '
    '+ '
    '+ ''+ '医生坐诊时间'+ ''+ '
    '+ '
    '; for(var j in res.data){ if(j%2==0){ dochtml+='
    '; } var timeData = res.data[j]; var dateTime = timeData.date+""; var date= dateTime.split(" ")[0]; var week = getWeek(date); var riqi = date.split("/"); riqi = riqi[1]+"-"+riqi[2]; var used = parseInt(timeData.used); var max = parseInt(timeData.max); var isMo = timeData.time; var status = timeData.status; if(isMo =="a"){ isMo ="上午"; }else{ isMo ="下午"; } var clazz = "div-fr-time-item"; if(j%2==0){ clazz = "div-time-item" } var vip_icon = ""; var timeBg = 'cb-74BF00'; if(res.data[j].regType != undefined){ if(res.data[j].regType.indexOf('vip')>-1 || res.data[j].regType.indexOf('VIP')>-1 || res.data[j].fee == '300'){ vip_icon = ''; clazz = clazz+' vip-bg'; timeBg = 'cb-FF9526'; } } if(status==2||max<=used){ dochtml+='
    '+ ''+riqi+" "+week+isMo+''+ ''+ vip_icon+ '
    '; } else if(status==0){ dochtml+='
    '+ ''+riqi+" "+week+isMo+''+ ''+ vip_icon+ '
    '; } else{ dochtml+='
    '+ ''+riqi+" "+week+isMo+''+ ''+(max-used)+''+ vip_icon+ '
    '; } if(j%2==1||j==(res.data.lenth-1)){ dochtml +='
    '; } } dochtml+='
  • '; $(".c-list").append(dochtml); scroller1.myScroll.refresh(); }else{ getListFail(res); } }); } function getWeek(d){ var dateArray = d.split("/"); var year = dateArray[0], month = dateArray[1], date = dateArray[2]; var dt = new Date(year, month-1, date); var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"]; return weekDay[dt.getDay()] } });