index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 } =
  13. this.$page.data.query || {};
  14. this.getDepositDetailsFn(depositId, inpatientId, hisPatientId);
  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) {
  61. try {
  62. const detail = await getDepositDetails({
  63. depositId,
  64. hisPatientId: hisPatientId,
  65. receiptNo: depositId,
  66. });
  67. this.setData({
  68. detail,
  69. });
  70. } catch (error) {
  71. console.log(error, "error");
  72. }
  73. },
  74. },
  75. });