doctorWhoAnother.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. (function (c) {
  2. config.init();
  3. var selectedDate = window.Fx.getUrlParam('date')||(new Date()).pattern('yyyy-MM-dd');
  4. var startDate = (new Date()).pattern('yyyy-MM-dd');
  5. var endDate = (new Date(new Date().getTime()+ 24 * 60 * 60 * 1000 * 8)).pattern('yyyy-MM-dd');
  6. var a = {
  7. hospitalId: Fx.getUrlParam("hospitalId"),
  8. deptId: Fx.getUrlParam("deptId"),
  9. doctorId: Fx.getUrlParam("doctorId")
  10. };
  11. var b = {
  12. hospitalId: Fx.getUrlParam("hospitalId"),
  13. deptId: Fx.getUrlParam("deptId"),
  14. doctorId: Fx.getUrlParam("doctorId"),
  15. startDate: startDate,
  16. endDate: endDate
  17. // regDate: window.Fx.getUrlParam('date')||(new Date()).pattern('yyyy-MM-dd')
  18. }
  19. //默认进行第一次请求号源拿数据
  20. var d = c.extend(window.hzAPI.getToken(),a);
  21. var timeFlag = '';
  22. var regFee = '';
  23. var treatFee = '';
  24. //界面显示日期 url参数
  25. //c('#date').html(selectedDate);
  26. //医生信息
  27. hzAPI.getData(window.apiUrl + "?c=Index&a=doctorInfo", a, "#docinfo");
  28. hzAPI.getData(window.apiUrl + "?c=Index&a=doctorInfo", a, "#list1 ul", 1, null, null, null);
  29. //获取医生预约
  30. var getDoctorBooking = function () {
  31. var deferred = c.Deferred();
  32. c.ajax({
  33. type: "get",
  34. url: window.apiUrl+"index.php?c=Other&a=getDoctorBookingScheduleSyn",
  35. dataType: "jsonp",
  36. data: c.extend(window.hzAPI.getToken(),a),
  37. jsonp: "callback",
  38. async: false,
  39. crossDomain: true,
  40. success:function (data) {
  41. deferred.resolve(data);
  42. },
  43. error: function (error) {
  44. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "网络链接失败");
  45. },
  46. timeout: 30000
  47. });
  48. return deferred.promise();
  49. }
  50. //获取的是日期
  51. var getDate = function () {
  52. var deferred = c.Deferred();
  53. c.ajax({
  54. type: "get",
  55. url: window.apiUrl+"getRegInfo.php",
  56. dataType: "jsonp",
  57. data: c.extend(window.hzAPI.getToken(),b),
  58. jsonp: "callback",
  59. async: false,
  60. crossDomain: true,
  61. success:function (data) {
  62. deferred.resolve(data);
  63. },
  64. error: function (error) {
  65. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "服务器繁忙,请刷新重试");
  66. },
  67. timeout: 9000
  68. });
  69. return deferred.promise();
  70. }
  71. c.when(getDate(),getDoctorBooking()).done(function (res1,res2) {
  72. // console.log(res1);
  73. if(!res1){
  74. window.hzAPI.dialog(false,window.hzAPI.options.timeout,'服务器繁忙,请刷新重试');
  75. return false;
  76. }
  77. var scheduleList = res1.Schedules.Schedule;
  78. if(scheduleList instanceof Array){
  79. console.log(scheduleList);
  80. }else{
  81. scheduleList = [scheduleList];
  82. }
  83. //添加金额到界面上显示
  84. c('#money').html('¥'+scheduleList[0].Fee/100);
  85. var dateList = res2.dataInfo.data;
  86. var scheduleStr = '';
  87. //找出选择日期的参数的值
  88. for(var i=0;i < scheduleList.length;i++){
  89. if(scheduleList[i].regDate == selectedDate){
  90. timeFlag = dateList[i].timeFlag;
  91. regFee = dateList[i].regFee;
  92. treatFee = dateList[i].treatFee;
  93. }
  94. }
  95. //左边
  96. for(var i=0;i < scheduleList.length;i++){
  97. if(i == 0){
  98. scheduleStr += '<li name="'+scheduleList[i].SessionName+'" class="active" value="'+ scheduleList[i].ServiceDate +'">'+
  99. scheduleList[i].ServiceDate + ' '+ scheduleList[i].SessionName +'</li>';
  100. continue;
  101. }
  102. scheduleStr += '<li name="'+scheduleList[i].SessionName+'" value="'+ scheduleList[i].ServiceDate +'">'+ scheduleList[i].ServiceDate + ' '+ scheduleList[i].SessionName +'</li>';
  103. }
  104. c('.wraplist.left ul').append(scheduleStr);
  105. //委托事件
  106. c('.wraplist.left').on('click','li',function (e) {
  107. c(e.currentTarget).addClass('active');
  108. c(e.currentTarget).siblings().removeClass('active');
  109. appointment(timeFlag,regFee,treatFee,c(e.target).html().split(' ')[0],c(e.target).attr('name'));
  110. });
  111. d.regDate = scheduleList[0].ServiceDate; //请求的日期
  112. appointment(timeFlag,regFee,treatFee,scheduleList[0].ServiceDate,scheduleList[0].SessionName);
  113. });
  114. var appointment = function (timeFlag,regFee,treatFee,regDate,timeInterval) {
  115. d.regDate = regDate;
  116. //获取内容
  117. c.ajax({
  118. type: "get",
  119. url: window.apiUrl+"index.php?c=ReqHis&a=getTimeRegInfo",
  120. dataType: "jsonp",
  121. data: d,
  122. jsonp: "callback",
  123. async: false,
  124. crossDomain: true,
  125. success:function (data) {
  126. var scheduleStr = '';
  127. var scheduleDate = data.dataInfo.data;
  128. c('.wraplist.right ul').html('');
  129. for (var i = 0; i < scheduleDate.length; i++) {
  130. if(scheduleDate[i].regLeaveCount>0){
  131. if(timeInterval=='上午'&&parseInt(scheduleDate[i].endTime.split(":")[0])<=12){
  132. scheduleStr += '<li class="line1">' +
  133. '<a href="doctorBookingSure.html?scheduleCode=' + scheduleDate[i].scheduleCode + '&hospitalId=' + b.hospitalId + '&deptId=' + b.deptId + '&doctorId=' + b.doctorId +
  134. '&regDate=' + regDate + '&timeFlag=' + timeFlag + '&regFee=' + regFee + '&treatFee=' + treatFee + '&startTime=' + scheduleDate[i].startTime + '&endTime=' + scheduleDate[i].endTime + '">' +
  135. ' <div class="info_line1" style="text-align: center;color: #008a8a">' + scheduleDate[i].startTime + '~' + scheduleDate[i].endTime +
  136. '(总' + scheduleDate[i].regTotalCount + '余' + scheduleDate[i].regLeaveCount + ')号' +
  137. '<span>可预约</span>' +
  138. ' </div>' +
  139. ' <div class="clear"></div>' +
  140. '</a>' +
  141. '</li>';
  142. }
  143. if(timeInterval=='下午'&&parseInt(scheduleDate[i].endTime.split(":")[0])>12){
  144. scheduleStr += '<li class="line1">' +
  145. '<a href="doctorBookingSure.html?scheduleCode=' + scheduleDate[i].scheduleCode + '&hospitalId=' + b.hospitalId + '&deptId=' + b.deptId + '&doctorId=' + b.doctorId +
  146. '&regDate=' + regDate + '&timeFlag=' + timeFlag + '&regFee=' + regFee + '&treatFee=' + treatFee + '&startTime=' + scheduleDate[i].startTime + '&endTime=' + scheduleDate[i].endTime + '">' +
  147. ' <div class="info_line1" style="text-align: center;color: #008a8a">' + scheduleDate[i].startTime + '~' + scheduleDate[i].endTime +
  148. '(总' + scheduleDate[i].regTotalCount + '余' + scheduleDate[i].regLeaveCount + ')号' +
  149. '<span>可预约</span>' +
  150. ' </div>' +
  151. ' <div class="clear"></div>' +
  152. '</a>' +
  153. '</li>';
  154. }
  155. }else{
  156. if(timeInterval=='上午'&&parseInt(scheduleDate[i].endTime.split(":")[0])<=12){
  157. scheduleStr += '<li class="line1">' +
  158. '<a href="javascript:;">' +
  159. ' <div class="info_line1" style="text-align: center;color: #008a8a">' + scheduleDate[i].startTime + '~' + scheduleDate[i].endTime +
  160. '(总' + scheduleDate[i].regTotalCount + '余' + scheduleDate[i].regLeaveCount + ')号' +
  161. '<span style="color: gray;">不可预约</span>' +
  162. ' </div>' +
  163. ' <div class="clear"></div>' +
  164. '</a>' +
  165. '</li>';
  166. }
  167. if(timeInterval=='下午'&&parseInt(scheduleDate[i].endTime.split(":")[0])>12){
  168. scheduleStr += '<li class="line1">' +
  169. '<a href="javascript:;">' +
  170. ' <div class="info_line1" style="text-align: center;color: #008a8a">' + scheduleDate[i].startTime + '~' + scheduleDate[i].endTime +
  171. '(总' + scheduleDate[i].regTotalCount + '余' + scheduleDate[i].regLeaveCount + ')号' +
  172. '<span style="color: gray;">不可预约</span>' +
  173. ' </div>' +
  174. ' <div class="clear"></div>' +
  175. '</a>' +
  176. '</li>';
  177. }
  178. }
  179. }
  180. c('.wraplist.right ul').append(scheduleStr);
  181. },
  182. error: function (error) {
  183. window.hzAPI.dialog(false, window.hzAPI.options.timeout, "服务器繁忙,请刷新重试");
  184. },
  185. timeout: 9000
  186. });
  187. }
  188. //旧接口
  189. // hzAPI.getData(window.apiUrl + "?c=Other&a=getDoctorBookingScheduleSyn", a, "#list1 ul", 1, null, null, null, "该周暂无出诊安排");
  190. // c('#subscribe').click(function (e) {
  191. // c('.lists').addClass('active');
  192. // });
  193. //
  194. //
  195. // c('.wrap').click(function (e) {
  196. // c('.lists').removeClass('active');
  197. // // c('#list1 ul').html('');
  198. // });
  199. //
  200. //
  201. // c('.close').click(function (e) {
  202. // c('.lists').removeClass('active');
  203. // })
  204. //添加关注
  205. // c('#favorite').click(function (e) {
  206. // window.hzAPI.sendData(window.apiUrl+"?c=Index&a=favoriteDoctor",c.extend(a,{status: 1}),false, ["更新失败", "更新成功"], [0, c(this)]);
  207. // })
  208. })(Zepto);