您的位置:首页 > 其它

ionic1 跳转至某个页面之前判断用户是否登录

2018-03-01 14:46 741 查看
在app.js文件中的run方法中使用如下代码:
var needLoginView = ['tab.account', 'tab.cart', 'tab.orders', 'dizhibu', 'idcard', 'youhuiquan', 'jifen'];
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams, options) {
if (needLoginView.indexOf(toState.name) > 0) {
if (Service.islogin() != true) {
$state.go('login');
$ionicViewSwitcher.nextDirection("forward");
}
}
});needLoginView数组存放需要检测的页面路由,当前操作是如果未登录就跳转登录页面。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐