select-doctor.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. $(function(){
  3. var pageIndex = 1;
  4. var pageSize = 100;
  5. var doclist = 0;
  6. var request = GetRequest();
  7. var hospitalId =request["hospitalId"];
  8. var deptId = request["deptId"];
  9. bindEvents();
  10. initDoctors();
  11. var isResult = true;
  12. var scroller1 = new IScrollPullUpDown('wrapper3',{
  13. probeType:2,
  14. bounceTime: 250,
  15. bounceEasing: 'quadratic',
  16. mouseWheel:false,
  17. scrollbars:true,
  18. fadeScrollbars:true,
  19. click:true,
  20. interactiveScrollbars:false
  21. },pullDownAction,pullUpAction);
  22. //下拉刷新
  23. function pullDownAction(theScrollerTemp) {
  24. if(isResult==false){
  25. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'数据加载中请勿重复刷新!',bottom:true}).show();
  26. return false;
  27. }
  28. if(isResult==true){
  29. isResult = false;
  30. }
  31. $(".pullDown").show();
  32. $(".pullUp").hide();
  33. setTimeout(function () {
  34. initDoctors();
  35. }, 1000);
  36. }
  37. //上拉加载数据
  38. function pullUpAction(theScrollerTemp) {
  39. // $(".pullDown").hide();
  40. // $(".pullUp").show();
  41. // if(doclist%100==0){
  42. // getDoc();
  43. // }else{
  44. // dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  45. // }
  46. }
  47. function bindEvents(){
  48. $(".c-list").on("click","li",function(event){
  49. var doctorId = $(this).attr("data-id");
  50. var target = $(event.target);
  51. if(target.closest(".div-timeList").length==0){//跳转到医生简介
  52. location.href = "doctor-detail.html?type=1&doctorId="+doctorId+"&hospitalId="+hospitalId+"&hosDeptId="+deptId;
  53. }else{//跳转到门诊预约
  54. var id = target.closest("div").eq(0).attr("data-id");
  55. location.href = "doctor-detail.html?type=2&id="+id+"&doctorId="+doctorId+"&hospitalId="+hospitalId+"&hosDeptId="+deptId;
  56. }
  57. })
  58. }
  59. function initDoctors(){
  60. pageIndex = 1 ;
  61. $(".c-list").html("");
  62. getDoc();
  63. }
  64. function getDoc(){
  65. d.show();
  66. var data={};
  67. data.city = "350200";
  68. data.filter ="";
  69. data.hospitalId = hospitalId;
  70. data.hosDeptId = deptId;
  71. data.pageIndex = pageIndex;
  72. data.pageSize = pageSize;
  73. sendPost('wlyy_service/third/smjk/RegDeptSpeDoctorList', data, 'json', 'post', getListFail, successFun);
  74. }
  75. function successFun(res){
  76. $(".pullDown").hide();
  77. $(".pullUp").hide();
  78. d.close();
  79. if(res.status==200){
  80. var dataList = res.data;
  81. if(dataList&&dataList.length>0){
  82. pageIndex = pageIndex+1;
  83. appendDoc(dataList);
  84. doclist = doclist+dataList.length;
  85. }else{
  86. if(doclist==0||doclist.length==0){
  87. $(".div-no-info").show();
  88. }
  89. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  90. }
  91. }else{
  92. getListFail(res);
  93. }
  94. }
  95. function getListFail(res){
  96. d.close();
  97. if (res && res.msg) {
  98. if((res.msg).indexOf("SOAP")>=0){
  99. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  100. return false;
  101. }
  102. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  103. } else {
  104. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  105. }
  106. }
  107. function appendDoc(dataList){
  108. var dochtml ="";
  109. if(pageIndex==1){
  110. $(".c-list").html("");
  111. }
  112. for(var j in dataList){
  113. var data = dataList[j];
  114. getDocTime(data);
  115. }
  116. isResult = true;
  117. }
  118. function getDocTime(data){
  119. var params={};
  120. params.city ="350200";
  121. params.hospitalId = hospitalId;
  122. params.hosDeptId = deptId;
  123. params.doctorId = data.id;
  124. sendPostAsync('third/guahao/GetDoctorArrange', params, 'json', 'post', getListFail, function(res){
  125. if(res.status==200){
  126. var title = "";
  127. var introduce = "";
  128. var img = getImgUrl(data.photo);
  129. if(!img){
  130. var img = "noSexDoctor.jpg";
  131. if(data.sex==1){
  132. img = "d-male.png";
  133. }else if(data.sex==2){
  134. img = "d-female.png";
  135. }
  136. }
  137. if(data.title){
  138. title = '<span class="c-f16 c-666666 pl10">('+data.title+')</span>';
  139. }
  140. if(data.introduce){
  141. introduce = '<div class="mt5 c-f12 c-666666 mb5 pl10">'+
  142. '<span class="span-content">擅长:'+
  143. data.introduce+
  144. '</span>'+
  145. '</div>';
  146. }
  147. var dochtml = '<li class="mt10" data-id="'+data.id+'">'+
  148. '<div class="n-list dr-item c-border">'+
  149. '<div class="n-list-li pl10">'+
  150. '<div class="n-list-key">'+
  151. '<div class="n-avatar-l img-round">'+
  152. '<img src="../../../images/'+img+'">'+
  153. '</div>'+
  154. '</div>'+
  155. '<div class="pl15 c-100">'+
  156. '<div>'+
  157. '<span class="c-f16 c-bold c-323232">'+data.name+'</span>'+
  158. title+
  159. '</div>'+
  160. '<div class="c-f12 c-323232 div-hospital">'+data.hospitalName+'</div>'+
  161. '<div class="c-f12 c-323232">'+data.hosDeptName+'</div>'+
  162. '</div>'+
  163. '</div>'+
  164. introduce+
  165. '<div class="line"></div>'+
  166. '<div class="mt10 c-f14 c-666666 mb10 pl10">'+
  167. '<span class="">'+
  168. '医生坐诊时间'+
  169. '</span>'+
  170. '</div>'+
  171. '<div class="div-timeList">';
  172. for(var j in res.data){
  173. if(j%2==0){
  174. dochtml+='<div class="height-40">';
  175. }
  176. var timeData = res.data[j];
  177. var dateTime = timeData.date+"";
  178. var date= dateTime.split(" ")[0];
  179. var week = getWeek(date);
  180. var riqi = date.split("/");
  181. riqi = riqi[1]+"-"+riqi[2];
  182. var used = parseInt(timeData.used);
  183. var max = parseInt(timeData.max);
  184. var isMo = timeData.time;
  185. var status = timeData.status;
  186. if(isMo =="a"){
  187. isMo ="上午";
  188. }else{
  189. isMo ="下午";
  190. }
  191. var clazz = "div-fr-time-item";
  192. if(j%2==0){
  193. clazz = "div-time-item"
  194. }
  195. var vip_icon = "";
  196. var timeBg = 'cb-74BF00';
  197. if(res.data[j].regType != undefined){
  198. if(res.data[j].regType.indexOf('vip')>-1 || res.data[j].regType.indexOf('VIP')>-1 || res.data[j].fee == '300'){
  199. vip_icon = '<i class="vip-icon"></i>';
  200. clazz = clazz+' vip-bg';
  201. timeBg = 'cb-FF9526';
  202. }
  203. }
  204. if(status==2||max<=used){
  205. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  206. '<span class="div-item-time">'+riqi+" "+week+isMo+'</span>'+
  207. '<span class="div-item-man c-fff cb-A8A8A8">满</span>'+
  208. vip_icon+
  209. '</div>';
  210. }
  211. else if(status==0){
  212. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  213. '<span class="div-item-time">'+riqi+" "+week+isMo+'</span>'+
  214. '<span class="div-item-man c-fff cb-A8A8A8">停</span>'+
  215. vip_icon+
  216. '</div>';
  217. }
  218. else{
  219. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  220. '<span class="div-item-no-man">'+riqi+" "+week+isMo+'</span>'+
  221. '<span class="div-item-man c-fff ' + timeBg + '">'+(max-used)+'</span>'+
  222. vip_icon+
  223. '</div>';
  224. }
  225. if(j%2==1||j==(res.data.lenth-1)){
  226. dochtml +='</div>';
  227. }
  228. }
  229. dochtml+='</div></div></li>';
  230. $(".c-list").append(dochtml);
  231. scroller1.myScroll.refresh();
  232. }else{
  233. getListFail(res);
  234. }
  235. });
  236. }
  237. function getWeek(d){
  238. var dateArray = d.split("/");
  239. var year = dateArray[0], month = dateArray[1], date = dateArray[2];
  240. var dt = new Date(year, month-1, date);
  241. var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
  242. return weekDay[dt.getDay()]
  243. }
  244. });