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
d9bc19fd
authored
May 21, 2019
by
hank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token 认证失败
parent
1f647aaf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
30 deletions
+54
-30
src/modules/js/api.js
+3
-3
src/modules/js/request.js
+2
-1
src/modules/store/index.js
+5
-3
src/pages/index/App.vue
+1
-1
src/pages/index/index.js
+2
-2
src/pages/user/user.html
+1
-1
src/pages/user/user.js
+40
-19
No files found.
src/modules/js/api.js
View file @
d9bc19fd
...
...
@@ -29,10 +29,10 @@ var extra = '7';
var
wrapHref
=
(
mode
===
'development'
?
'http://web-comment.iyunfish.cn'
:
'http://wanda-qj.maxrocky.com'
)
+
'/relay/contest/h5/7'
;
//首页地址
var
indexHref
=
url
+
weburl
+
'/7
'
;
var
indexHref
=
url
+
'/video/index.html
'
;
// 个人中心地址
var
userCenterHref
=
url
+
weburl
+
'/newuser/7
'
;
var
shareImg
=
url
+
weburl
+
'/static/share.jpg'
;
var
userCenterHref
=
url
+
'/video/user.html
'
;
var
shareImg
=
url
+
'/static/share.jpg'
;
var
signHref
=
'http://mr-static.maxrocky.com/h5/wanda/dzgp/index.html'
export
default
{
server
,
...
...
src/modules/js/request.js
View file @
d9bc19fd
...
...
@@ -13,6 +13,7 @@ axios.interceptors.request.use(
config
=>
{
// Do something before request is sent
// console.log(config.url)
// console.log(store.state.token, 'accessToken')
if
(
store
.
state
.
token
)
{
config
.
headers
[
'accessToken'
]
=
store
.
state
.
token
// 让每个请求携带token--['ticket']为自定义key 请根据实际情况自行修改
}
...
...
@@ -60,7 +61,7 @@ axios.interceptors.response.use(
*/
err
=>
{
if
(
err
&&
err
.
response
)
{
if
(
err
.
response
.
data
.
code
==
100100
0
||
err
.
response
.
data
.
code
==
101
)
{
if
(
err
.
response
.
data
.
code
==
100100
||
err
.
response
.
data
.
code
==
100
101
)
{
store
.
dispatch
(
'getAuth'
).
then
()
}
switch
(
err
.
response
.
status
)
{
...
...
src/modules/store/index.js
View file @
d9bc19fd
...
...
@@ -62,7 +62,7 @@ export default new Vuex.Store({
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
'/contest/user/info'
,
{
headers
:
{
'accessToken'
:
window
.
localStorage
.
getItem
(
'token'
)
'accessToken'
:
state
.
token
}
}).
then
(
res
=>
{
state
.
userInfo
=
res
.
data
.
data
...
...
@@ -78,6 +78,7 @@ export default new Vuex.Store({
},
actions
:
{
getAuth
({
commit
,
state
})
{
window
.
localStorage
.
removeItem
(
'token'
)
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
'/weixin/info'
).
then
(
res
=>
{
window
.
localStorage
.
setItem
(
'callbackurl'
,
location
.
href
)
...
...
@@ -87,9 +88,10 @@ export default new Vuex.Store({
},
getToken
({
commit
,
state
},
code
){
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
'weixin/callback'
,
{
axios
.
get
(
'
/
weixin/callback'
,
{
params
:
{
code
code
,
type
:
1
}
}).
then
(
res
=>
{
window
.
localStorage
.
setItem
(
'token'
,
res
.
data
.
data
.
accessToken
)
...
...
src/pages/index/App.vue
View file @
d9bc19fd
...
...
@@ -44,7 +44,7 @@ export default {
this
.
hiddenBar
();
// 请求入围信息,提前加载入围的信息防止入围公告闪烁
store
.
commit
(
'getRuweiInfo'
);
//
store.commit('getRuweiInfo');
},
mounted
()
{
if
(
localStorage
.
getItem
(
'token'
))
{
...
...
src/pages/index/index.js
View file @
d9bc19fd
...
...
@@ -20,7 +20,7 @@ axios.defaults.baseURL = api.server;
axios
.
defaults
.
timeout
=
10000
;
// axios.defaults.headers.common['systemtype'] = api.extra;
import
'@/modules/js/request'
import
'@/modules/js/request
.js
'
import
fastclick
from
'fastclick'
fastclick
.
attach
(
document
.
body
)
...
...
@@ -61,7 +61,7 @@ router.beforeEach((to, from, next) => {
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/user/user.html
View file @
d9bc19fd
...
...
@@ -5,7 +5,7 @@
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
>
<title>
云上丹寨 摄影月赛
</title>
<script
type=
"text/javascript"
src=
"http://js.tarsocial.com/h5stat-2.1.1.vue.js"
></script>
<script
type=
"text/javascript"
src=
"http
s
://js.tarsocial.com/h5stat-2.1.1.vue.js"
></script>
</head>
<body>
...
...
src/pages/user/user.js
View file @
d9bc19fd
...
...
@@ -13,6 +13,7 @@ import '@/modules/js/flexible.js';
import
axios
from
'axios'
;
import
api
from
'@/modules/js/api.js'
;
axios
.
defaults
.
baseURL
=
api
.
server
;
import
'@/modules/js/request.js'
// api 拦截器
// axios.defaults.headers.common['systemtype'] = api.extra;
...
...
@@ -24,8 +25,6 @@ window.$eventbus = new Vue();
// import store from './store';
import
store
from
'../../modules/store'
;
var
_hmt
=
_hmt
||
[];
(
function
()
{
var
hm
=
document
.
createElement
(
"script"
);
...
...
@@ -35,42 +34,64 @@ var _hmt = _hmt || [];
})();
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
const
list
=
[
'/'
,
'/detail'
,
'/address'
]
// 将需要切换效果的路由名称组成一个数组
const
toName
=
to
.
path
// 即将进入的路由名字
const
fromName
=
from
.
path
// 即将离开的路由名字
const
toIndex
=
list
.
indexOf
(
toName
)
// 进入下标
const
fromIndex
=
list
.
indexOf
(
fromName
)
// 离开下标
function
getQuery
(
key
)
{
var
url
=
location
.
search
;
//获取url中"?"符后的字串
var
theRequest
=
new
Object
();
if
(
url
.
indexOf
(
'?'
)
!=
-
1
)
{
var
str
=
url
.
substr
(
1
);
var
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
// 即将离开的路由名字
const
toIndex
=
list
.
indexOf
(
toName
)
// 进入下标
const
fromIndex
=
list
.
indexOf
(
fromName
)
// 离开下标
let
direction
=
''
if
(
toIndex
>
-
1
&&
fromIndex
>
-
1
)
{
// 如果下标都存在
if
(
toIndex
<
fromIndex
)
{
// 如果进入的下标小于离开的下标,那么是左滑
if
(
toIndex
>
-
1
&&
fromIndex
>
-
1
)
{
// 如果下标都存在
if
(
toIndex
<
fromIndex
)
{
// 如果进入的下标小于离开的下标,那么是左滑
direction
=
'left'
}
else
{
direction
=
'right'
// 如果进入的下标大于离开的下标,那么是右滑
direction
=
'right'
// 如果进入的下标大于离开的下标,那么是右滑
}
}
store
.
state
.
viewDirection
=
direction
//这里使用vuex进行赋值
store
.
state
.
viewDirection
=
direction
//这里使用vuex进行赋值
if
(
_hmt
)
{
if
(
to
.
path
)
{
_hmt
.
push
([
'_trackPageview'
,
'/#'
+
to
.
fullPath
]);
_hmt
.
push
([
'_trackPageview'
,
'/#'
+
to
.
fullPath
]);
}
}
return
next
()
if
(
getQuery
(
'code'
)
&&
!
store
.
state
.
token
)
{
store
.
dispatch
(
'getToken'
,
getQuery
(
'code'
)).
then
(
res
=>
{
next
()
})
}
else
{
next
()
}
})
Vue
.
prototype
.
$randomText
=
function
()
{
Vue
.
prototype
.
$randomText
=
function
()
{
function
RandomNumBoth
(
Min
,
Max
)
{
var
Range
=
Max
-
Min
;
var
Rand
=
Math
.
random
();
var
num
=
Min
+
Math
.
round
(
Rand
*
Range
);
var
num
=
Min
+
Math
.
round
(
Rand
*
Range
);
return
num
;
}
var
num
=
RandomNumBoth
(
1
,
11
);
var
num
=
RandomNumBoth
(
1
,
11
);
var
str
=
null
;
switch
(
num
)
{
case
2
:
...
...
@@ -92,7 +113,7 @@ Vue.prototype.$randomText = function() {
str
=
'每月评奖,金奖1万元!'
;
break
;
}
return
str
;
}
...
...
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