1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * 跳转非tabbar页面
- * @param url 路径
- * @param param 参数对象
- * @param timeout 延时时间,默认0
- * @param type default普通跳转 redirect关闭当前页面跳转 reLaunch关闭所有页面跳转 默认default
- */
- export const jump = (url, param, timeout = 0, type = 'default') => {
- setTimeout(() => {
- if (param) {
- url = `${url}?detail=${encodeURIComponent(JSON.stringify(param)?.replace(/%/g, '%25'))}`
- }
- if (type === 'default') {
- uni.navigateTo({ url })
- } else if (type === 'redirect') {
- uni.redirectTo({ url })
- } else {
- uni.reLaunch({ url })
- }
- }, timeout)
- }
- /**
- * 跳转到tabbar页面
- * @param url 路径
- * @param timeout 延时时间,默认0
- */
- export const jumpToTabbar = (url, timeout = 0) => {
- setTimeout(() => {
- uni.switchTab({ url })
- }, timeout)
- }
- /**
- * 关闭当前页面,返回上一级或者多级页面
- * @param delta 级数,默认1
- */
- export const goBack = (delta = 1) => {
- uni.navigateBack({ delta })
- }
- /**
- * 获取跳转参数
- * @param loadParam
- * @return {{}|any}
- */
- export const getJumpParam = (loadParam) => {
- if (typeof loadParam === 'object' && loadParam?.detail) {
- return JSON.parse(decodeURIComponent(loadParam.detail))
- }
- return {}
- }
|