doctorWho.min.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. (function (c) {
  2. config.init();
  3. var selectedDate = window.Fx.getUrlParam('date');
  4. var a = {
  5. hospitalId: Fx.getUrlParam("hospitalId"),
  6. deptId: Fx.getUrlParam("deptId"),
  7. doctorId: Fx.getUrlParam("doctorId")
  8. };
  9. var b = {
  10. hospitalId: Fx.getUrlParam("hospitalId"),
  11. deptId: Fx.getUrlParam("deptId"),
  12. doctorId: Fx.getUrlParam("doctorId"),
  13. regDate: window.Fx.getUrlParam('date')||(new Date()).pattern('yyyy-MM-dd')
  14. }
  15. //界面显示日期 url参数
  16. // c('#date').html(selectedDate);
  17. //获取医生诊疗费用
  18. c.ajax({
  19. type: "get",
  20. url: window.apiUrl + "index.php?c=Other&a=getDoctorBookingScheduleSyn",
  21. dataType: "jsonp",
  22. data: c.extend(window.hzAPI.getToken(), a),
  23. jsonp: "callback",
  24. async: false,
  25. crossDomain: true,
  26. success: function (data) {
  27. //显示金额
  28. c('#money').html('¥'+data.dataInfo.data[0].treatFee/100 + '.00');
  29. },
  30. error: function (error) {
  31. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败");
  32. },
  33. timeout: 9000
  34. });
  35. //医生信息
  36. hzAPI.getData(window.apiUrl + "?c=Index&a=doctorInfo", a, "#docinfo");
  37. //hzAPI.getData(window.apiUrl + "?c=Index&a=doctorInfo", a, "#list1 ul", 1, null, null, null);
  38. var getTime = function () {
  39. var deferred = c.Deferred();
  40. c.ajax({
  41. type: "get",
  42. url: window.apiUrl+"index.php?c=ReqHis&a=getTimeRegInfo",
  43. dataType: "jsonp",
  44. data: c.extend(window.hzAPI.getToken(),b),
  45. jsonp: "callback",
  46. async: false,
  47. crossDomain: true,
  48. success:function (data) {
  49. deferred.resolve(data);
  50. },
  51. error: function (error) {
  52. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "服务器繁忙,请刷新重试");
  53. },
  54. timeout: 9000
  55. });
  56. return deferred.promise();
  57. }
  58. var getDate = function () {
  59. var deferred = c.Deferred();
  60. c.ajax({
  61. type: "get",
  62. url: window.apiUrl+"index.php?c=Other&a=getDoctorBookingScheduleSyn",
  63. dataType: "jsonp",
  64. data: c.extend(window.hzAPI.getToken(),a),
  65. jsonp: "callback",
  66. async: false,
  67. crossDomain: true,
  68. success:function (data) {
  69. deferred.resolve(data);
  70. },
  71. error: function (error) {
  72. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败");
  73. },
  74. timeout: 9000
  75. });
  76. return deferred.promise();
  77. }
  78. //就诊日期 获取参数生成链接
  79. c.when(getTime(),getDate()).done(function (res1,res2) {
  80. //如果返回的结果是 false 说明医院的接口又拿不到数据啦~
  81. if(!res1||!res2){
  82. window.hzAPI.dialog(fasle,window.hzAPI.options.timeout,"服务器繁忙,请刷新重试");
  83. return false;
  84. }
  85. console.log(res1,res2);
  86. var list = res1.dataInfo.data;
  87. var dateList = res2.dataInfo.data;
  88. var timeFlag = '';
  89. var regFee = '';
  90. var treatFee = '';
  91. var listStr = '';
  92. //找出选择日期的参数的值
  93. for(var i in dateList){
  94. if(dateList[i].regDate == selectedDate){
  95. timeFlag = dateList[i].timeFlag;
  96. regFee = dateList[i].regFee;
  97. treatFee = dateList[i].treatFee;
  98. }
  99. }
  100. $('.subscribeList li').eq(0).siblings().remove();
  101. for(var i = 0; i<list.length ; i++ ){
  102. if(list[i].regLeaveCount > 0){
  103. listStr += '<li class="line1">' +
  104. '<a href="doctorBookingSure.html?scheduleCode='+ list[i].scheduleCode +'&hospitalId='+b.hospitalId+'&deptId='+b.deptId+'&doctorId='+b.doctorId+
  105. '&regDate='+ b.regDate +'&timeFlag='+ timeFlag +'&regFee='+ regFee +'&treatFee='+ treatFee +'&startTime='+ list[i].startTime +'&endTime='+ list[i].endTime +'">' +
  106. ' <span class="button"><i class="icon-arrowright"></i> </span>' +
  107. ' <div class="info_line1" style="text-align: center;color: #008a8a">' + list[i].startTime + '~' + list[i].endTime +
  108. '(总'+ list[i].regTotalCount +'余'+ list[i].regLeaveCount +')号 '+
  109. '<span>可预约</span>' +
  110. ' </div>' +
  111. ' <div class="clear"></div>' +
  112. '</a>' +
  113. '</li>';
  114. }else{
  115. listStr += '<li class="line1">' +
  116. '<a href="javascript:;">' +
  117. ' <span class="button"><i class="icon-arrowright"></i> </span>' +
  118. ' <div class="info_line1" style="text-align: center;color: #008a8a">' + list[i].startTime + '~' + list[i].endTime +
  119. '(总'+ list[i].regTotalCount +'余'+ list[i].regLeaveCount +')号 '+
  120. '<span style="color: gray;">不可预约</span>' +
  121. ' </div>' +
  122. ' <div class="clear"></div>' +
  123. '</a>' +
  124. '</li>';
  125. }
  126. '<span style="color: red">已约满</span>'
  127. }
  128. $('.subscribeList ul').append(listStr);
  129. })
  130. //旧接口
  131. // hzAPI.getData(window.apiUrl + "?c=Other&a=getDoctorBookingScheduleSyn", a, "#list1 ul", 1, null, null, null, "该周暂无出诊安排");
  132. c('#subscribe').click(function (e) {
  133. c('#d-title').html('<div>'+$('.doctor .name').html()+' <span>'+$('.doctor .title').html()+'</span></div>');
  134. c('#d-img').attr('src',$('.doctor img').attr('src'));
  135. c('.lists').addClass('active');
  136. });
  137. c('.wrap').click(function (e) {
  138. c('.lists').removeClass('active');
  139. // c('#list1 ul').html('');
  140. });
  141. c('body').on('click','.close',function (e) {
  142. c('.lists').removeClass('active');
  143. })
  144. //添加关注
  145. // c('#favorite').click(function (e) {
  146. // window.hzAPI.sendData(window.apiUrl+"?c=Index&a=favoriteDoctor",c.extend(a,{status: 1}),false, ["更新失败", "更新成功"], [0, c(this)]);
  147. // })
  148. })(Zepto);