Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
html
/
wanda-ball
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1f647aaf
authored
May 21, 2019
by
hank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
081ee4bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
12 deletions
+37
-12
src/modules/js/request.js
+10
-7
src/pages/index/App.vue
+2
-2
src/pages/index/index.js
+24
-2
src/pages/user/App.vue
+1
-1
No files found.
src/modules/js/request.js
View file @
1f647aaf
...
...
@@ -35,15 +35,15 @@ axios.interceptors.request.use(
// respone拦截器
axios
.
interceptors
.
response
.
use
(
response
=>
{
if
(
response
.
data
.
code
===
'0000'
||
response
.
data
.
code
===
'4010'
||
response
.
data
.
code
===
'1041'
)
{
if
(
response
.
data
.
code
===
'0000'
||
response
.
data
.
code
===
'4010'
||
response
.
data
.
code
===
0
)
{
// 1041 公司存在报错
return
response
}
else
{
response
.
status
=
400
Toast
({
message
:
response
.
data
.
m
essage
,
message
:
response
.
data
.
m
sg
,
position
:
'center'
,
duration
:
3
*
1000
duration
:
2
*
1000
})
return
Promise
.
reject
(
response
)
throw
new
Error
({
...
...
@@ -60,17 +60,20 @@ axios.interceptors.response.use(
*/
err
=>
{
if
(
err
&&
err
.
response
)
{
if
(
err
.
response
.
data
.
code
==
1001000
||
err
.
response
.
data
.
code
==
101
)
{
store
.
dispatch
(
'getAuth'
).
then
()
}
switch
(
err
.
response
.
status
)
{
case
400
:
err
.
message
=
`
${
err
.
response
.
data
.
m
essage
}
`
err
.
message
=
`
${
err
.
response
.
data
.
m
sg
}
`
break
case
401
:
err
.
message
=
`
${
err
.
response
.
data
.
m
essage
}
`
err
.
message
=
`
${
err
.
response
.
data
.
m
sg
}
`
break
case
403
:
err
.
message
=
`
${
err
.
response
.
data
.
m
essage
}
`
err
.
message
=
`
${
err
.
response
.
data
.
m
sg
}
`
break
case
404
:
...
...
@@ -78,7 +81,7 @@ axios.interceptors.response.use(
break
case
405
:
err
.
message
=
`方法错误:
${
err
.
response
.
data
.
m
essage
}
`
err
.
message
=
`方法错误:
${
err
.
response
.
data
.
m
sg
}
`
break
case
408
:
...
...
src/pages/index/App.vue
View file @
1f647aaf
...
...
@@ -50,7 +50,7 @@ export default {
if
(
localStorage
.
getItem
(
'token'
))
{
store
.
commit
(
'getUserInfo'
)
}
else
{
//
store.dispatch('getAuth').then()
store
.
dispatch
(
'getAuth'
).
then
()
}
if
(
this
.
getQuery
(
'code'
))
{
store
.
dispatch
(
'getToken'
,
this
.
getQuery
(
'code'
)).
then
()
...
...
@@ -82,7 +82,7 @@ export default {
var
theRequest
=
new
Object
();
if
(
url
.
indexOf
(
'?'
)
!=
-
1
)
{
var
str
=
url
.
substr
(
1
);
strs
=
str
.
split
(
'&'
);
var
strs
=
str
.
split
(
'&'
);
for
(
var
i
=
0
;
i
<
strs
.
length
;
i
++
)
{
theRequest
[
strs
[
i
].
split
(
'='
)[
0
]]
=
decodeURI
(
strs
[
i
].
split
(
'='
)[
1
]);
}
...
...
src/pages/index/index.js
View file @
1f647aaf
...
...
@@ -56,6 +56,22 @@ var _hmt = _hmt || [];
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
function
getQuery
(
key
)
{
var
url
=
location
.
search
;
//获取url中"?"符后的字串
var
theRequest
=
new
Object
();
if
(
url
.
indexOf
(
'?'
)
!=
-
1
)
{
var
str
=
url
.
substr
(
1
);
strs
=
str
.
split
(
'&'
);
for
(
var
i
=
0
;
i
<
strs
.
length
;
i
++
)
{
theRequest
[
strs
[
i
].
split
(
'='
)[
0
]]
=
decodeURI
(
strs
[
i
].
split
(
'='
)[
1
]);
}
}
if
(
key
)
{
return
theRequest
[
key
];
}
else
{
return
theRequest
;
}
}
const
list
=
[
'/'
,
'/detail'
,
'/imgup'
]
// 将需要切换效果的路由名称组成一个数组
const
toName
=
to
.
path
// 即将进入的路由名字
const
fromName
=
from
.
path
// 即将离开的路由名字
...
...
@@ -78,8 +94,14 @@ router.beforeEach((to, from, next) => {
_hmt
.
push
([
'_trackPageview'
,
'/#'
+
to
.
fullPath
]);
}
}
return
next
()
if
(
getQuery
(
'code'
)
&&
!
store
.
state
.
token
)
{
store
.
dispatch
(
'getToken'
,
getQuery
(
'code'
)).
then
(
res
=>
{
next
()
})
}
else
{
next
()
}
// return next()
})
...
...
src/pages/user/App.vue
View file @
1f647aaf
...
...
@@ -84,7 +84,7 @@ export default {
var
theRequest
=
new
Object
();
if
(
url
.
indexOf
(
'?'
)
!=
-
1
)
{
var
str
=
url
.
substr
(
1
);
strs
=
str
.
split
(
'&'
);
var
strs
=
str
.
split
(
'&'
);
for
(
var
i
=
0
;
i
<
strs
.
length
;
i
++
)
{
theRequest
[
strs
[
i
].
split
(
'='
)[
0
]]
=
decodeURI
(
strs
[
i
].
split
(
'='
)[
1
]);
}
...
...
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