index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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: false,
  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. // if (!startTime || this.getTimeChange(startTime, endTime, 15)) {
  63. // my.showToast({
  64. // type: "fail",
  65. // content: "请选择15天以内的时间",
  66. // duration: 1500,
  67. // });
  68. // if (prevStatus === curStatus) return;
  69. // }
  70. // }
  71. // 状态:未支付
  72. // if (!status || status === "0") {
  73. // if (!startTime || this.getTimeChange(startTime, endTime, 3)) {
  74. // my.showToast({
  75. // type: "fail",
  76. // content: "请选择3天以内的时间",
  77. // duration: 1500,
  78. // });
  79. // if (prevStatus === curStatus) return;
  80. // }
  81. // }
  82. this.scrollRef.refresh();
  83. },
  84. saveRef(ref) {
  85. this.scrollRef = ref;
  86. },
  87. saveSubscribe(ref) {
  88. this.subscribe = ref;
  89. },
  90. getTimeChange(startTime, endTime, len) {
  91. if (!startTime || !endTime) {
  92. return true;
  93. }
  94. const time1 = Date.parse(startTime);
  95. const time2 = Date.parse(endTime);
  96. const timeDiff = time2 - time1;
  97. const duration = len * 24 * 60 * 60 * 1000;
  98. return timeDiff < 0 || timeDiff > duration;
  99. },
  100. onService(page) {
  101. const { status, startTime, endTime } = this.filters || {};
  102. if (!this.hisPatientId) return;
  103. return payHistory({
  104. ...this.filters,
  105. status: status || "0",
  106. ...page,
  107. hisPatientId: this.hisPatientId,
  108. });
  109. },
  110. onAutoFilter(patient) {
  111. if (patient) {
  112. this.hisPatientId = patient.hisPatientId;
  113. this.scrollRef.refresh();
  114. }
  115. },
  116. // 进入详情
  117. toDetail(e) {
  118. const {
  119. item: {
  120. type,
  121. outTradeNo,
  122. status,
  123. tradeNo,
  124. invoiceNo,
  125. hisPatientId,
  126. date,
  127. depName,
  128. amount,
  129. name,
  130. age,
  131. sex,
  132. prescribeDate,
  133. hisOrderNo,
  134. doctorName,
  135. doctorCode,
  136. total,
  137. hisClinicCode,
  138. deptName,
  139. orderItems,
  140. },
  141. } = e.target.dataset;
  142. history.push({
  143. title: "缴费详情",
  144. query: {
  145. type: type || 0,
  146. outTradeNo,
  147. status,
  148. tradeNo,
  149. invoiceNo,
  150. hisPatientId,
  151. date,
  152. depName,
  153. amount,
  154. name,
  155. age,
  156. sex,
  157. prescribeDate,
  158. hisOrderNo,
  159. doctorName,
  160. doctorCode,
  161. total,
  162. hisClinicCode,
  163. deptName,
  164. orderItems: encodeURIComponent(JSON.stringify(orderItems || "")),
  165. },
  166. pageType: "hospital-payment-detail",
  167. });
  168. },
  169. // 付款
  170. async onPayment(e) {
  171. const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
  172. try {
  173. my.showLoading();
  174. // 获取智能消息推送授权
  175. await getSubscribeAuth();
  176. // 挂号
  177. if (item.type === 1) {
  178. await tradePay(
  179. {
  180. type: item.type,
  181. idNum: item.outTradeNo,
  182. depName: item.depName,
  183. },
  184. {
  185. tradeType: "Appointment",
  186. }
  187. );
  188. } else if (item.type === 2) {
  189. // 充值
  190. await tradePay(
  191. {
  192. type: item.type,
  193. idNum: item.outTradeNo,
  194. amount: item.amount,
  195. },
  196. {
  197. tradeType: "Appointment",
  198. }
  199. );
  200. } else {
  201. // 门诊订单
  202. await tradePay(
  203. {
  204. useBalance: !medicareBinded,
  205. useMedicare: medicareBinded,
  206. outTradeNo: item.outTradeNo,
  207. ...item,
  208. },
  209. {
  210. tradeType: "Outpatient",
  211. }
  212. );
  213. }
  214. } catch (error) {
  215. } finally {
  216. my.hideLoading();
  217. }
  218. this.scrollRef.refresh();
  219. // 支付成功去订单详情页
  220. this.toDetail({
  221. target: {
  222. dataset: {
  223. outTradeNo: item.outTradeNo,
  224. type: item.type ? item.type : 0,
  225. ...item,
  226. },
  227. },
  228. }); // 发起消息订阅
  229. // this.subscribe.subscribeMessage();
  230. },
  231. },
  232. })
  233. );