| 123456789101112131415161718192021222324252627282930313233343536 |
- <script>
- export default {
- onLaunch: function() {
- console.log('App Launch');
- interceptorInit();
- },
- onShow: function() {
- console.log('App Show')
- },
- onHide: function() {
- console.log('App Hide')
- }
- }
-
- /**
- * 拦截器初始化
- */
- const interceptorInit = () => {
- uni.addInterceptor('navigateTo', {
- invoke(data) {
- const token = uni.getStorageSync('token');
- if (!token) {
- uni.reLaunch({
- url: "/pages/login/login"
- });
- return false; // 阻止跳转
- }
- }
- });
- }
-
- </script>
- <style>
- /*每个页面公共css */
- </style>
|