detail-appointment.js 7.5 KB

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