jieshoudingdan.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. var $confirmBtn = $('#confirmBtn'),
  2. $drugsInfo = $('#drugsInfo'),
  3. $receiveInfo = $('#receiveInfo'),
  4. $logs = $('#logs'),
  5. $orderRecord = $('#orderRecord'),
  6. $takeBtn = $('#takeBtn'),
  7. $reachBtn = $('#reachBtn');
  8. var docInfo = {};
  9. // 医生角色: 3 健管师;2 全科医生
  10. var level;
  11. // 是否是团队长
  12. var isLeader;
  13. var hospital;
  14. //取药类型:1 自取 2快递配送 3健管师配送
  15. var dispensaryDispensaryType;
  16. //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中 , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送 41配送失败 42配送中 43配送到服务站 100配送到患者手中/已完成)
  17. var prescriptionStatus;
  18. var prescriptionExpressage;
  19. var prescriptionCode = '';
  20. var teamCode = '';
  21. // 医院药品接收人Code
  22. var acceptCode = '';
  23. // 药品所到达的服务站
  24. var acceptHospital = '';
  25. // 患者填写的需要送达的机构code
  26. var patientHospitalCode = '';
  27. mui.plusReady(function() {
  28. var cur = plus.webview.currentWebview(),
  29. opener = cur.opener();
  30. if(opener.id == "shurushuzima") {
  31. mui.back = backToWebviewById("home2.html")
  32. }
  33. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  34. level = docInfo.level;
  35. hospital = docInfo.hospital || plus.storage.getItem("hospital");
  36. isLeader = docInfo.isLeader;
  37. var self = plus.webview.currentWebview();
  38. prescriptionCode = self.prescriptionCode;
  39. teamCode = self.teamCode;
  40. pageInit();
  41. })
  42. function getPrescriptionFollowPromise() {
  43. return getReqPromise("doctor/prescriptionInfo/prescriptionFollow", {
  44. prescriptionCode: prescriptionCode // 处方code
  45. }, 'GET')
  46. }
  47. function getOrderFollowPromise() {
  48. return getReqPromise("doctor/prescriptionlog/orderFollow", {
  49. prescriptionCode: prescriptionCode // 处方code
  50. }, 'GET')
  51. }
  52. // 显示订单记录
  53. function showOrderRecord(data) {
  54. var html = template('record_tmpl',data);
  55. $orderRecord.html(html)
  56. }
  57. // 显示药品信息
  58. function showDrugsInfo(drugs) {
  59. var html = template('drug_tmpl',{list: drugs});
  60. $drugsInfo.html(html)
  61. }
  62. // 显示收药信息(健管师)
  63. function showReceiveDrugsInfoForJG(data) {
  64. var html = template('jgs_delivery_tmpl',data)
  65. $receiveInfo.html(html)
  66. }
  67. // 显示订单跟踪
  68. function showLogsInfo() {
  69. getOrderFollowPromise().then(function(res) {
  70. if(res.status == 200) {
  71. var logs = res.data;
  72. if(logs && logs.length) {
  73. var html = template('log_tmpl',{list: logs});
  74. $logs.html(html)
  75. } else {
  76. $logs.text("暂无信息")
  77. }
  78. }
  79. }).catch(function(e) {
  80. console && console.error(e)
  81. })
  82. }
  83. function bindEvents() {
  84. $confirmBtn.on('click', function() {
  85. openWebview("querenjieshou.html",{
  86. prescriptionCode: prescriptionCode
  87. })
  88. })
  89. $reachBtn.on('click', function() {
  90. openWebview("peisongma.html",{
  91. prescriptionCode: prescriptionCode
  92. })
  93. })
  94. $takeBtn.on('click', function() {
  95. openWebview("querensongda.html",{
  96. prescriptionCode: prescriptionCode
  97. })
  98. })
  99. }
  100. function pageInit() {
  101. getPrescriptionFollowPromise().then(function(res) {
  102. var data;
  103. if(res.status == 200) {
  104. data = res.data;
  105. prescriptionStatus = data.prescriptionStatus;
  106. dispensaryDispensaryType = data.dispensaryDispensaryType;
  107. prescriptionExpressage = data.prescriptionExpressage;
  108. acceptCode = prescriptionExpressage.acceptCode;
  109. acceptHospital = prescriptionExpressage.acceptHospital;
  110. patientHospitalCode = prescriptionExpressage.patientHospitalCode;
  111. showOrderRecord({
  112. payNum: (data.prescriptionExpressage && data.prescriptionExpressage.code) || "",
  113. prescriptionHospital: data.prescriptionHospital||"",
  114. prescriptionStatusName: data.prescriptionStatusName||""
  115. })
  116. showDrugsInfo(data.prescriptionInfos)
  117. showReceiveDrugsInfoForJG($.extend({},prescriptionExpressage,{
  118. dispensaryDispensaryTypeName: data.dispensaryDispensaryTypeName
  119. }))
  120. // 如果订单当前状态为“药品到达服务站”,且接收人为该账号人时,显示订单跟踪记录
  121. if(prescriptionStatus == "43" && acceptCode == docInfo.code) {
  122. showLogsInfo();
  123. } else {
  124. $logs.closest('.c-list').hide();
  125. }
  126. // 如订单当前的接收人不是该账号人或订单状态为“配送员已领药”时,显示“确认接收”按钮
  127. if(acceptCode != docInfo.code || prescriptionStatus == "42") {
  128. $confirmBtn.css('display','block');
  129. }
  130. // 判断药品所到达的服务站与居民选择的配送服务站是否一致,一致则显示”居民已取药“按钮,
  131. // 点击后跳转扫描页,扫描居民取药码确认送达。不一致则显示”确认送达服务站“按钮,点击跳转配送码页,继续送药流程
  132. if(prescriptionStatus == "43" && acceptHospital == patientHospitalCode) {
  133. $takeBtn.show()
  134. } else {
  135. $reachBtn.show()
  136. }
  137. } else {
  138. mui.toast(res.msg);
  139. }
  140. }).catch(function(e) {
  141. console && console.error(e)
  142. })
  143. bindEvents();
  144. }
  145. /*刷新事件*/
  146. window.addEventListener("updateOrderStatus", function refresh(e) {
  147. getPrescriptionFollowPromise().then(function(res) {
  148. if(res.status == 200) {
  149. showOrderRecord({
  150. payNum: (data.prescriptionPay && data.prescriptionPay.payNum) || "",
  151. prescriptionHospital: data.prescriptionHospital||"",
  152. prescriptionStatusName: data.prescriptionStatusName||""
  153. })
  154. } else {
  155. mui.toast(res.msg);
  156. }
  157. })
  158. });