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 515588c8
authored
Aug 18, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改登出
1 parent
be6f74c6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
19 deletions
src/utils/http.ts
src/utils/request.ts
src/views/login/index.vue
src/utils/http.ts
View file @
515588c
import
axios
,
{
AxiosInstance
,
AxiosRequestConfig
,
AxiosResponse
,
AxiosError
}
from
'axios'
import
axios
,
{
AxiosInstance
,
AxiosRequestConfig
,
AxiosResponse
,
AxiosError
}
from
'axios'
import
{
Toast
}
from
'vant'
;
import
{
Toast
}
from
'vant'
;
import
router
from
'../router'
import
qs
from
'qs'
import
qs
from
'qs'
import
{
createSign
}
from
'./util'
import
{
createSign
}
from
'./util'
const
options
:
any
=
localStorage
.
getItem
(
'config'
)
const
options
:
any
=
localStorage
.
getItem
(
'config'
)
interface
Config
{
interface
Config
{
response
:
{
response
:
{
'code_key'
:
string
,
'code_key'
:
string
,
'code_success_value'
:
0
,
'code_success_value'
:
0
,
'data_key'
:
string
,
'data_key'
:
string
,
'errId_logout_value'
:
string
'errId_logout_value'
:
string
,
'errId'
?:
string
,
'code_error_value'
:
string
},
},
request
:
{
request
:
{
baseURL
:
string
baseURL
:
string
...
@@ -48,29 +48,35 @@ service.interceptors.request.use((config: AxiosRequestConfig) => {
...
@@ -48,29 +48,35 @@ service.interceptors.request.use((config: AxiosRequestConfig) => {
})
})
// 添加响应拦截器
// 添加响应拦截器
service
.
interceptors
.
response
.
use
((
r
)
=>
{
service
.
interceptors
.
response
.
use
((
r
:
AxiosResponse
)
=>
{
console
.
log
(
r
)
const
{
data
:
res
,
config
:
{
returnAll
}
}
=
r
const
{
data
:
res
,
config
:
{
returnAll
}
}
=
r
const
{
code_key
,
code_success_value
,
data_key
=
'data'
,
errId_logout_value
}
=
response
const
{
code_key
,
code_success_value
,
data_key
=
'data'
,
errId
=
'errId'
,
code_error_value
,
errId_logout_value
}
=
response
const
errId
=
'errId'
// if (returnAll) {
if
(
returnAll
)
{
// return res
return
res
// }
}
let
codekey
=
Array
.
isArray
(
code_key
)
?
code_key
.
find
(
key
=>
res
.
hasOwnProperty
(
key
))
:
code_key
let
codekey
=
Array
.
isArray
(
code_key
)
?
code_key
.
find
(
key
=>
res
.
hasOwnProperty
(
key
))
:
code_key
let
code
=
res
[
codekey
]
let
code
=
res
[
codekey
]
let
errValue
=
res
[
errId
]
let
errValue
=
res
[
errId
]
console
.
log
(
errValue
,
errId_logout_value
,
returnAll
)
// 特殊的code处理,可以增加
// 特殊的code处理,可以增加
switch
(
code
+
''
)
{
switch
(
code
+
''
)
{
case
code_success_value
+
''
:
case
code_success_value
+
''
:
if
(
returnAll
)
return
res
break
break
case
errId_logout_value
+
''
:
case
code_error_value
+
''
:
localStorage
.
removeItem
(
'sessionId'
)
console
.
log
(
11
,
errValue
&&
errValue
==
errId_logout_value
)
router
.
push
(
'/login'
)
break
default
:
if
(
errValue
&&
errValue
==
errId_logout_value
)
{
if
(
errValue
&&
errValue
==
errId_logout_value
)
{
localStorage
.
removeItem
(
'sessionId'
)
localStorage
.
removeItem
(
'sessionId'
)
router
.
replace
(
'/login'
)
location
.
replace
(
'/login'
)
}
}
Toast
(
res
.
message
)
break
default
:
// if (errValue && errValue == errId_logout_value) {
// localStorage.removeItem('sessionId')
// router.replace('/login')
// }
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
break
break
}
}
...
...
src/utils/request.ts
View file @
515588c
...
@@ -4,6 +4,7 @@ const PATH = 'rop-scrm-renewal/router'
...
@@ -4,6 +4,7 @@ const PATH = 'rop-scrm-renewal/router'
const
req
:
any
=
(
url
:
string
,
data
:
any
=
{},
returnAll
=
false
,
method
=
'POST'
,
)
=>
{
const
req
:
any
=
(
url
:
string
,
data
:
any
=
{},
returnAll
=
false
,
method
=
'POST'
,
)
=>
{
let
sessionId
=
useUserStore
().
getSession
let
sessionId
=
useUserStore
().
getSession
// let sessionId = '2dfdf8ff-fe50-4b07-bfd4-bdaec96ad717'
if
(
sessionId
)
data
.
loginSessionId
=
sessionId
if
(
sessionId
)
data
.
loginSessionId
=
sessionId
data
.
method
=
url
data
.
method
=
url
return
http
({
return
http
({
...
...
src/views/login/index.vue
View file @
515588c
...
@@ -52,7 +52,9 @@ let userForm = reactive({
...
@@ -52,7 +52,9 @@ let userForm = reactive({
// mobile: "17307427218",
// mobile: "17307427218",
// captcha: "8888",
// captcha: "8888",
});
});
let
timeout
:
number
|
undefined
=
undefined
;
// let timeout: number | undefined = undefined;
let
timeout
:
ReturnType
<
typeof
setInterval
>
// let timeout: NodeJS.Timer
const
time
=
ref
();
const
time
=
ref
();
watch
(
time
,
(
newVal
)
=>
{
watch
(
time
,
(
newVal
)
=>
{
if
(
newVal
==
0
)
{
if
(
newVal
==
0
)
{
...
@@ -102,9 +104,9 @@ const onSubmit = async (values: any) => {
...
@@ -102,9 +104,9 @@ const onSubmit = async (values: any) => {
}
}
};
};
onMounted
(()
=>
{
onMounted
(()
=>
{
if
(
route
.
query
)
{
//
if (route.query) {
userForm
=
Object
.
assign
(
userForm
,
route
.
query
)
//
userForm = Object.assign(userForm, route.query)
}
//
}
})
})
</
script
>
</
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