index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 { getAuthUser } from "../../../../core/utils/jsapi";
  6. import { submitAuthCode } from "../../../../core/utils/ywtService";
  7. Component({
  8. props: {},
  9. data: {
  10. empty: true,
  11. clinicCard: {},
  12. filterParams: {
  13. type: "9",
  14. cardNum: "",
  15. endTime: "",
  16. startTime: "",
  17. medicCards: [],
  18. timeShow: false,
  19. },
  20. /* 赛选项目 */
  21. typeOptions: [],
  22. statusOptions: [
  23. {
  24. value: "0",
  25. label: "待支付",
  26. },
  27. {
  28. value: "1",
  29. label: "已支付",
  30. },
  31. ],
  32. showAll: false,
  33. showTimeSelector: true,
  34. defaultLabel: "待支付",
  35. defaultName: "待支付",
  36. defaultStatus: "待支付",
  37. },
  38. didMount() {
  39. /* 服务预警,缴费记录查询 */
  40. reportCmPV_YL({
  41. title: "缴费记录查询",
  42. });
  43. },
  44. onInit() {},
  45. methods: {
  46. onFilterHandel(filters) {
  47. if (!this.hisPatientId) return;
  48. this.filters = filters;
  49. this.scrollRef.refresh();
  50. },
  51. saveRef(ref) {
  52. this.scrollRef = ref;
  53. },
  54. saveSubscribe(ref) {
  55. this.subscribe = ref;
  56. },
  57. onService(page) {
  58. const { status } = this.filters || {};
  59. if (!this.hisPatientId) return;
  60. return payHistory({
  61. ...this.filters,
  62. status: status || "0",
  63. ...page,
  64. hisPatientId: this.hisPatientId,
  65. });
  66. },
  67. onAutoFilter(patient) {
  68. if (patient) {
  69. this.hisPatientId = patient.hisPatientId;
  70. this.scrollRef.refresh();
  71. }
  72. },
  73. // 进入详情
  74. toDetail(e) {
  75. const {
  76. item: {
  77. type,
  78. outTradeNo,
  79. status,
  80. tradeNo,
  81. invoiceNo,
  82. hisPatientId,
  83. date,
  84. depName,
  85. amount,
  86. name,
  87. age,
  88. sex,
  89. prescribeDate,
  90. hisOrderNo,
  91. doctorName,
  92. doctorCode,
  93. total,
  94. hisClinicCode,
  95. deptName,
  96. },
  97. } = e.target.dataset;
  98. history.push({
  99. title: "缴费详情",
  100. query: {
  101. type: type || 0,
  102. outTradeNo,
  103. status,
  104. tradeNo,
  105. invoiceNo,
  106. hisPatientId,
  107. date,
  108. depName,
  109. amount,
  110. name,
  111. age,
  112. sex,
  113. prescribeDate,
  114. hisOrderNo,
  115. doctorName,
  116. doctorCode,
  117. total,
  118. hisClinicCode,
  119. deptName,
  120. },
  121. pageType: "hospital-payment-detail",
  122. });
  123. },
  124. // 付款
  125. async onPayment(e) {
  126. const { medicareBinded = false, item } = e.target.dataset; // 同意订阅消息后发起支付
  127. const [err, authResult] = await getAuthUser([
  128. "auth_user",
  129. "hospital_order",
  130. ]);
  131. if (err) {
  132. my.showToast({
  133. type: "fail",
  134. content: "智能消息推送授权失败",
  135. });
  136. } else {
  137. const [error, result] = await submitAuthCode({
  138. authCode: authResult.authCode,
  139. });
  140. if (!error) {
  141. my.showToast({
  142. type: "success",
  143. content: "消息订阅成功",
  144. });
  145. }
  146. return [error, result];
  147. }
  148. // 挂号
  149. if (item.type === 1) {
  150. await tradePay(
  151. {
  152. type: item.type,
  153. idNum: item.outTradeNo,
  154. depName: item.depName,
  155. },
  156. {
  157. tradeType: "Appointment",
  158. }
  159. );
  160. } else if (item.type === 2) {
  161. // 充值
  162. await tradePay(
  163. {
  164. type: item.type,
  165. idNum: item.outTradeNo,
  166. amount: item.amount,
  167. },
  168. {
  169. tradeType: "Appointment",
  170. }
  171. );
  172. } else {
  173. // 门诊订单
  174. await tradePay(
  175. {
  176. useBalance: !medicareBinded,
  177. useMedicare: medicareBinded,
  178. outTradeNo: item.outTradeNo,
  179. ...item,
  180. },
  181. {
  182. tradeType: "Outpatient",
  183. }
  184. );
  185. } // 支付成功去订单详情页
  186. this.toDetail({
  187. target: {
  188. dataset: {
  189. outTradeNo: item.outTradeNo,
  190. type: item.type ? item.type : 0,
  191. ...item,
  192. },
  193. },
  194. }); // 发起消息订阅
  195. // this.subscribe.subscribeMessage();
  196. },
  197. },
  198. });