doctor-detail.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. var patient,hospitalId,deptId,doctorId,type,id = null,xtCode;
  2. mui.init();
  3. mui.plusReady(function(){
  4. var doctorInfo;
  5. var self = plus.webview.currentWebview();
  6. patient = self.patient;
  7. hospitalId = self.hospitalId;
  8. deptId = self.deptId;
  9. doctorId = self.doctorId;
  10. xtCode = self.xtCode;
  11. type = self.type;
  12. id = self.dataid;
  13. initData();
  14. bindEvents();//注册事件
  15. //协同
  16. if(xtCode){
  17. $('#no_appoint').show()
  18. $('#no_appoint').on('click',function(){
  19. mui.openWindow({
  20. id: "xietongfuwu-deal",
  21. url: "../../xtfw/html/xietongfuwu-deal.html",
  22. extras: {
  23. type:1,
  24. code:xtCode
  25. }
  26. })
  27. })
  28. }
  29. });
  30. function initData(){
  31. getDoctorInfo();
  32. }
  33. function getDoctorInfo(){
  34. var params ={};
  35. params.city=CITY_CODE;
  36. params.doctorId = doctorId;
  37. params.hospitalId = hospitalId;
  38. params.hosDeptId = deptId;
  39. sendPost("third/guahao/GetDoctorInfo",params,queryFailed,queryDoctorSuc);
  40. }
  41. function getDocWorkTimeInfo(){
  42. var params ={};
  43. params.OrgCode = hospitalId;
  44. params.DeptCode = deptId;
  45. params.DocCode = doctorId;
  46. sendPost("wlyy_service/third/smjk/RegDeptSpeDoctorSectionList",params,queryFailed,queryWorkTimeSuc);
  47. }
  48. function queryFailed(res){
  49. if (res && res.msg) {
  50. mui.toast(res.msg);
  51. } else {
  52. mui.toast("加载失败!");
  53. }
  54. }
  55. function queryDoctorSuc(res){
  56. if(res.status==200){
  57. showDocInfo(res.data);
  58. }else{
  59. queryFailed(res);
  60. }
  61. }
  62. function queryWorkTimeSuc(res){
  63. if(res.status==200){
  64. showWorkTimeList(res.data);
  65. }else{
  66. queryFailed(res);
  67. }
  68. }
  69. function showDocInfo(data){
  70. $("#name").html(data.name);
  71. $("#jobName").html(data.title);
  72. $("#hospitalName").html(data.hospitalName);
  73. $("#introduce").html(data.introduce);
  74. if(data.sex==2){
  75. // $("#photo").attr("src","../../../images/d-female.png");
  76. $("#photo").attr("src","../../../images/d-male.png");
  77. }else{
  78. $("#photo").attr("src","../../../images/d-male.png");
  79. }
  80. doctorInfo = data;
  81. getDocWorkTimeInfo();
  82. }
  83. function showWorkTimeList(data){
  84. var timeList = "";
  85. for(var j in data){
  86. var detail = data[j];
  87. var dateTime = detail.date+"";
  88. var date= dateTime.split(" ")[0];
  89. var week = getWeek(date);
  90. var riqi = date.split("/");
  91. riqi = riqi[1]+"-"+riqi[2];
  92. var used = detail.used;
  93. var max = detail.max;
  94. var isMo = detail.time;
  95. var detailTitle = "";
  96. if(isMo =="a"){
  97. isMo ="上午";
  98. }else{
  99. isMo ="下午";
  100. }
  101. var status = detail.status;
  102. var statusHtml ="";
  103. if(status==2){
  104. statusHtml= '<div class="div-btn-status">'+
  105. '<div class="div-dian cb-909090"></div>'+
  106. '<div class="div-status-content c-909090">已满</div>'+
  107. '</div>';
  108. }else{
  109. statusHtml= '<div class="div-btn-status">'+
  110. '<div class="div-dian cb-74bf00"></div>'+
  111. '<div class="div-status-content c-74bf00">预约</div>'+
  112. '</div>';
  113. }
  114. var liHtml = appendLi(detail);
  115. var titleColor = 'c-323232';
  116. if(data[j].regType != undefined){
  117. // debugger
  118. if(data[j].regType.indexOf('vip')>-1 || data[j].regType.indexOf('VIP')>-1 || data[j].fee == '300'){
  119. titleColor = 'c-FF9526';
  120. }
  121. }else{
  122. if(data[j].fee == '300'){
  123. titleColor = 'c-FF9526';
  124. data[j].regType = "VIP门诊";
  125. }else{
  126. data[j].regType = "普通门诊";
  127. }
  128. }
  129. timeList+= '<div class="div-item-content">'+
  130. '<div class="member-sel plr10 bor-b-f2" data-id="'+j+'">'+
  131. '<a class="arrow-shou fr ahide"></a>'+
  132. '<div class="h60">'+
  133. '<div class="div-item">'+
  134. '<div class="f-fs14 c-323232 f-tac h30 lh30 div-date">'+
  135. date+
  136. '</div>'+
  137. '<div class="f-fs12 f-tac h30 lh30 c-909090 div-week">'+
  138. week+" "+isMo+
  139. '</div>'+
  140. '</div>'+
  141. '<div class="div-item">'+
  142. '<div class="f-fs14 '+titleColor+' f-tac h30 lh30">'+
  143. data[j].regType+
  144. '</div>'+
  145. '<div class="f-fs12 f-tac h30 lh30 c-909090">'+
  146. '诊查费:<span class="zcf-money">'+detail.fee+'元</span>'+
  147. '</div>'+
  148. '</div>'+
  149. '<div class="div-item">'+
  150. statusHtml+
  151. '</div>'+
  152. '<div>'+
  153. '</div>'+
  154. '</div>'+
  155. '</div>'+
  156. '<ul class="c-list member-list bor-b-f2 mt10 cb-f2f4f6 c-hide mb10">'+
  157. liHtml+
  158. '</ul>'+
  159. '</div>';
  160. }
  161. $("#tice_list").append(timeList);
  162. init();//页面初始化
  163. }
  164. function appendLi(detail){
  165. var sections = detail.sections;
  166. var liHtml = "";
  167. for(var j in sections){
  168. var data = sections[j];
  169. if(j%3==0){
  170. if(j!=0){
  171. liHtml+='</li>';
  172. }
  173. liHtml+='<li class="c-list-link h34">';
  174. }
  175. var start = data.startTime;
  176. var end = data.endTime;
  177. var max = data.max;
  178. var used = data.used;
  179. var clazz = "div-time-enable";
  180. if(max==used){
  181. clazz = "div-time-disable";
  182. }
  183. liHtml+='<div data-attr=\'{"sectionType":"'+detail.time+'","startTime":"'+start+'","yysj":"'+getTime(start)+"-"+getTime(end)+'"}\' class="'+clazz+'">'+getTime(start)+"-"+getTime(end)+'</div>';
  184. if(j==(sections.length-1)){
  185. liHtml+='</li>';
  186. }
  187. }
  188. return liHtml;
  189. }
  190. function getWeek(d){
  191. var dateArray = d.split("/");
  192. var year = dateArray[0], month = dateArray[1], date = dateArray[2];
  193. var dt = new Date(year, month-1, date);
  194. var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
  195. return weekDay[dt.getDay()]
  196. }
  197. function getTime(dateTime){
  198. var tempStrs = dateTime.split(" ");
  199. var timeStrs = tempStrs[1].split(":");
  200. var hour = timeStrs [0];
  201. var minute = timeStrs [1];
  202. var second = timeStrs [2];
  203. return hour+":"+minute;
  204. }
  205. function init(){
  206. if(type==1 || type==""){//显示医生简介
  207. $("#doctorLi").addClass("hit");
  208. $(".div-doctor-info").show();
  209. }else{//显示门诊预约
  210. $("#deptyuyueLi").addClass("hit");
  211. $(".div-dept-info").show();
  212. }
  213. if($('.member-sel[data-id='+id+']').length>0){
  214. $('.member-sel[data-id='+id+']').siblings("ul").removeClass("c-hide");
  215. $('.member-sel[data-id='+id+']').find(".arrow-shou").addClass("active");
  216. var offset = $('.member-sel[data-id='+id+']').offset();
  217. window.scrollTo(offset.left,offset.top);
  218. }
  219. }
  220. function bindEvents(){
  221. //分组展开收起
  222. $(".div-dept-info").on('click', '.member-sel', function() {
  223. if(!$(this).siblings("ul").hasClass("c-hide")){
  224. $(this).find(".arrow-shou").removeClass("active");
  225. $(this).siblings("ul").addClass("c-hide");
  226. }else{
  227. $(".member-list").addClass("c-hide");
  228. $(".member-sel").find(".arrow-shou").removeClass("active");
  229. $(this).siblings("ul").removeClass("c-hide");
  230. $(this).find(".arrow-shou").addClass("active");
  231. }
  232. });
  233. $(".pt-tab").on("click","li",function(){
  234. var activeId = $(this).attr("id");
  235. $(".pt-tab li").removeClass("hit");
  236. $(this).addClass("hit");
  237. if(activeId=="doctorLi"){//医生简介
  238. $(".div-doctor-info").show();
  239. $(".div-dept-info").hide();
  240. }else{//门诊预约
  241. $(".div-doctor-info").hide();
  242. $(".div-dept-info").show();
  243. }
  244. })
  245. $(".div-dept-info").on("click",".div-time-enable",function(){
  246. $(".div-time-enable").removeClass("active");
  247. $(this).addClass("active");
  248. var arrangeDate = $(this).attr("data-attr");
  249. window.localStorage.setItem("arrangeDate",arrangeDate);
  250. window.localStorage.setItem("doctorTemp",JSON.stringify(doctorInfo));
  251. openWebviewExtras("info-confirm.html",{patient:patient,xtCode:xtCode});
  252. });
  253. }