index.js 1.7 KB

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