/** * 页面跳转 * @author 深圳前海万联科技有限公司 * * @param {Object} url 需要跳转的应用内非 tabBar 的页面的路径 * @param {Object} animationType 窗口显示的动画效果 * @param {Object} animationDuration 窗口动画持续时间,单位为 ms */ export const to = (url, animationType = 'pop-in', animationDuration = 300) => { on(url); }; /** * 打开任意链接 * @author 深圳前海万联科技有限公司 * * @param {Object} url 页面地址 */ export const on = (url, replace = false, reLaunch = false) => { // url = decodeURIComponent(url); console.log('onnnnn', url); if (url.indexOf('pages') === 0) { url = `/${url}`; } if (!/^\/?pages/.test(url) && url.indexOf('./') === -1) { url = `./${url}`; } // const in_tabar = PAGES_JSON.tabBar.list.find((v, idx, obj) => { // return url.replace('/pages', 'pages') == v.pagePath; // }); // 关闭所有页面,跳转链接 console.log(in_tabar, url); const in_tabar =false if (in_tabar) { uni.switchTab({ url: url, }); } else { const animationType = 'pop-in'; const animationDuration = 300; let param = { url, animationType, animationDuration, success: function (res) { // wanlshop_config.debug ? console.log(res) : ''; }, fail: function (e) { // wanlshop_config.debug ? console.log(e) : ''; }, }; if (replace) { uni.redirectTo(param); } else if (reLaunch) { uni.reLaunch(param); } else { uni.navigateTo(param); } } }; export default { to, on, }