Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
肖康
/
iedgeMini
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3613d455
authored
Mar 19, 2025
by
LJM
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
恢复
parent
8518f187
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
82 deletions
App.vue
App.vue
View file @
3613d455
<
script
>
export
default
{
onLaunch
:
function
()
{
console
.
log
(
'App Launch'
)
this
.
loginCheck
()
export
default
{
onLaunch
:
function
()
{
console
.
log
(
'App Launch'
)
this
.
loginCheck
()
},
onShow
:
function
()
{
console
.
log
(
'App Show'
)
},
onHide
:
function
()
{
console
.
log
(
'App Hide'
)
},
methods
:
{
loginCheck
(){
try
{
uni
.
onAppRoute
((
res
)
=>
{
const
token
=
uni
.
getStorageSync
(
"token"
);
const
url
=
"/"
+
res
.
path
var
pages
=
getCurrentPages
();
// 获取栈实例
let
currentPage
=
pages
[
pages
.
length
-
1
];
// 获取当前页面实例
let
currentPath
=
currentPage
.
route
;
// 获取当前页面路由
let
currentPageFullPath
=
currentPage
[
'$page'
][
'fullPath'
];
// 当前页面路径
if
(
pages
.
length
>=
8
){
uni
.
reLaunch
({
url
:
currentPageFullPath
});
return
}
if
((
url
.
indexOf
(
"/user/"
)
!=
-
1
||
url
.
indexOf
(
"/car/confirm"
)
!=
-
1
)
&&
!
token
)
{
uni
.
reLaunch
({
url
:
`/pages/auth/login?referer=
${
encodeURIComponent
(
url
)}
`
});
return
false
;
}
})
}
catch
(
e
)
{
const
interceptors
=
[
"navigateTo"
,
"redirectTo"
,
"reLaunch"
,
"switchTab"
];
interceptors
.
forEach
((
method
)
=>
{
uni
.
addInterceptor
(
method
,
{
invoke
(
e
)
{
const
token
=
uni
.
getStorageSync
(
"token"
);
const
url
=
e
.
url
.
split
(
"?"
)[
0
];
// 获取路径部分
console
.
log
(
666
)
console
.
log
(
url
.
indexOf
(
"/user/"
)
!=
-
1
||
url
.
indexOf
(
"/car/confirm"
)
!=
-
1
)
if
((
url
.
indexOf
(
"/user/"
)
!=
-
1
||
url
.
indexOf
(
"/car/confirm"
)
!=
-
1
)
&&
!
token
)
{
uni
.
reLaunch
({
url
:
`/pages/auth/login?referer=
${
encodeURIComponent
(
e
.
url
)}
`
});
return
false
;
// 阻止原生跳转
}
}
});
});
}
}
},
onShow
:
function
()
{
console
.
log
(
'App Show'
)
},
onHide
:
function
()
{
console
.
log
(
'App Hide'
)
},
methods
:
{
loginCheck
()
{
debugger
try
{
uni
.
onAppRoute
((
res
)
=>
{
const
token
=
uni
.
getStorageSync
(
"token"
);
const
url
=
"/"
+
res
.
path
var
pages
=
getCurrentPages
();
// 获取栈实例
let
currentPage
=
pages
[
pages
.
length
-
1
];
// 获取当前页面实例
let
currentPath
=
currentPage
.
route
;
// 获取当前页面路由
let
currentPageFullPath
=
currentPage
[
'$page'
][
'fullPath'
];
// 当前页面路径
if
(
pages
.
length
>=
8
)
{
uni
.
reLaunch
({
url
:
currentPageFullPath
});
return
}
if
((
url
.
indexOf
(
"/user/"
)
!=
-
1
||
url
.
indexOf
(
"/car/confirm"
)
!=
-
1
)
&&
!
token
)
{
uni
.
reLaunch
({
url
:
`/pages/auth/login?referer=
${
encodeURIComponent
(
url
)}
`
});
return
false
;
}
})
}
catch
(
e
)
{
const
interceptors
=
[
"navigateTo"
,
"redirectTo"
,
"reLaunch"
,
"switchTab"
];
interceptors
.
forEach
((
method
)
=>
{
uni
.
addInterceptor
(
method
,
{
invoke
(
e
)
{
const
token
=
uni
.
getStorageSync
(
"token"
);
const
url
=
e
.
url
.
split
(
"?"
)[
0
];
// 获取路径部分
console
.
log
(
666
)
console
.
log
(
url
.
indexOf
(
"/user/"
)
!=
-
1
||
url
.
indexOf
(
"/car/confirm"
)
!=
-
1
)
if
((
url
.
indexOf
(
"/user/"
)
!=
-
1
||
url
.
indexOf
(
"/car/confirm"
)
!=
-
1
)
&&
!
token
)
{
uni
.
reLaunch
({
url
:
`/pages/auth/login?referer=
${
encodeURIComponent
(
e
.
url
)}
`
});
return
false
;
// 阻止原生跳转
}
}
});
});
}
}
}
}
}
}
</
script
>
<
style
>
/*每个页面公共css */
@import
'./assets/css/font/iconfont.css'
;
.img-style
{
max-width
:
100%
;
height
:
auto
;
display
:
block
;
margin
:
0
auto
;
}
#mobile
.mobile-header
{
background
:
red
!important
;
}
page
{
padding-top
:
175
rpx
;
}
/*每个页面公共css */
@import
'./assets/css/font/iconfont.css'
;
.img-style
{
max-width
:
100%
;
height
:
auto
;
display
:
block
;
margin
:
0
auto
;
}
#mobile
.mobile-header
{
background
:
red
!important
;
}
page
{
padding-top
:
175
rpx
;
}
/* #ifdef H5 */
page
{
padding-top
:
90
rpx
;
}
/* #ifdef H5 */
page
{
padding-top
:
90
rpx
;
}
/* #endif */
/* #endif */
</
style
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment