Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
vite-integral
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 54d7604e
authored
Aug 11, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改
1 parent
c74e5704
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
src/utils/axios.ts
src/views/home/index.vue
src/utils/axios.ts
View file @
54d7604
...
...
@@ -84,7 +84,7 @@ service.interceptors.response.use(
// return logout(logout_function)
console
.
log
(
2
)
localStorage
.
removeItem
(
'sessionId'
)
router
.
push
(
'/log
ged
'
)
router
.
push
(
'/log
in
'
)
console
.
log
(
'session失效,登出'
,
useUserStore
().
getSession
)
}
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
...
...
src/views/home/index.vue
View file @
54d7604
...
...
@@ -74,8 +74,9 @@
<
script
lang=
"ts"
setup
>
import
{
ref
,
reactive
,
onBeforeMount
}
from
"vue"
;
import
{
useRouter
}
from
"vue-router"
;
import
req
from
"../../utils/request"
;
import
{
useRouter
}
from
"vue-router"
import
req
from
"../../utils/request"
import
{
Toast
}
from
'vant'
import
{
useUserStore
}
from
"../../store/user"
;
type
listStyle
=
{
id
?:
number
;
...
...
@@ -100,11 +101,20 @@ let id = ref<number>(0);
const
loading
=
ref
<
boolean
>
(
true
);
const
finished
=
ref
<
boolean
>
(
false
);
// 校验是否登录
const
hasSession
=
()
=>
{
console
.
log
(
userStore
.
getSession
)
const
sessionId
=
userStore
.
getSession
if
(
!
sessionId
)
Toast
(
'请先登录'
)
sessionId
?
getUserInfo
()
:
logout
()
}
const
getUserInfo
=
async
()
=>
{
const
res
=
await
req
(
'scrm.api.renewal.customer.h5.get'
)
data
.
userInfo
=
res
}
// 路由跳转,value:跳转页面路径
const
routerTo
=
(
value
:
string
)
=>
{
router
.
push
(
`/
${
value
}
`
)
...
...
@@ -113,8 +123,7 @@ const routerTo = (value: string) => {
// 登出
const
logout
=
()
=>
{
userStore
.
logout
();
router
.
push
(
"/logged"
);
// isLogin.value = false;
router
.
push
(
"/login"
);
};
// 下拉加载数据
...
...
@@ -138,11 +147,10 @@ const onLoad = (): void => {
}
});
};
// 组件挂载完成
onBeforeMount
(()
=>
{
onLoad
()
getUserInfo
()
hasSession
()
});
</
script
>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment