index.js 1.8 KB

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