link.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. export const navToAsync = (url) => {
  2. return new Promise((resolve, reject) => {
  3. uni.navigateTo({
  4. url: url,
  5. success: res => {
  6. return true;
  7. },
  8. fail: err => {
  9. return false;
  10. }
  11. });
  12. });
  13. }
  14. export const navto = (url, replace = false) => {
  15. if (replace) {
  16. return uni.redirectTo({
  17. url: url
  18. });
  19. }
  20. return uni.navigateTo({
  21. url: url
  22. });
  23. }
  24. export const home = () => {
  25. return navto('/pages/index/index', true);
  26. }
  27. export const back = () => {
  28. return new Promise((resolve, reject) => {
  29. uni.navigateBack({
  30. success: res => {
  31. return true;
  32. },
  33. fail: err => {
  34. uni.reLaunch({
  35. url: '/pages/index/index',
  36. });
  37. return false;
  38. }
  39. });
  40. });
  41. // return uni.navigateBack();
  42. }
  43. export const login = () => {
  44. let url : String
  45. // #ifdef MP-WEIXIN
  46. url = '/pages/login/index'
  47. // #endif
  48. // #ifdef APP
  49. url = '/pages/login/index'
  50. // #endif
  51. uni.navigateTo({
  52. url: url,
  53. })
  54. }
  55. export const goBJList = (replace = false) => {
  56. navto('/pages/feedback/index', replace)
  57. }
  58. // 办件详情
  59. export const goBJDetails = (id = null) => {
  60. if (id) {
  61. navto('/pages/feedback/details?id=' + id)
  62. } else {
  63. navto('/pages/feedback/details')
  64. }
  65. }
  66. // 登录页面
  67. export const goLogin = () => {
  68. navto('/pages/login/index')
  69. }
  70. // 错误页面
  71. export const getErrorPage = () => {
  72. navto('/pages/error/index')
  73. }