index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. complete(result) {
  49. console.log("result ==>", result);
  50. },
  51. });
  52. });
  53. },
  54. async gotoSubscrible() {
  55. try {
  56. const subscribeID = await getsubscribeID();
  57. await this.requestSubscribeMessageFn(subscribeID.depositTemplateId);
  58. } catch (error) {
  59. console.log(error, "error");
  60. }
  61. },
  62. // 获取支付详情
  63. async getDepositDetailsFn(depositId, inpatientId, hisPatientId, name) {
  64. try {
  65. const detail = await getDepositDetails({
  66. depositId,
  67. hisPatientId: hisPatientId,
  68. receiptNo: depositId,
  69. name,
  70. });
  71. this.setData({
  72. detail,
  73. });
  74. } catch (error) {
  75. console.log(error, "error");
  76. }
  77. },
  78. },
  79. });