多租户商城-商户小程序端
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

/**
* @FileDescription:
* @Author: kahu
* @Date: 2022/11/3
* @LastEditors: kahu
* @LastEditTime: 2022/11/3
*/
/**
* 跳转非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 {}
}