多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4 KiB

2 years ago
2 years ago
2 years ago
  1. /**
  2. * @FileDescription:
  3. * @Author: kahu
  4. * @Date: 2022/11/3
  5. * @LastEditors: kahu
  6. * @LastEditTime: 2022/11/3
  7. */
  8. /**
  9. * 跳转非tabbar页面
  10. * @param url 路径
  11. * @param param 参数对象
  12. * @param timeout 延时时间默认0
  13. * @param type default普通跳转 redirect关闭当前页面跳转 reLaunch关闭所有页面跳转 默认default
  14. */
  15. export const jump = (url, param, timeout = 0, type = "default") => {
  16. setTimeout(() => {
  17. if (param) {
  18. url = `${url}?detail=${encodeURIComponent((JSON.stringify(param))?.replace(/%/g, '%25'))}`
  19. }
  20. if (type === 'default') {
  21. uni.navigateTo({url})
  22. } else if (type === 'redirect') {
  23. uni.redirectTo({url})
  24. } else {
  25. uni.reLaunch({url})
  26. }
  27. }, timeout)
  28. }
  29. /**
  30. * 跳转到tabbar页面
  31. * @param url 路径
  32. * @param timeout 延时时间默认0
  33. */
  34. export const jumpToTabbar = (url, timeout = 0) => {
  35. setTimeout(() => {
  36. uni.switchTab({url})
  37. }, timeout)
  38. }
  39. /**
  40. * 关闭当前页面返回上一级或者多级页面
  41. * @param delta 级数默认1
  42. */
  43. export const goBack = (delta = 1) => {
  44. uni.navigateBack({delta})
  45. }
  46. /**
  47. * 获取跳转参数
  48. * @param loadParam
  49. * @return {{}|any}
  50. */
  51. export const getJumpParam = (loadParam) => {
  52. if (typeof loadParam === "object" && loadParam?.detail) {
  53. return JSON.parse(decodeURIComponent(loadParam.detail))
  54. }
  55. return {}
  56. }