var d = dialog({contentType:'load', skin:'bk-popup'}); var scroller1, scroller2, scroller3; $(function(){ //医院列表初始化信息 var pageIndex = 1 ; var pageSize = 100; var hostpitallist = 0; //社区列表初始化信息 var pageIndex1 = 1 ; var pageSize1 = 100; var communitylist = 0; //计划免疫列表初始化信息 var pageIndex2 = 1 ; var pageSize2 = 100; var immunelist = 0; bindEvents(); //初始化医院列表 initHospital(); //初始化社区列表 initCommunity(); //初始化计划免疫列表 initImmune(); //下拉刷新 function pullDownAction(theScrollerTemp) { $(".pullDown").show(); $(".ul-hospital").html(""); initHospital(); setTimeout(function () { $(".pullDown").hide(); }, 1000); } //上拉加载数据 function pullUpAction(theScrollerTemp) { if(hostpitallist%100==0){ $(".pullUp").show(); getHosptitalByType(1); }else{ dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); } setTimeout(function () { $(".pullUp").hide(); }, 1000); } //下拉刷新 function pullDownAction2(theScrollerTemp) { $(".pullDown").show(); $(".ul-community").html(""); initCommunity(); setTimeout(function () { $(".pullDown").hide(); }, 1000); } //上拉加载数据 function pullUpAction2(theScrollerTemp) { if(communitylist%100==0){ $(".pullUp").show(); getHosptitalByType(2); }else{ dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); } setTimeout(function () { $(".pullUp").hide(); }, 1000); } initScroller(); function initScroller(){ if(!scroller1) { scroller1 = new IScrollPullUpDown('wrapper6',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, click:true, scrollbars:true, fadeScrollbars:true, interactiveScrollbars:false },null,null); } if(!scroller2) { scroller2 = new IScrollPullUpDown('wrapper7',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, click:true, scrollbars:true, fadeScrollbars:true, interactiveScrollbars:false },null,null); } if(!scroller3) { scroller3 = new IScrollPullUpDown('wrapper8',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, click:true, scrollbars:true, fadeScrollbars:true, interactiveScrollbars:false },null,null); } } function bindEvents(){ $(".pt-tab").on("click","li",function(){ var activeId = $(this).attr("id"); $(".pt-tab li").removeClass("hit"); $(this).addClass("hit"); $(".area-list-wrap").hide(); var ele = $(".area-list-wrap")[$(this).index()]; var scroller = window["scroller"+($(this).index()+1)] $(ele).show(); setTimeout(function() { scroller && scroller.myScroll.refresh(); }, 500) }) $(".ul-community").on("click","li",function(){ var hospitalId = $(this).attr("data-id"); location.href = "hospital-dept.html?hospitalId="+hospitalId; }) $(".ul-hospital").on("click","li",function(){ var hospitalId = $(this).attr("data-id"); location.href = "hospital-dept.html?hospitalId="+hospitalId; }) $(".ul-immune").on("click", "li", function() { var hospitalId = $(this).attr("data-id"); location.href = "immune-date.html?hospitalId=" + hospitalId; }) $(".div-yuyue-btn").on("click",function(){ //location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wxurl+"%2fwdyy%2fhtml%2fmy-appointment.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"; location.href = "my-appointment.html"; }) } /** * 接口数据获取 */ function getHosptitalByType(type){ d.show(); var data={}; data.city = CITY_CODE; data.filter =""; data.type = type; if(type==1){ data.pageIndex = pageIndex; data.pageSize = pageSize; }else if(type ==2){ data.pageIndex = pageIndex1; data.pageSize = pageSize1; } var successFun = type == 1 ? getHosptitalSuccess : getCommunitySuccess; sendPost('third/guahao/GetOrgList', data, 'json', 'post', getListFail, successFun); } function getHosptitalSuccess(res){ d.close(); if(res.status==200){ var dataList = res.data; if(dataList&&dataList.length>0){ pageIndex = pageIndex+1; appendHopital(dataList); hostpitallist = hostpitallist+dataList.length; scroller1.myScroll.refresh(); }else{ dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); } }else{ getListFail(res); } } function getCommunitySuccess(res){ d.close(); if(res.status==200){ var dataList = res.data; if(dataList&&dataList.length>0){ pageIndex1= pageIndex1+1; appendCommunity(dataList); communitylist = communitylist+dataList.length; scroller2.myScroll.refresh(); }else{ dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show(); } } else { getListFail(res); } $(".main").show(); $("#footer").show(); } function appendHopital(dataList){ var hopitalLi =""; for(var j in dataList){ var data = dataList[j]; var photo = getImgUrl(data.photo); if(!photo){ photo = "../images/hospital_default.png"; } hopitalLi +='
  • '+ ''+ '
    '+ ''+ '
    '+ '
    '+ '
    '+data.address+'
    '+ //等医院地址有值时,则上一句注释,下面两句注释放开 // '
    '+data.name+'
    '+ // '
    '+data.address+'
    '+ '
    '+ '
    '+ ''+ '
  • '; } $(".ul-hospital").append(hopitalLi); setTimeout(function(){ if(!scroller1){ initScroller(); } scroller1.myScroll.refresh(); },500); } function appendCommunity(dataList){ var communitylLi =""; for(var j in dataList){ var data = dataList[j]; var photo = getImgUrl(data.photo); if(!photo){ photo = "../images/hospital_default.png"; } communitylLi +='
  • '+ ''+ '
    '+ ''+ '
    '+ '
    '+ '
    '+data.address+'
    '+ //等医院地址有值时,则上一句注释,下面两句注释放开 // '
    '+data.name+'
    '+ // '
    '+data.address+'
    '+ '
    '+ '
    '+ '
  • '; } $(".ul-community").append(communitylLi); if(!scroller2){ initScroller(); } scroller2.myScroll.refresh(); } /** * 计划免疫列表数据获取 */ function getImmune() { var url = "/patient/guahao/imm/GetOrgImmuneList"; sendPost(url, {},'json','get', getListFail, function(res){ if(res.status == 200){ appendImmune(res.data); }else{ getListFail(res); } }); } function appendImmune(dataList){ var immuneLi =""; for(var j in dataList){ var data = dataList[j]; var photo = getImgUrl(data.photo); if(!photo){ photo = "../images/hospital_default.png"; } immuneLi +='
  • '+ ''+ '
    '+ ''+ '
    '+ '
    '+ // '
    '+data.address+'
    '+ //等医院地址有值时,则上一句注释,下面两句注释放开 '
    '+data.name+'
    '+ '
    '+data.zone_name+data.shortName+'
    '+ '
    '+ '
    '+ '
  • '; } $(".ul-immune").append(immuneLi); $(".main").removeClass("f-dn") setTimeout(function() { if(!scroller3){ initScroller(); } scroller3.myScroll.refresh(); }, 500) } 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 initHospital(){ pageIndex = 1 ; hostpitallist = 0 ; getHosptitalByType(1); } /** * 初始化社区 */ function initCommunity(){ pageIndex1 = 1 ; communitylist = 0; getHosptitalByType(2); } /** * 初始化计划免疫 */ function initImmune() { pageIndex2 = 1; immunelist = 0; getImmune(); } });