select-doctor.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. var pageIndex = 1;
  2. var pageSize = 100;
  3. var patient = null;
  4. var hospitalId = null;
  5. var deptId= null;
  6. var scroller1 = null;
  7. var xtCode = "";
  8. mui.init();
  9. mui.plusReady(function(){
  10. var self = plus.webview.currentWebview();
  11. patient = self.patient;
  12. hospitalId = self.hospitalId;
  13. deptId = self.deptId;
  14. xtCode = self.xtCode
  15. bindEvents();
  16. initDoctors();
  17. initScroller();
  18. //协同
  19. if(xtCode){
  20. $('#no_appoint').show()
  21. $('#no_appoint').on('click',function(){
  22. mui.openWindow({
  23. id: "xietongfuwu-deal",
  24. url: "../../xtfw/html/xietongfuwu-deal.html",
  25. extras: {
  26. type:1,
  27. code:xtCode
  28. }
  29. })
  30. })
  31. }
  32. });
  33. function initScroller(){
  34. scroller1 = $("#wrapper3").initScroll(
  35. {
  36. pullDownAction: function(){
  37. initDoctors();
  38. },pullUpAction: function() {
  39. updatePullUpText(scroller1,new Array());
  40. }
  41. }
  42. );
  43. }
  44. var updatePullUpText= function(scroller,list) {
  45. var $wrap = $(scroller.wrapper),
  46. $pullupLabel = $wrap.find('.pullUpLabel');
  47. $(".pullUp").removeClass("loading");
  48. if(!list || !list.length) {
  49. $pullupLabel.text('没有更多');
  50. } else {
  51. $pullupLabel.text('上拉加载更多');
  52. }
  53. scroller.on('refresh',function() {
  54. if(!list || !list.length) {
  55. $pullupLabel.text('没有更多');
  56. } else {
  57. $pullupLabel.text('上拉加载更多');
  58. }
  59. })
  60. }
  61. function bindEvents(){
  62. $(".c-list").on("click","li",function(event){
  63. var doctorId = $(this).attr("data-id");
  64. var target = $(event.target);
  65. var params = {};
  66. params.patient = patient;
  67. params.xtCode = xtCode;
  68. if(target.closest(".div-timeList").length==0){
  69. params.type=1;
  70. params.doctorId = doctorId;
  71. params.hospitalId = hospitalId;
  72. params.deptId = deptId;
  73. //跳转到医生简介
  74. openWebviewExtras("doctor-detail.html",params);
  75. }else{//跳转到门诊预约
  76. var id = target.closest("div").eq(0).attr("data-id");
  77. params.type=2;
  78. params.doctorId = doctorId;
  79. params.hospitalId = hospitalId;
  80. params.deptId = deptId;
  81. params.dataid = id;
  82. openWebviewExtras("doctor-detail.html",params);
  83. }
  84. })
  85. }
  86. function initDoctors(){
  87. pageIndex = 1 ;
  88. $(".c-list").html("");
  89. $("#wrapper3").hide()
  90. getDoc();
  91. }
  92. function getDoc(){
  93. var data={};
  94. data.city = CITY_CODE;
  95. data.filter ="";
  96. data.hospitalId = hospitalId;
  97. data.hosDeptId = deptId;
  98. data.pageIndex = pageIndex;
  99. data.pageSize = pageSize;
  100. plus.nativeUI.showWaiting();
  101. sendPost('third/guahao/GetDoctorList', data,getListFail, successFun);
  102. }
  103. function successFun(res){
  104. if(res.status==200){
  105. if(res.data.length > 0){
  106. appendDoc(res.data);
  107. }else{
  108. $("#wrapper3").show();
  109. $(".pullUp").hide();
  110. $("#no_result_wrap").removeClass("c-hide");
  111. plus.nativeUI.closeWaiting();
  112. }
  113. }else{
  114. getListFail(res);
  115. }
  116. }
  117. function getListFail(res){
  118. plus.nativeUI.closeWaiting();
  119. if (res && res.msg) {
  120. mui.toast(res.msg);
  121. } else {
  122. mui.toast("医生列表获取失败!");
  123. }
  124. }
  125. function appendDoc(dataList){
  126. var dochtml ="";
  127. if(pageIndex==1){
  128. $(".c-list").html("");
  129. }
  130. updatePullUpText(scroller1,dataList);
  131. for(var j in dataList){
  132. var data = dataList[j];
  133. getDocTime(data);
  134. }
  135. }
  136. function getDocTime(data){
  137. var params={};
  138. params.OrgCode = hospitalId;
  139. params.DeptCode = deptId;
  140. params.DocCode = data.id;
  141. sendPost('wlyy_service/third/smjk/RegDeptSpeDoctorSectionList', params, getListFail, function(res){
  142. if(res.status==200){
  143. plus.nativeUI.closeWaiting();
  144. if(!res.data||res.data.length==0){
  145. return;
  146. }
  147. var title = "";
  148. var introduce = "";
  149. var img = getImgUrl(data.photo) || "d-male.png";
  150. if(data.title){
  151. title = '<span class="c-f16 c-666666 pl10">('+data.title+')</span>';
  152. }
  153. if(data.introduce){
  154. introduce = '<div class="mt5 c-f12 c-666666 mb5 pl10">'+
  155. '<span class="span-content">擅长:'+
  156. data.introduce+
  157. '</span>'+
  158. '</div>';
  159. }
  160. var dochtml = '<li class="mt10" data-id="'+data.id+'">'+
  161. '<div class="n-list dr-item c-border">'+
  162. '<div class="n-list-li pl10">'+
  163. '<div class="n-list-key">'+
  164. '<div class="n-avatar-l img-round">'+
  165. '<img src="../../../images/'+img+'">'+
  166. '</div>'+
  167. '</div>'+
  168. '<div class="pl15 c-100">'+
  169. '<div>'+
  170. '<span class="c-f16 c-bold c-323232">'+data.name+'</span>'+
  171. title+
  172. '</div>'+
  173. '<div class="c-f12 c-323232 div-hospital">'+data.hospitalName+'</div>'+
  174. '<div class="c-f12 c-323232">'+data.hosDeptName+'</div>'+
  175. '</div>'+
  176. '</div>'+
  177. introduce+
  178. '<div class="line"></div>'+
  179. '<div class="mt10 c-f14 c-666666 mb10 pl10">'+
  180. '<span class="">'+
  181. '医生坐诊时间'+
  182. '</span>'+
  183. '</div>'+
  184. '<div class="div-timeList">';
  185. for(var j in res.data){
  186. if(j%2==0){
  187. dochtml+='<div class="height-40">';
  188. }
  189. var timeData = res.data[j];
  190. var dateTime = timeData.date+"";
  191. var date= dateTime.split(" ")[0];
  192. var week = getWeek(date);
  193. var riqi = date.split("/");
  194. riqi = riqi[1]+"-"+riqi[2];
  195. var used = parseInt(timeData.used);
  196. var max = parseInt(timeData.max);
  197. var isMo = timeData.time;
  198. var status = timeData.status;
  199. if(isMo =="a"){
  200. isMo ="上午";
  201. }else{
  202. isMo ="下午";
  203. }
  204. var clazz = "div-fr-time-item";
  205. if(j%2==0){
  206. clazz = "div-time-item"
  207. }
  208. var vip_icon = "";
  209. var timeBg = 'cb-74BF00';
  210. if(res.data[j].regType != undefined){
  211. if(res.data[j].regType.indexOf('vip')>-1 || res.data[j].regType.indexOf('VIP')>-1 || res.data[j].fee == '300'){
  212. vip_icon = '<i class="vip-icon"></i>';
  213. clazz = clazz+' vip-bg';
  214. timeBg = 'cb-FF9526';
  215. }
  216. }else{
  217. if(res.data[j].fee == '300'){
  218. vip_icon = '<i class="vip-icon"></i>';
  219. clazz = clazz+' vip-bg';
  220. timeBg = 'cb-FF9526';
  221. }
  222. }
  223. if(status==2||max<=used){
  224. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  225. '<span class="div-item-time">'+riqi+" "+week+isMo+'</span>'+
  226. '<span class="div-item-man c-fff cb-A8A8A8">满</span>'+
  227. vip_icon +
  228. '</div>';
  229. }
  230. else if(status==0){
  231. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  232. '<span class="div-item-time">'+riqi+" "+week+isMo+'</span>'+
  233. '<span class="div-item-man c-fff cb-A8A8A8">停</span>'+
  234. vip_icon +
  235. '</div>';
  236. }
  237. else{
  238. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  239. '<span class="div-item-no-man">'+riqi+" "+week+isMo+'</span>'+
  240. '<span class="div-item-man c-fff ' + timeBg + '">'+(max-used)+'</span>'+
  241. vip_icon +
  242. '</div>';
  243. }
  244. if(j%2==1||j==(res.data.lenth-1)){
  245. dochtml +='</div>';
  246. }
  247. }
  248. dochtml+='</div></div></li>';
  249. $(".c-list").append(dochtml);
  250. scroller1.refresh();
  251. $("#wrapper3").show()
  252. }else{
  253. getListFail(res);
  254. }
  255. });
  256. }
  257. function getWeek(d){
  258. var dateArray = d.split("/");
  259. var year = dateArray[0], month = dateArray[1], date = dateArray[2];
  260. var dt = new Date(year, month-1, date);
  261. var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
  262. return weekDay[dt.getDay()]
  263. }