index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. Component({
  6. props: {},
  7. data: {
  8. empty: true,
  9. clinicCard: {},
  10. filterParams: {
  11. type: "9",
  12. cardNum: "",
  13. endTime: "",
  14. startTime: "",
  15. medicCards: [],
  16. timeShow: false,
  17. },
  18. /* 赛选项目 */
  19. typeOptions: [],
  20. statusOptions: [
  21. {
  22. value: "0",
  23. label: "待支付",
  24. },
  25. {
  26. value: "1",
  27. label: "已支付",
  28. },
  29. ],
  30. showAll: false,
  31. showTimeSelector: false,
  32. defaultLabel: "待支付",
  33. defaultName: "待支付",
  34. defaultStatus: "待支付",
  35. },
  36. didMount() {
  37. /* 服务预警,缴费记录查询 */
  38. reportCmPV_YL({
  39. title: "缴费记录查询",
  40. });
  41. },
  42. onInit() {},
  43. methods: {
  44. onFilterHandel(filters) {
  45. console.log("onFilterHandel ===>", filters);
  46. if (!this.hisPatientId) return;
  47. this.filters = filters;
  48. this.scrollRef.refresh();
  49. },
  50. saveRef(ref) {
  51. this.scrollRef = ref;
  52. },
  53. saveSubscribe(ref) {
  54. this.subscribe = ref;
  55. },
  56. onService(page) {
  57. console.log("onService ===>");
  58. const { type, status } = this.filters || {};
  59. if (!this.hisPatientId) return;
  60. if (this.filters && this.filters.status === "1") {
  61. this.setData({
  62. showTimeSelector: true,
  63. });
  64. if (!this.filters.startTime) {
  65. my.showToast({
  66. type: "fail",
  67. content: "请选择时间段",
  68. duration: 3000,
  69. });
  70. }
  71. return;
  72. } else {
  73. this.setData({
  74. showTimeSelector: false,
  75. });
  76. }
  77. console.log("onService 执行 ===>");
  78. return payHistory({
  79. ...this.filters,
  80. type: type || "9",
  81. status: status || "0",
  82. ...page,
  83. hisPatientId: this.hisPatientId,
  84. });
  85. },
  86. onAutoFilter(patient) {
  87. console.log("onAutoFilter ====>");
  88. if (patient) {
  89. this.hisPatientId = patient.hisPatientId;
  90. this.scrollRef.refresh();
  91. }
  92. },
  93. // 进入详情
  94. toDetail(e) {
  95. history.push({
  96. title: "缴费详情",
  97. query: e.target.dataset,
  98. pageType: "hospital-payment-detail",
  99. });
  100. },
  101. // 付款
  102. async onPayment(e) {
  103. const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
  104. // 挂号
  105. if (item.type === 1) {
  106. await tradePay(
  107. {
  108. type: item.type,
  109. idNum: item.outTradeNo,
  110. depName: item.depName,
  111. },
  112. {
  113. tradeType: "Appointment",
  114. }
  115. );
  116. } else if (item.type === 2) {
  117. // 充值
  118. await tradePay(
  119. {
  120. type: item.type,
  121. idNum: item.outTradeNo,
  122. amount: item.amount,
  123. },
  124. {
  125. tradeType: "Appointment",
  126. }
  127. );
  128. } else {
  129. // 门诊订单
  130. await tradePay(
  131. {
  132. useBalance: !medicareBinded,
  133. useMedicare: medicareBinded,
  134. outTradeNo: item.outTradeNo,
  135. },
  136. {
  137. tradeType: "Outpatient",
  138. }
  139. );
  140. } // 支付成功去订单详情页
  141. this.toDetail({
  142. target: {
  143. dataset: {
  144. outTradeNo: item.outTradeNo,
  145. type: item.type,
  146. },
  147. },
  148. }); // 发起消息订阅
  149. this.subscribe.subscribeMessage();
  150. },
  151. },
  152. });