83 lines
1.5 KiB
JavaScript
83 lines
1.5 KiB
JavaScript
import config from '../config.js'
|
|
/*导航菜单白名单*/
|
|
const tabBarLinks = [
|
|
'/pages/index/index',
|
|
'/pages/member-area/index',
|
|
'/pages/cart/cart',
|
|
'/pages/user/index/index'
|
|
];
|
|
|
|
/*分享页面白名单*/
|
|
const shareLinks = []
|
|
|
|
/*
|
|
* 跳转页面
|
|
*/
|
|
export const gotopage = (url, type) => {
|
|
console.log(url,type)
|
|
if (!url || url.length == 0) {
|
|
return false;
|
|
}
|
|
console.log('gotopage',url)
|
|
if(url.substr(0,1)!=='/'){
|
|
url='/' + url;
|
|
}
|
|
let p = url;
|
|
if(url.indexOf('?') != -1){
|
|
p = url.substr(0, url.indexOf('?'));
|
|
// #ifdef H5
|
|
if(url.search("app_id") == -1){
|
|
url = url;
|
|
}
|
|
// #endif
|
|
}else{
|
|
// #ifdef H5
|
|
if(url.search("app_id") == -1){
|
|
url = url ;
|
|
}
|
|
// #endif
|
|
}
|
|
console.log('gotopage-p',p)
|
|
// 特殊账号拦截
|
|
let loginType = uni.getStorageSync('loginType');
|
|
if(loginType == 1){
|
|
if(url != '/pages/special/goods/index'){
|
|
console.log('loginType 特殊账号')
|
|
uni.reLaunch({
|
|
url: url
|
|
});
|
|
return
|
|
}
|
|
}
|
|
console.log('loginType 非特殊账号')
|
|
console.log('loginType 非特殊账号')
|
|
|
|
// tabBar页面
|
|
if (tabBarLinks.indexOf(p) > -1) {
|
|
console.log('tabBarLinks-reLaunch',url)
|
|
uni.reLaunch({
|
|
url: url
|
|
});
|
|
} else {
|
|
if(type == 'redirect'){
|
|
console.log('redirectTo',url)
|
|
uni.redirectTo({
|
|
url: url
|
|
});
|
|
return
|
|
}
|
|
if(type == 'reLaunch'){
|
|
console.log('reLaunch',url)
|
|
uni.reLaunch({
|
|
url: url
|
|
});
|
|
return
|
|
}
|
|
console.log('navigateTo',url)
|
|
// 普通页面
|
|
uni.navigateTo({
|
|
url: url
|
|
});
|
|
}
|
|
}
|