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 +='