index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import { payHistory } from "./service";
  2. import history from "../../utils/history";
  3. import { tradePay } from "../../utils/tradePay";
  4. import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
  5. import { getSubscribeAuth } from "../../../../core/utils/ywtService";
  6. import { createSubscribe } from "applet-page-component";
  7. Component(
  8. createSubscribe({
  9. async onShow() {
  10. this.scrollRef.refresh();
  11. },
  12. })({
  13. props: {},
  14. data: {
  15. empty: true,
  16. clinicCard: {},
  17. filterParams: {
  18. type: "9",
  19. cardNum: "",
  20. endTime: "",
  21. startTime: "",
  22. medicCards: [],
  23. timeShow: false,
  24. },
  25. /* 赛选项目 */
  26. typeOptions: [],
  27. statusOptions: [
  28. {
  29. value: "0",
  30. label: "待支付",
  31. },
  32. {
  33. value: "1",
  34. label: "已支付",
  35. },
  36. ],
  37. showAll: false,
  38. showTimeSelector: true,
  39. showCardSelector: false,
  40. defaultLabel: "待支付",
  41. defaultName: "待支付",
  42. defaultStatus: "待支付",
  43. alertTitle: "",
  44. },
  45. didMount() {
  46. /* 服务预警,缴费记录查询 */
  47. reportCmPV_YL({
  48. title: "门诊缴费",
  49. });
  50. },
  51. onInit() { },
  52. methods: {
  53. onFilterHandel(filters) {
  54. const { status: prevStatus } = this.filters || {};
  55. const { status: curStatus } = filters || {};
  56. if (!this.hisPatientId) return;
  57. this.filters = filters;
  58. const { status, startTime, endTime } = this.filters || {};
  59. // 当状态未改变时,做时间筛选校验,拦截请求;当状态被改变时,做时间校验的同时,不拦截请求
  60. // 状态:已支付
  61. if (status && status === "1") {
  62. this.setData({
  63. alertTitle: "温馨提醒:每次最多能查询15天时间段的记录",
  64. });
  65. if (!startTime || this.getTimeChange(startTime, endTime, 15)) {
  66. my.showToast({
  67. type: "fail",
  68. content: "请选择15天以内的时间",
  69. duration: 1500,
  70. });
  71. if (prevStatus === curStatus) return;
  72. }
  73. }
  74. // 状态:未支付
  75. if (!status || status === "0") {
  76. this.setData({
  77. alertTitle: "",
  78. });
  79. if (!startTime || this.getTimeChange(startTime, endTime, 3)) {
  80. my.showToast({
  81. type: "fail",
  82. content: "请选择3天以内的时间",
  83. duration: 1500,
  84. });
  85. if (prevStatus === curStatus) return;
  86. }
  87. }
  88. this.scrollRef.refresh();
  89. },
  90. saveRef(ref) {
  91. this.scrollRef = ref;
  92. },
  93. saveSubscribe(ref) {
  94. this.subscribe = ref;
  95. },
  96. getTimeChange(startTime, endTime, len) {
  97. if (!startTime || !endTime) {
  98. return true;
  99. }
  100. const time1 = Date.parse(startTime);
  101. const time2 = Date.parse(endTime);
  102. const timeDiff = time2 - time1;
  103. const duration = len * 24 * 60 * 60 * 1000;
  104. return timeDiff < 0 || timeDiff > duration;
  105. },
  106. onService(page) {
  107. const { status, startTime, endTime } = this.filters || {};
  108. if (!this.hisPatientId) return;
  109. return payHistory({
  110. ...this.filters,
  111. status: status || "0",
  112. ...page,
  113. hisPatientId: this.hisPatientId,
  114. });
  115. },
  116. onAutoFilter(patient) {
  117. if (patient) {
  118. this.hisPatientId = patient.hisPatientId;
  119. this.scrollRef.refresh();
  120. }
  121. },
  122. // 进入详情
  123. toDetail(e) {
  124. const {
  125. item: {
  126. type,
  127. outTradeNo,
  128. status,
  129. tradeNo,
  130. invoiceNo,
  131. hisPatientId,
  132. date,
  133. depName,
  134. amount,
  135. name,
  136. age,
  137. sex,
  138. prescribeDate,
  139. hisOrderNo,
  140. doctorName,
  141. doctorCode,
  142. total,
  143. hisClinicCode,
  144. deptName,
  145. orderItems,
  146. orderInsType,
  147. medInsFee,
  148. selfFee,
  149. payName,
  150. patName
  151. },
  152. } = e.target.dataset;
  153. history.push({
  154. title: "缴费详情",
  155. query: {
  156. type: type || 0,
  157. outTradeNo,
  158. status,
  159. tradeNo,
  160. invoiceNo,
  161. hisPatientId,
  162. date,
  163. depName,
  164. amount,
  165. name,
  166. age,
  167. sex,
  168. prescribeDate,
  169. hisOrderNo,
  170. doctorName,
  171. doctorCode,
  172. total,
  173. hisClinicCode,
  174. deptName,
  175. orderInsType,
  176. orderItems: encodeURIComponent(JSON.stringify(orderItems || "")),
  177. medInsFee,
  178. selfFee,
  179. payName,
  180. patName
  181. },
  182. pageType: "hospital-payment-detail",
  183. });
  184. },
  185. // 付款
  186. async onPayment(e) {
  187. this.toDetail(e)
  188. },
  189. },
  190. })
  191. );