var pageIndex = 1 ; var pageSize = 100; var hospitalId = null; var patient = null; var xtCode = ""; var dept_scroller = null; mui.init(); mui.plusReady(function() { var self = plus.webview.currentWebview(); hospitalId=self.hospitalId; patient =self.patient; xtCode = self.xtCode initScroller(); initHosDept(); bindEvents(); }); function initScroller(){ dept_scroller = $("#wrapper4").initScroll( { pullDownAction: function(){ initHosDept(); },pullUpAction: function() { updatePullUpText(dept_scroller,new Array()); } } ); } var updatePullUpText= function(scroller,list) { var $wrap = $(scroller.wrapper), $pullupLabel = $wrap.find('.pullUpLabel'); $(".pullUp").removeClass("loading"); if(!list || !list.length) { $pullupLabel.text('没有更多'); } else { $pullupLabel.text('上拉加载更多'); } scroller.on('refresh',function() { if(!list || !list.length) { $pullupLabel.text('没有更多'); } else { $pullupLabel.text('上拉加载更多'); } }) } function bindEvents(){ $(".div-dept").on("click",".n-list",function(){ var hid = $(this).attr("h-id"); var deptId = $(this).attr("hdept-id"); var params = {}; params.hospitalId = hospitalId; params.deptId = deptId; params.patient = patient; params.xtCode = xtCode; openWebviewExtras("select-doctor.html",params); }); } function initHosDept(){ pageIndex = 1 ; $(".div-dept").html(""); $('#wrapper4').hide() getHosDeptByHospital(); } function getHosDeptByHospital(){ var data={}; data.city = "350200"; data.filter =""; data.hospitalId = hospitalId; data.pageIndex = pageIndex; data.pageSize = pageSize; sendPost('third/guahao/GetOrgDepList', data, getListFail,successFun); } function successFun(res){ if(res.status==200){ var dataList = res.data; appendHopitalDept(dataList); updatePullUpText(dept_scroller,dataList); }else{ getListFail(res); } } function getListFail(res){ if(res && res.msg) { mui.toast(res.msg); } else { mui.toast("数据加载失败!"); } } function appendHopitalDept(dataList){ var deptHtml =""; for(var j in dataList){ var data = dataList[j]; deptHtml+='
'+ ''+ '
'; } $(".div-dept").append(deptHtml) $('#wrapper4').show() setTimeout(function(){ dept_scroller.refresh(); },200); }