hospital-dept.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. $(function(){
  3. var pageIndex = 1 ;
  4. var pageSize = 100;
  5. var keshilist = 0;
  6. var request = GetRequest();
  7. var hospitalId =request["hospitalId"];
  8. var scroller1 = new IScrollPullUpDown('wrapper4',{
  9. probeType:2,
  10. bounceTime: 250,
  11. bounceEasing: 'quadratic',
  12. mouseWheel:false,
  13. scrollbars:true,
  14. fadeScrollbars:true,
  15. click:true,
  16. interactiveScrollbars:false
  17. },null,null);
  18. initHosDept();
  19. //下拉刷新
  20. function pullDownAction(theScrollerTemp) {
  21. $(".pullDown").show();
  22. initHosDept();
  23. setTimeout(function () {
  24. $(".pullDown").hide();
  25. }, 1000);
  26. }
  27. //上拉加载数据
  28. function pullUpAction(theScrollerTemp) {
  29. if(keshilist%100==0){
  30. $(".pullUp").show();
  31. getHosDeptByHospital();
  32. }else{
  33. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  34. }
  35. setTimeout(function () {
  36. $(".pullUp").hide();
  37. }, 1000);
  38. }
  39. $(".div-dept").on("click",".n-list",function(){
  40. var hid = $(this).attr("h-id");
  41. var deptId = $(this).attr("hdept-id");
  42. location.href = "select-doctor.html?hospitalId="+hid+"&deptId="+deptId;
  43. });
  44. function initHosDept(){
  45. var pageIndex = 1 ;
  46. var keshilist = 0;
  47. $(".div-dept").html("");
  48. getHosDeptByHospital();
  49. }
  50. function getHosDeptByHospital(){
  51. d.show();
  52. var data={};
  53. data.city = "350200";
  54. data.filter ="";
  55. data.hospitalId = hospitalId;
  56. data.pageIndex = pageIndex;
  57. data.pageSize = pageSize;
  58. sendPost('third/guahao/GetOrgDepList', data, 'json', 'post', getListFail, successFun);
  59. }
  60. function successFun(res){
  61. d.close();
  62. if(res.status==200){
  63. var dataList = res.data;
  64. if(dataList&&dataList.length>0){
  65. pageIndex = pageIndex+1;
  66. appendHopitalDept(dataList);
  67. keshilist = keshilist+dataList.length;
  68. }else{
  69. if(keshilist==0||keshilist.length==0){
  70. $(".div-no-info").show();
  71. }
  72. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  73. }
  74. }else{
  75. getListFail(res);
  76. }
  77. }
  78. function getListFail(res){
  79. d.close();
  80. if (res && res.msg) {
  81. if((res.msg).indexOf("SOAP")>=0){
  82. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  83. return false;
  84. }
  85. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  86. } else {
  87. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  88. }
  89. }
  90. function appendHopitalDept(dataList){
  91. var deptHtml ="";
  92. for(var j in dataList){
  93. var data = dataList[j];
  94. deptHtml+='<div class="n-list c-border-b" h-id="'+data.hospitalId+'" hdept-id="'+data.id+'">'+
  95. '<div class="n-list-li n-list-link ptb12">'+
  96. '<div class="n-list-info">'+
  97. '<h4 class="c-323232 c-f16">'+data.name+'</h4>'+
  98. '</div>'+
  99. '<span class="list-icon arrow-right"></span>'+
  100. '</div>'+
  101. '</div>';
  102. }
  103. $(".div-dept").append(deptHtml);
  104. scroller1.myScroll.refresh();
  105. }
  106. });