Commit 4ac1d7f3 by hank

bug

parent c6504b13
......@@ -59,12 +59,17 @@ export default new Vuex.Store({
},
getUserInfo(state) {
return new Promise((resolve, reject) => {
axios.get('/contest/user/info').then(res => {
axios.get('/contest/user/info', {
headers: {
'accessToken': window.localStorage.getItem('token')
}
}).then(res => {
state.userInfo = res.data.data
localStorage.setItem('userInfo', JSON.stringify(res.data.data))
alert('获取用户信息成功')
resolve(res)
}).catch(e =>{
alert('获取用户信息失败')
reject(e)
})
})
......@@ -79,11 +84,16 @@ export default new Vuex.Store({
})
})
},
getToken({commit,state}){
getToken({commit,state}, code){
return new Promise((resolve, reject) => {
axios.get('weixin/callback').then(res => {
window.localStorage.setItem('callbackurl', location.href)
location.href = res.data.data.url + '/video/2.html'
axios.get('weixin/callback', {
params : {
code
}
}).then(res => {
window.localStorage.setItem('token', res.data.data.accessToken)
// location.href = res.data.data.url + '/video/2.html'
commit('getUserInfo')
})
})
}
......
......@@ -42,15 +42,19 @@ export default {
},
created() {
this.hiddenBar();
if(localStorage.getItem('token')) {
} else {
store.dispatch('getAuth')
}
// 请求入围信息,提前加载入围的信息防止入围公告闪烁
store.commit('getRuweiInfo');
},
mounted() {
if(localStorage.getItem('token')) {
store.commit('getUserInfo')
} else {
store.dispatch('getAuth').then()
}
if(this.$route.query.code) {
store.dispatch('getToken', this.$route.query.code).then()
}
var tar_userinfo = localStorage.getItem('tar_userinfo');
console.log(tar)
if (tar_userinfo) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment