immune-date.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. var d = dialog({
  2. contentType: 'load',
  3. skin: 'bk-popup'
  4. });
  5. $(function() {
  6. var pageIndex = 1;
  7. var pageSize = 100;
  8. var request = GetRequest();
  9. var hospitalId = request["hospitalId"];
  10. var pageInfo;
  11. getPageInfo();
  12. bindEvents();
  13. templateHelper();
  14. function getPageInfo(){
  15. var url = "/patient/guahao/imm/GetOrgScheduleList",
  16. params = {
  17. orgCode: hospitalId
  18. };
  19. d.show();
  20. sendPost(url, params, 'json', 'get', queryFailed, function(res) {
  21. if(res.status == 200) {
  22. d.close();
  23. pageInfo = res.data;
  24. var html = template("info_tmp", res.data);
  25. $(".main").empty().append(html);
  26. } else {
  27. queryFailed(res);
  28. }
  29. });
  30. }
  31. function getTimeSection(orgId, scheduleId, amorpm){
  32. var url = "/patient/guahao/imm/GetOrgNumberList",
  33. params = {
  34. orgId: orgId,
  35. ScheduleId: scheduleId,
  36. amorpm: amorpm
  37. };
  38. d.show();
  39. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  40. if(res.status == 200){
  41. d.close();
  42. var html = template("section-info-tmp", {list: res.data});
  43. $(".time-section[data-id="+scheduleId+"]").empty().append(html);
  44. }else{
  45. queryFailed(res);
  46. }
  47. });
  48. }
  49. function bindEvents() {
  50. // $(".c-list").on("click", "li", function(event) {
  51. // var doctorId = $(this).attr("data-id");
  52. // var target = $(event.target);
  53. // if(target.closest(".div-timeList").length == 0) { //跳转到医生简介
  54. // location.href = "immune-detail.html?type=1&&hospitalId=" + hospitalId;
  55. // } else { //跳转到门诊预约
  56. // var id = target.closest("div").eq(0).attr("data-id");
  57. // location.href = "immune-detail.html?type=2&id=" + id + "&hospitalId=" + hospitalId;
  58. // }
  59. // })
  60. //展开查看
  61. $(".main").on('click', '.yy-info', function(){
  62. var $this = $(this),
  63. $ul = $this.siblings(),
  64. orgCode = $this.attr("data-org"),
  65. sid = $this.attr("data-sid"),
  66. time = $this.attr("data-time");
  67. if($ul.hasClass("c-hide")){
  68. $this.find(".fa").removeClass("fa-chevron-circle-down");
  69. $this.find(".fa").addClass("fa-chevron-circle-up");
  70. $ul.removeClass("c-hide");
  71. getTimeSection(orgCode, sid, time);
  72. }else{
  73. $this.find(".fa").removeClass("fa-chevron-circle-up");
  74. $this.find(".fa").addClass("fa-chevron-circle-down");
  75. $ul.addClass("c-hide");
  76. }
  77. });
  78. //选中时间预约
  79. $(".main").on('click', ".time", function(){
  80. var $this = $(this),
  81. time = $this.attr("data-time"),
  82. startTime = $this.attr("data-start"),
  83. timeRange = $this.text();
  84. if($this.hasClass("disabled")){
  85. return false;
  86. }
  87. var orgInfo = {},
  88. arrangeDate = {
  89. timeStr: startTime.substr(0, 10)+' '+timeRange,
  90. time: time,
  91. startTime: startTime
  92. };
  93. if(pageInfo){
  94. orgInfo = {
  95. code: pageInfo.ORG_CODE,
  96. name: pageInfo.ORG_NAME,
  97. };
  98. }
  99. window.localStorage.setItem("orgInfo", JSON.stringify(orgInfo));
  100. window.localStorage.setItem('arrangeDate', JSON.stringify(arrangeDate));
  101. // window.location.href = "immune-confirm.html";
  102. location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wxurl+"%2fwdyy%2fhtml%2fimmune-confirm.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
  103. })
  104. }
  105. function templateHelper(){
  106. template.helper('getWeek', function(str){
  107. var weekDay = ["周天", "周一", "周二", "周三", "周四", "周五", "周六"];
  108. return weekDay[parseInt(str)];
  109. });
  110. template.helper('formatDate', function(str, formatter){
  111. //默认时间格式是2017-08-12 08:00:00
  112. switch(formatter){
  113. case 'yyyy-MM-dd':
  114. return str.substring(0, 10);
  115. break;
  116. case 'HH:ss':
  117. return str.substring(11, 16);
  118. break;
  119. default:
  120. return str;
  121. break;
  122. }
  123. });
  124. template.helper('getOrgPhoto', function(url){
  125. if(url){
  126. return getImgUrl(url);
  127. }else{
  128. return "../../qygl/images/hospital_default.png";
  129. }
  130. })
  131. }
  132. function queryFailed(res) {
  133. d.close();
  134. if(res && res.msg) {
  135. if((res.msg).indexOf("SOAP") >= 0) {
  136. dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: "医院接口访问异常,请刷新后重试!", bottom: true }).show();
  137. return false;
  138. }
  139. dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: res.msg, bottom: true }).show();
  140. } else {
  141. dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '加载失败', bottom: true }).show();
  142. }
  143. }
  144. });