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.
67 lines
1.6 KiB
67 lines
1.6 KiB
|
|
/**
|
|
* 页面跳转
|
|
* @author 深圳前海万联科技有限公司 <www.wanlshop.com>
|
|
*
|
|
* @param {Object} url 需要跳转的应用内非 tabBar 的页面的路径
|
|
* @param {Object} animationType 窗口显示的动画效果
|
|
* @param {Object} animationDuration 窗口动画持续时间,单位为 ms
|
|
*/
|
|
export const to = (url, animationType = 'pop-in', animationDuration = 300) => {
|
|
on(url);
|
|
};
|
|
|
|
/**
|
|
* 打开任意链接
|
|
* @author 深圳前海万联科技有限公司 <www.wanlshop.com>
|
|
*
|
|
* @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,
|
|
} |