select-doctor.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 = "350200";
  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. appendDoc(res.data);
  106. }else{
  107. getListFail(res);
  108. }
  109. }
  110. function getListFail(res){
  111. plus.nativeUI.closeWaiting();
  112. if (res && res.msg) {
  113. mui.toast(res.msg);
  114. } else {
  115. mui.toast("医生列表获取失败!");
  116. }
  117. }
  118. function appendDoc(dataList){
  119. var dochtml ="";
  120. if(pageIndex==1){
  121. $(".c-list").html("");
  122. }
  123. updatePullUpText(scroller1,dataList);
  124. for(var j in dataList){
  125. var data = dataList[j];
  126. getDocTime(data);
  127. }
  128. }
  129. function getDocTime(data){
  130. var params={};
  131. params.OrgCode = hospitalId;
  132. params.DeptCode = deptId;
  133. params.DocCode = data.id;
  134. sendPost('wlyy_service/third/smjk/RegDeptSpeDoctorSectionList', params, getListFail, function(res){
  135. if(res.status==200){
  136. plus.nativeUI.closeWaiting();
  137. if(!res.data||res.data.length==0){
  138. return;
  139. }
  140. var title = "";
  141. var introduce = "";
  142. var img = getImgUrl(data.photo) || "d-male.png";
  143. if(data.title){
  144. title = '<span class="c-f16 c-666666 pl10">('+data.title+')</span>';
  145. }
  146. if(data.introduce){
  147. introduce = '<div class="mt5 c-f12 c-666666 mb5 pl10">'+
  148. '<span class="span-content">擅长:'+
  149. data.introduce+
  150. '</span>'+
  151. '</div>';
  152. }
  153. var dochtml = '<li class="mt10" data-id="'+data.id+'">'+
  154. '<div class="n-list dr-item c-border">'+
  155. '<div class="n-list-li pl10">'+
  156. '<div class="n-list-key">'+
  157. '<div class="n-avatar-l img-round">'+
  158. '<img src="../../../images/'+img+'">'+
  159. '</div>'+
  160. '</div>'+
  161. '<div class="pl15 c-100">'+
  162. '<div>'+
  163. '<span class="c-f16 c-bold c-323232">'+data.name+'</span>'+
  164. title+
  165. '</div>'+
  166. '<div class="c-f12 c-323232 div-hospital">'+data.hospitalName+'</div>'+
  167. '<div class="c-f12 c-323232">'+data.hosDeptName+'</div>'+
  168. '</div>'+
  169. '</div>'+
  170. introduce+
  171. '<div class="line"></div>'+
  172. '<div class="mt10 c-f14 c-666666 mb10 pl10">'+
  173. '<span class="">'+
  174. '医生坐诊时间'+
  175. '</span>'+
  176. '</div>'+
  177. '<div class="div-timeList">';
  178. for(var j in res.data){
  179. if(j%2==0){
  180. dochtml+='<div class="height-40">';
  181. }
  182. var timeData = res.data[j];
  183. var dateTime = timeData.date+"";
  184. var date= dateTime.split(" ")[0];
  185. var week = getWeek(date);
  186. var riqi = date.split("/");
  187. riqi = riqi[1]+"-"+riqi[2];
  188. var used = parseInt(timeData.used);
  189. var max = parseInt(timeData.max);
  190. var isMo = timeData.time;
  191. var status = timeData.status;
  192. if(isMo =="a"){
  193. isMo ="上午";
  194. }else{
  195. isMo ="下午";
  196. }
  197. var clazz = "div-fr-time-item";
  198. if(j%2==0){
  199. clazz = "div-time-item"
  200. }
  201. var vip_icon = "";
  202. var timeBg = 'cb-74BF00';
  203. if(res.data[j].regType != undefined){
  204. if(res.data[j].regType.indexOf('vip')>-1 || res.data[j].regType.indexOf('VIP')>-1 || res.data[j].fee == '300'){
  205. vip_icon = '<i class="vip-icon"></i>';
  206. clazz = clazz+' vip-bg';
  207. timeBg = 'cb-FF9526';
  208. }
  209. }else{
  210. if(res.data[j].fee == '300'){
  211. vip_icon = '<i class="vip-icon"></i>';
  212. clazz = clazz+' vip-bg';
  213. timeBg = 'cb-FF9526';
  214. }
  215. }
  216. if(status==2||max<=used){
  217. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  218. '<span class="div-item-time">'+riqi+" "+week+isMo+'</span>'+
  219. '<span class="div-item-man c-fff cb-A8A8A8">满</span>'+
  220. vip_icon +
  221. '</div>';
  222. }
  223. else if(status==0){
  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{
  231. dochtml+='<div class="'+clazz+'" data-id="'+j+'">'+
  232. '<span class="div-item-no-man">'+riqi+" "+week+isMo+'</span>'+
  233. '<span class="div-item-man c-fff ' + timeBg + '">'+(max-used)+'</span>'+
  234. vip_icon +
  235. '</div>';
  236. }
  237. if(j%2==1||j==(res.data.lenth-1)){
  238. dochtml +='</div>';
  239. }
  240. }
  241. dochtml+='</div></div></li>';
  242. $(".c-list").append(dochtml);
  243. scroller1.refresh();
  244. $("#wrapper3").show()
  245. }else{
  246. getListFail(res);
  247. }
  248. });
  249. }
  250. function getWeek(d){
  251. var dateArray = d.split("/");
  252. var year = dateArray[0], month = dateArray[1], date = dateArray[2];
  253. var dt = new Date(year, month-1, date);
  254. var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
  255. return weekDay[dt.getDay()]
  256. }