Commit 4ac1d7f3 by hank

bug

parent c6504b13
...@@ -59,12 +59,17 @@ export default new Vuex.Store({ ...@@ -59,12 +59,17 @@ export default new Vuex.Store({
}, },
getUserInfo(state) { getUserInfo(state) {
return new Promise((resolve, reject) => { 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 state.userInfo = res.data.data
localStorage.setItem('userInfo', JSON.stringify(res.data.data)) localStorage.setItem('userInfo', JSON.stringify(res.data.data))
alert('获取用户信息成功') alert('获取用户信息成功')
resolve(res) resolve(res)
}).catch(e =>{ }).catch(e =>{
alert('获取用户信息失败')
reject(e) reject(e)
}) })
}) })
...@@ -79,11 +84,16 @@ export default new Vuex.Store({ ...@@ -79,11 +84,16 @@ export default new Vuex.Store({
}) })
}) })
}, },
getToken({commit,state}){ getToken({commit,state}, code){
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.get('weixin/callback').then(res => { axios.get('weixin/callback', {
window.localStorage.setItem('callbackurl', location.href) params : {
location.href = res.data.data.url + '/video/2.html' 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 { ...@@ -42,15 +42,19 @@ export default {
}, },
created() { created() {
this.hiddenBar(); this.hiddenBar();
if(localStorage.getItem('token')) {
} else {
store.dispatch('getAuth')
}
// 请求入围信息,提前加载入围的信息防止入围公告闪烁 // 请求入围信息,提前加载入围的信息防止入围公告闪烁
store.commit('getRuweiInfo'); store.commit('getRuweiInfo');
}, },
mounted() { 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'); var tar_userinfo = localStorage.getItem('tar_userinfo');
console.log(tar) console.log(tar)
if (tar_userinfo) { 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