index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import request from "../../../../core/utils/request";
  2. import { activeStatusUrl } from "../../../../core/utils/constants";
  3. import { report } from '@mas.io/falcon-utils';
  4. const app = getApp();
  5. Component({
  6. props: {
  7. componentData: {}
  8. },
  9. data: {
  10. success: false,
  11. // summary组件是否渲染完成
  12. bindStatus: false
  13. },
  14. async didMount() {
  15. const params = {
  16. isShowLoadig: true,
  17. isShowError: true,
  18. method: 'GET',
  19. url: activeStatusUrl
  20. };
  21. report('@mas.io/medicare-home');
  22. const [err, res = {}] = await request(params);
  23. if (err) return;
  24. const {
  25. bindStatus,
  26. appid,
  27. page
  28. } = res;
  29. this.setData({
  30. bindStatus
  31. });
  32. const currentAppId = app.globalData.appId;
  33. const pages = getCurrentPages() || [];
  34. const len = pages.length; // eslint-disable-next-line no-proto
  35. const currentPage = pages[len - 1].__proto__.route;
  36. const {
  37. pageUuid
  38. } = this.$page.options;
  39. const pageOptions = `?source=medicare&pageUuid=${pageUuid}`;
  40. const currentAppSchema = `alipays://platformapi/startapp?appId=${currentAppId}&page=${currentPage}${encodeURIComponent(pageOptions)}`;
  41. const path = `${page}?returnUrl=${encodeURIComponent(currentAppSchema)}`;
  42. if (bindStatus === 'NOT_BIND' && appid && page) {
  43. return my.navigateToMiniProgram({
  44. appId: appid,
  45. path
  46. });
  47. }
  48. },
  49. methods: {
  50. onSuccess() {
  51. this.setData({
  52. success: true
  53. });
  54. }
  55. }
  56. });