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