doctor-detail.js 7.7 KB

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