提交 d60c93c1 作者: 毛细亚

更新代码

上级 87eea1a1
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>cebianlan</title><script src="./js/jweixin-1.2.0.js"></script><script src="./js/jwxwork-1.0.0.js"></script><script defer="defer" src="static/js/app.ff6fb11f.js"></script><link href="static/css/app.3ca40e10.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but cebianlan doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html> <!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>cebianlan</title><script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js" referrerpolicy="origin"></script><script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js" referrerpolicy="origin"></script><script defer="defer" src="static/js/app.ac946d78.js"></script><link href="static/css/app.9dbe61af.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but cebianlan doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</template> </template>
<script> <script>
import { getAuthUser } from '@/api/user' import { getAuthUser } from '@/api/user'
import {mapMutations} from 'vuex'
export default { export default {
name: 'App', name: 'App',
components: { components: {
...@@ -21,6 +22,7 @@ export default { ...@@ -21,6 +22,7 @@ export default {
}; };
}, },
methods: { methods: {
...mapMutations('user',['set_userInfo','set_userid']),
Authorize() { Authorize() {
// 先获取企微配置信息 // 先获取企微配置信息
let redirectUrl = location.origin + location.pathname; let redirectUrl = location.origin + location.pathname;
...@@ -42,12 +44,10 @@ export default { ...@@ -42,12 +44,10 @@ export default {
params.split('&').map(param => param.split('=')) params.split('&').map(param => param.split('='))
) )
const { code, corp_id } = paramsObj; const { code, corp_id } = paramsObj;
const userid = sessionStorage.getItem('userid'); if(code && corp_id){
if (!userid || userid === '') {
this.getWxUserInfo(code, corp_id); this.getWxUserInfo(code, corp_id);
} else { }else{
this.resolveAuth(); this.Authorize();
console.log('userid 存在')
} }
} else { } else {
this.Authorize(); this.Authorize();
...@@ -60,9 +60,9 @@ export default { ...@@ -60,9 +60,9 @@ export default {
getAuthUser({ code: authCode, corp_id: 'wweaefe716636df3d1' }).then((res) => { getAuthUser({ code: authCode, corp_id: 'wweaefe716636df3d1' }).then((res) => {
if (res.status_code === 1) { if (res.status_code === 1) {
let { userid } = res.data || {}; let { userid } = res.data || {};
if (userid) { if ( res.data && userid) {
sessionStorage.setItem('userid', userid); this.set_userInfo(res.data)
sessionStorage.setItem('userInfo', JSON.stringify(res.data)); this.set_userid(userid)
// 解析 Promise // 解析 Promise
this.resolveAuth(); this.resolveAuth();
} else { } else {
......
const state = { const state = {
userInfo:{
},
userid:''
} }
const mutations = { const mutations = {
set_userInfo(state,userInfo){
state.userInfo = userInfo
},
set_userid(state,userid){
state.userid = userid
}
} }
const actions = { const actions = {
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</template> </template>
<script> <script>
import {mapState, mapActions} from 'vuex'
export default { export default {
name: 'HomeView', name: 'HomeView',
inject: ['authPromise'], inject: ['authPromise'],
...@@ -12,6 +13,7 @@ export default { ...@@ -12,6 +13,7 @@ export default {
// 等待认证完成后执行 getAuthUser // 等待认证完成后执行 getAuthUser
this.authPromise.then(() => { this.authPromise.then(() => {
this.getAuthUser(); this.getAuthUser();
console.log('网页地址',window.location.href)
}); });
}, },
data() { data() {
...@@ -19,11 +21,11 @@ export default { ...@@ -19,11 +21,11 @@ export default {
} }
}, },
computed: {
...mapState('user', ['userInfo'])
},
methods: { methods: {
getAuthUser() { getAuthUser() {
console.log('getAuthUser')
this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'));
console.log(this.userInfo,'12313')
this.companyConfigInit() this.companyConfigInit()
}, },
//企业验证配置 //企业验证配置
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论