hospital-dept.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. var pageIndex = 1 ;
  2. var pageSize = 100;
  3. var hospitalId = null;
  4. var patient = null;
  5. var xtCode = "";
  6. var dept_scroller = null;
  7. mui.init();
  8. mui.plusReady(function() {
  9. var self = plus.webview.currentWebview();
  10. hospitalId=self.hospitalId;
  11. patient =self.patient;
  12. xtCode = self.xtCode
  13. initScroller();
  14. initHosDept();
  15. bindEvents();
  16. });
  17. function initScroller(){
  18. dept_scroller = $("#wrapper4").initScroll(
  19. {
  20. pullDownAction: function(){
  21. initHosDept();
  22. },pullUpAction: function() {
  23. updatePullUpText(dept_scroller,new Array());
  24. }
  25. }
  26. );
  27. }
  28. var updatePullUpText= function(scroller,list) {
  29. var $wrap = $(scroller.wrapper),
  30. $pullupLabel = $wrap.find('.pullUpLabel');
  31. $(".pullUp").removeClass("loading");
  32. if(!list || !list.length) {
  33. $pullupLabel.text('没有更多');
  34. } else {
  35. $pullupLabel.text('上拉加载更多');
  36. }
  37. scroller.on('refresh',function() {
  38. if(!list || !list.length) {
  39. $pullupLabel.text('没有更多');
  40. } else {
  41. $pullupLabel.text('上拉加载更多');
  42. }
  43. })
  44. }
  45. function bindEvents(){
  46. $(".div-dept").on("click",".n-list",function(){
  47. var hid = $(this).attr("h-id");
  48. var deptId = $(this).attr("hdept-id");
  49. var params = {};
  50. params.hospitalId = hospitalId;
  51. params.deptId = deptId;
  52. params.patient = patient;
  53. params.xtCode = xtCode;
  54. openWebviewExtras("select-doctor.html",params);
  55. });
  56. }
  57. function initHosDept(){
  58. pageIndex = 1 ;
  59. $(".div-dept").html("");
  60. $('#wrapper4').hide()
  61. getHosDeptByHospital();
  62. }
  63. function getHosDeptByHospital(){
  64. var data={};
  65. data.city = "350200";
  66. data.filter ="";
  67. data.hospitalId = hospitalId;
  68. data.pageIndex = pageIndex;
  69. data.pageSize = pageSize;
  70. sendPost('third/guahao/GetOrgDepList', data, getListFail,successFun);
  71. }
  72. function successFun(res){
  73. if(res.status==200){
  74. var dataList = res.data;
  75. appendHopitalDept(dataList);
  76. updatePullUpText(dept_scroller,dataList);
  77. }else{
  78. getListFail(res);
  79. }
  80. }
  81. function getListFail(res){
  82. if(res && res.msg) {
  83. mui.toast(res.msg);
  84. } else {
  85. mui.toast("数据加载失败!");
  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" style="margin-top:7px;"></span>'+
  98. '</div>'+
  99. '</div>';
  100. }
  101. $(".div-dept").append(deptHtml)
  102. $('#wrapper4').show()
  103. setTimeout(function(){
  104. dept_scroller.refresh();
  105. },200);
  106. }