router.ts 991 B

123456789101112131415161718192021222324252627282930313233
  1. export function toSchemePage(id?: string) {
  2. if (!id) {
  3. wx.showToast({ title: '暂无调理方案', icon: 'none' });
  4. return
  5. }
  6. const route = 'module/health/pages/scheme/scheme';
  7. const pages = getCurrentPages();
  8. const historyIndex = pages.reverse().findIndex(page => page.route === route);
  9. if (historyIndex !== -1 && pages[historyIndex].options?.id === id) {
  10. wx.navigateBack({ delta: historyIndex + 1 });
  11. } else {
  12. wx.navigateTo({ url: `/${route}?id=${id}` });
  13. }
  14. }
  15. export function toReportPage(id?: string) {
  16. if (!id) {
  17. wx.showToast({ title: '暂无分析报告', icon: 'none' });
  18. return
  19. }
  20. const route = 'module/health/pages/report/report';
  21. const pages = getCurrentPages();
  22. const historyIndex = pages.reverse().findIndex(page => page.route === route);
  23. if (historyIndex !== -1 && pages[historyIndex].options?.id === id) {
  24. wx.navigateBack({ delta: historyIndex + 1 });
  25. } else {
  26. wx.navigateTo({ url: `/${route}?id=${id}` });
  27. }
  28. }