index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { getDepositDetails, getsubscribeID } from "./service";
  2. import { reportApi } from "../../utils/cloudMonitorHelper";
  3. Component({
  4. data: {
  5. showSubscrible: true,
  6. // 是否显示订阅部分
  7. detail: null,
  8. // 缴纳详情
  9. isReady: false,
  10. },
  11. didMount() {
  12. const { depositId, inpatientId, hisPatientId, name } =
  13. this.$page.data.query || {};
  14. this.getDepositDetailsFn(depositId, inpatientId, hisPatientId, name);
  15. // this.subscribeMsg();
  16. /* 服务办结,押金缴纳完成 */
  17. reportApi("押金缴纳完成");
  18. },
  19. methods: {
  20. subscribeMsg() {
  21. const pluginId = 2021001155639035;
  22. my.loadPlugin({
  23. plugin: `${pluginId}@*`,
  24. success: () => {
  25. this.setData({
  26. isReady: true,
  27. }); // 储存插件实列
  28. // eslint-disable-next-line no-undef
  29. const pluginInstance = requirePlugin(`dynamic-plugin://${pluginId}`);
  30. this.requestSubscribeMessage = pluginInstance.requestSubscribeMessage;
  31. },
  32. });
  33. },
  34. showSubscrible() {
  35. this.setData({
  36. showSubscrible: false,
  37. });
  38. },
  39. // 订阅插件要用时,请放开注释
  40. requestSubscribeMessageFn(subscribeID) {
  41. return new Promise((resolve) => {
  42. my.requestSubscribeMessage({
  43. // 模板id列表,最多3个
  44. entityIds: [subscribeID],
  45. callback() {
  46. resolve(true);
  47. },
  48. });
  49. });
  50. },
  51. async gotoSubscrible() {
  52. try {
  53. const subscribeID = await getsubscribeID();
  54. await this.requestSubscribeMessageFn(subscribeID.depositTemplateId);
  55. } catch (error) {
  56. console.log(error, "error");
  57. }
  58. },
  59. // 获取支付详情
  60. async getDepositDetailsFn(depositId, inpatientId, hisPatientId, name) {
  61. try {
  62. const detail = await getDepositDetails({
  63. depositId,
  64. hisPatientId: hisPatientId,
  65. receiptNo: depositId,
  66. name,
  67. });
  68. this.setData({
  69. detail,
  70. });
  71. } catch (error) {
  72. console.log(error, "error");
  73. }
  74. },
  75. },
  76. });