detail-appointment.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. mui.init();
  2. mui.plusReady(function(){
  3. var self = plus.webview.currentWebview();
  4. var id = self.dataId;
  5. if(id == "null"){
  6. id = "";
  7. }
  8. var xtCode = self.xtCode;
  9. var doctorCode = "";
  10. var orgCode = "";
  11. var deptCode = "";
  12. var patient = "";
  13. var details; //记录预约详情内容
  14. //注册事件
  15. bindEvents();
  16. //初始化数据
  17. initData();
  18. function initData(){
  19. var data={};
  20. data.orderId = id;
  21. sendPost('third/guahao/GetPatientReservation', data, getListFail, successFun);
  22. }
  23. function getCanceler(data) {
  24. var name = data.cancelerName;
  25. if(!name) return "";
  26. if(data.cancelerType=='1') {
  27. return name+'(专科医生)';
  28. } else if(data.cancelerType=='2') {
  29. return name+'(全科医生)';
  30. } else if(data.cancelerType=='3') {
  31. return name+'(健康管理师)';
  32. } else if(data.cancelerType=='4') {
  33. return name+'(临时专科)';
  34. } else if(data.cancelerType=='5') {
  35. return name;
  36. }
  37. return name;
  38. }
  39. function successFun(res){
  40. if(res.status==200){
  41. var data = res.data;
  42. details = data;
  43. //status:0 已撤销 1 预约成功 2 已就诊 3已停诊
  44. var clazz1 = "cb-47ABEF";
  45. var clazz2 = "c-47ABEF";
  46. var statusNm = "预约成功";
  47. //保存 协同数据
  48. if(xtCode){
  49. var params = {
  50. type:1,//1.预约成功,2.预约失败
  51. code:xtCode,
  52. orderHospital:details.orgCode,
  53. orderHospitalName:details.orgName,
  54. orderDept:details.deptCode,
  55. orderDeptName:details.deptName,
  56. orderDoctor :details.doctorCode,
  57. orderDoctorName:details.doctorName,
  58. orderTime:details.startTime,
  59. registerTime:details.czrq
  60. }
  61. plus.nativeUI.showWaiting();
  62. sendPost("doctor/pcCustomer/dealAppointCallService",params, function(){
  63. plus.nativeUI.closeWaiting();
  64. mui.toast("请求失败");
  65. }, function(res){
  66. plus.nativeUI.closeWaiting();
  67. if(res.status == 200){
  68. var page = plus.webview.getWebviewById("xietongfuwu-management");
  69. if(page){ mui.fire(page, "refreshXietong") }
  70. var page1 = plus.webview.getWebviewById("xietongfuwu-message");
  71. if(page1){ mui.fire(page1, "refreshXTmsg") }
  72. mui.toast("协同任务已完成");
  73. sendGet("doctor/pcCustomer/getCallServiceInfo",{code:xtCode}, function(){
  74. plus.nativeUI.closeWaiting();
  75. mui.toast("请求失败");
  76. }, function(res){
  77. plus.nativeUI.closeWaiting();
  78. if(res.status == 200){
  79. $('.xt-time').text(res.data.callService.createTime)
  80. $('.xt-text').text(res.data.callService.serverContent)
  81. $('.div-xietong').show();
  82. }else{
  83. mui.toast("获取数据失败");
  84. }
  85. })
  86. closePage()
  87. }else{
  88. mui.toast("协同任务保存失败");
  89. }
  90. })
  91. }
  92. if(data.status=="0"){
  93. clazz1 = "cb-FF6A56";
  94. clazz2 = "c-FF6A56";
  95. statusNm = "已撤销";
  96. var operator = getCanceler(data);
  97. if(operator) {
  98. $('.div-operator').show();
  99. $('#operator_name').text(operator);
  100. }
  101. $(".div-cancel-btn").hide();
  102. $(".div-tongkeshi-btn").removeClass("c-24").addClass("c-50");
  103. $(".div-again-yuyue").removeClass("c-38").addClass("c-50");
  104. }else if(data.status=="1"){
  105. // $(".div-cancel-btn").show();
  106. // TODO 如果预约开始时间早于当前时间,则不显示”取消预约“按钮
  107. var jzStartTimeStr = data.startTime.replace(/-/g,'/');
  108. var jsStartTime = new Date(jzStartTimeStr).getTime();
  109. var curTime = new Date().getTime();
  110. if(curTime>jsStartTime) {
  111. $(".div-cancel-btn").hide();
  112. } else {
  113. $(".div-cancel-btn").show();
  114. $(".div-tongkeshi-btn").removeClass("c-50").addClass("c-24");
  115. $(".div-again-yuyue").removeClass("c-50").addClass("c-38");
  116. }
  117. }else if(data.status=="2"){
  118. clazz1 = "cb-74BF00";
  119. clazz2 = "c-74BF00";
  120. statusNm = "已就诊";
  121. }else if(data.status=="3"){
  122. clazz1 = "cb-909090";
  123. clazz2 = "c-909090";
  124. statusNm = "已停诊";
  125. }
  126. var jiuzhenTime = data.startTime.replace(/\//g,'-').substring(0);//就诊时间
  127. if(data.endTime){
  128. jiuzhenTime = jiuzhenTime + "~"+data.endTime.replace(/\//g,'-').substring(9);
  129. }
  130. $(".left-yuan").addClass(clazz1);
  131. $(".left-status").addClass(clazz2).html(statusNm);
  132. $(".daiyuyue").html(data.dname);
  133. $(".guahao-time").html(data.czrq.substring(0,16));
  134. $(".jiuzheng-time").html(jiuzhenTime);
  135. $(".hospital-name").html(data.orgName);
  136. $(".users-name").html(data.name);
  137. $(".dept-name").html(data.deptName);
  138. $(".doctor-name").html(data.doctorName);
  139. $(".idcard").html(data.idcard);
  140. $(".yibao-num").html(data.ssc);
  141. $(".iphone-num").html(data.phone);
  142. doctorCode = data.doctorCode;
  143. orgCode = data.orgCode;
  144. deptCode = data.deptCode;
  145. patient = data.patient;
  146. }else{
  147. getListFail(res);
  148. }
  149. $(".main").show();
  150. $("#footer").show();
  151. }
  152. function getListFail(res){
  153. if (res && res.msg) {
  154. mui.toast(res.msg);
  155. } else {
  156. mui.toast("加载失败");
  157. }
  158. }
  159. function bindEvents(){
  160. //同科室医生
  161. $(".div-tongkeshi-btn").on("click",function(){
  162. var params ={};
  163. params.patient = patient;
  164. params.hospitalId = orgCode;
  165. params.deptId = deptCode;
  166. openWebviewExtras("select-doctor.html",params)
  167. });
  168. //再次预约
  169. $(".div-again-yuyue").on("click",function(){
  170. var params = {};
  171. params.id=id;
  172. params.doctorId=doctorCode;
  173. params.hospitalId=orgCode;
  174. params.deptId = deptCode;
  175. params.type=2;
  176. params.patient = patient;
  177. openWebviewExtras("doctor-detail.html",params);
  178. });
  179. //撤销预约
  180. $(".div-cancel-btn").on("click",function(){
  181. sendPost('doctor/guahao/isCancelOrder',{orderId:id},function(res) {
  182. mui.toast("操作失败");
  183. },function (res) {
  184. if(res.status == '0') {
  185. mui.toast('对不起,您本月已取消过该居民预约,如需继续撤销,请让居民自行处理。');
  186. } else {
  187. dialog({
  188. content: '取消预约次数将计入居民取消次数,居民每月取消超过3次将纳入黑名单。是否继续撤销?',
  189. okValue:'确认',
  190. ok: function (){
  191. plus.nativeUI.showWaiting();
  192. sendPost('doctor/guahao/CancelOrder', {orderId:id, code: details.code, ssc:details.ssc}, function() {
  193. plus.nativeUI.closeWaiting();
  194. mui.toast("操作失败");
  195. }, function(res) {
  196. plus.nativeUI.closeWaiting();
  197. if(res.status==200) {
  198. mui.toast("撤销成功");
  199. mui.fire(self.opener(),'update');
  200. initData();
  201. } else {
  202. mui.toast(res.msg);
  203. }
  204. },'post','',true);
  205. },
  206. cancelValue: '取消',
  207. cancel: function () {
  208. return ;
  209. }
  210. }).showModal();
  211. }
  212. },'post','',true)
  213. });
  214. }
  215. //关闭页面
  216. function closePage(){
  217. var page = plus.webview.getWebviewById("xietongfuwu-detail");
  218. if(page){ page.close('none') }
  219. var page1 = plus.webview.getWebviewById("appointment-register");
  220. if(page1){ page1.close('none') }
  221. var page2 = plus.webview.getWebviewById("hospital-dept");
  222. if(page2){ page2.close('none') }
  223. var page3 = plus.webview.getWebviewById("xietongfuwu-yy");
  224. if(page3){ page3.close('none') }
  225. var page4 = plus.webview.getWebviewById("select-doctor");
  226. if(page4){ page4.close('none') }
  227. var page5 = plus.webview.getWebviewById("doctor-detail");
  228. if(page5){ page5.close('none') }
  229. var page6 = plus.webview.getWebviewById("info-confirm");
  230. if(page6){ page6.close('none') }
  231. var page7 = plus.webview.getWebviewById("detail-appointment");
  232. if(page7){ page7.close('none') }
  233. }
  234. });