hospital-dept.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. $(function(){
  3. var page = 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-consult-doctor.html?deptId="+deptId;
  43. });
  44. function initHosDept(){
  45. var page = 1 ;
  46. var keshilist = 0;
  47. $(".div-dept").html("");
  48. getHosDeptByHospital();
  49. }
  50. function getHosDeptByHospital(){
  51. d.show();
  52. var data={};
  53. // data.hospitalId = hospitalId;
  54. data.page = page;
  55. data.pagesize = pagesize;
  56. sendPost('patient/consult/dept_list', data, 'json', 'get', getListFail, successFun);
  57. }
  58. function successFun(res){
  59. d.close();
  60. if(res.status==200){
  61. var dataList = res.data;
  62. if(dataList&&dataList.length>0){
  63. page = page+1;
  64. appendHopitalDept(dataList);
  65. keshilist = keshilist+dataList.length;
  66. }else{
  67. if(keshilist==0||keshilist.length==0){
  68. $(".div-no-info").show();
  69. }
  70. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  71. }
  72. }else{
  73. getListFail(res);
  74. }
  75. }
  76. function getListFail(res){
  77. d.close();
  78. if (res && res.msg) {
  79. if((res.msg).indexOf("SOAP")>=0){
  80. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  81. return false;
  82. }
  83. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  84. } else {
  85. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  86. }
  87. }
  88. function appendHopitalDept(dataList){
  89. var deptHtml ="";
  90. for(var j in dataList){
  91. var data = dataList[j];
  92. deptHtml+='<div class="n-list c-border-b" h-id="'+data.hospitalId+'" hdept-id="'+data.id+'">'+
  93. '<div class="n-list-li n-list-link ptb12">'+
  94. '<div class="n-list-info">'+
  95. '<h4 class="c-323232 c-f16">'+data.name+'</h4>'+
  96. '</div>'+
  97. '<span class="list-icon arrow-right"></span>'+
  98. '</div>'+
  99. '</div>';
  100. }
  101. $(".div-dept").append(deptHtml);
  102. scroller1.myScroll.refresh();
  103. }
  104. });