contacts-zk.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. var scrollers = [],
  2. page = 1,
  3. pageSize = 10,
  4. docInfo;
  5. mui.init();
  6. mui.plusReady(function(){
  7. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  8. getTeamMembers();
  9. initScroller();
  10. bindEvents();
  11. templateHelper();
  12. mui('#slider').slider().setStopped(true);
  13. })
  14. function getTeamMembers(){
  15. var url = "/doctor/specialist/findDoctorTeamMenmber",
  16. params = {
  17. doctor: docInfo.code
  18. };
  19. plus.nativeUI.showWaiting();
  20. sendGet(url, params, null, function(res){
  21. if(res.status == 200){
  22. if(res.data.member.length == 0){
  23. $("#teamList").hide();
  24. $("#item1 .no-result-wrapper").show();
  25. }else{
  26. var html = template("team-tmp", res.data);
  27. $("#teamList").empty().append(html);
  28. }
  29. plus.nativeUI.closeWaiting();
  30. }else{
  31. plus.nativeUI.closeWaiting();
  32. mui.toast(res.msg);
  33. }
  34. }, true);
  35. }
  36. function getHospitalDoctorList(isInit){
  37. if(isInit){
  38. page = 1;
  39. }
  40. var url = "/doctor/specialist/getDoctorInHospital",
  41. params = {
  42. doctor: docInfo.code,
  43. page: page,
  44. size: pageSize
  45. };
  46. plus.nativeUI.showWaiting();
  47. sendGet(url, params, null, function(res){
  48. if(res.status == 200){
  49. var list = res.data;
  50. if(list.length == 0){
  51. if(isInit){
  52. $("#hosDocList").hide();
  53. $("#hosDocList").siblings().show();
  54. }else{
  55. scrollers[1].endPullupToRefresh(true);
  56. }
  57. }else{
  58. var html = template("member-tmp", {list: list});
  59. if(isInit){
  60. $("#hosDocList").empty().append(html);
  61. }else{
  62. $("#hosDocList").append(html);
  63. }
  64. if(list.length < pageSize){
  65. scrollers[1].endPullupToRefresh(true);
  66. }else{
  67. page ++;
  68. scrollers[1].endPullupToRefresh(false);
  69. }
  70. }
  71. plus.nativeUI.closeWaiting();
  72. }else{
  73. plus.nativeUI.closeWaiting();
  74. mui.toast(res.msg);
  75. }
  76. }, true);
  77. }
  78. function bindEvents(){
  79. $(".mui-control-item").on('tap', function(){
  80. var $this = $(this),
  81. index = $this.index();
  82. console.log(index);
  83. if(index == 1 && $("#hosDocList li").length == 0){
  84. getHospitalDoctorList(true);
  85. }
  86. });
  87. //查看团队成员信息
  88. $("#slider").on('tap', ".t-doctor", function(){
  89. var oCode = $(this).attr("data-code");
  90. openWebview("doctor-info.html", {docCode: oCode});
  91. });
  92. $(".lin-search").on('tap', function(){
  93. openWebview("search-doctor.html");
  94. })
  95. }
  96. function templateHelper(){
  97. template.helper("getPhoto", function(str){
  98. return getImgUrl(str);
  99. });
  100. template.helper("getLevelName", function(level){
  101. switch(parseInt(level)){
  102. case 1:
  103. return "专科医生";
  104. break;
  105. case 2:
  106. return "全科医生";
  107. break;
  108. case 3:
  109. return "健康管理师";
  110. break;
  111. default:
  112. return "";
  113. break;
  114. }
  115. })
  116. }
  117. function initScroller(){
  118. var deceleration = mui.os.ios?0.003:0.0009;
  119. mui('.mui-scroll-wrapper').scroll({
  120. bounce: false,
  121. indicators: true, //是否显示滚动条
  122. deceleration:deceleration
  123. });
  124. $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl){
  125. //目前只有第3个tab的院内的医生需要分页,其他两个tab的页面不分页
  126. var scroller;
  127. if(index != 1){
  128. scroller = mui(pullRefreshEl).pullRefresh({
  129. down: {
  130. callback: function(){
  131. getTeamMembers();
  132. this.endPulldownToRefresh();
  133. }
  134. },
  135. });
  136. }else{
  137. scroller = mui(pullRefreshEl).pullRefresh({
  138. down: {
  139. callback: function(){
  140. getHospitalDoctorList(true);
  141. this.endPulldownToRefresh();
  142. }
  143. },
  144. up: {
  145. callback: function(){
  146. var self = this;
  147. getHospitalDoctorList(false);
  148. }
  149. }
  150. })
  151. }
  152. scrollers.push(scroller);
  153. })
  154. }