第三方登录增加组织选择

This commit is contained in:
fan 2023-05-05 09:32:34 +08:00
parent 210a7d0fdd
commit e353289594

View File

@ -3,18 +3,24 @@
<div class="thirdLoginMessage"> <div class="thirdLoginMessage">
{{ message }} {{ message }}
</div> </div>
<org-select ref="orgSelect" @select="selectOrg" />
</div> </div>
</template> </template>
<script> <script>
import { LoginParams } from '@/utils/login'; import { LoginParams } from '@/utils/login';
import { getOrgList, selectOrgnization } from '@/api/login';
import { thirdCountLogin } from '@/api/management/user'; import { thirdCountLogin } from '@/api/management/user';
import md5 from 'js-md5'; import md5 from 'js-md5';
import { setToken, getToken } from '@/utils/auth'; import { setToken, getToken } from '@/utils/auth';
import OrgSelect from '../login/orgSelect';
// , ProjectLoginStyleList, VersionBaseNoShow, MainBodyNoShow, NoQrcodeList, localPackageProject, RegisterCodeList // , ProjectLoginStyleList, VersionBaseNoShow, MainBodyNoShow, NoQrcodeList, localPackageProject, RegisterCodeList
// import { loginInfo, ProjectIcon } from '@/scripts/ProjectConfig'; // import { loginInfo, ProjectIcon } from '@/scripts/ProjectConfig';
export default { export default {
name:'ThirdLogin', name:'ThirdLogin',
components: {
OrgSelect
},
data() { data() {
return { return {
message:'' message:''
@ -52,7 +58,8 @@ export default {
const header = { group: '', 'X-Token': tokenKey }; const header = { group: '', 'X-Token': tokenKey };
this.$store.dispatch('setToken', tokenKey); this.$store.dispatch('setToken', tokenKey);
this.$store.dispatch('subscribe', {header, type:'class'}); this.$store.dispatch('subscribe', {header, type:'class'});
this.$router.replace({path:'/trainingPlatform'}); // this.$router.replace({path:'/trainingPlatform'});
this.checkOrgnizationInfo();
} else { } else {
thirdCountLogin(model).then(resp=> { thirdCountLogin(model).then(resp=> {
const token = resp.data; const token = resp.data;
@ -60,8 +67,7 @@ export default {
setToken(token); setToken(token);
this.$store.dispatch('setToken', token); this.$store.dispatch('setToken', token);
this.$store.dispatch('subscribe', {header, type:'class'}); this.$store.dispatch('subscribe', {header, type:'class'});
this.$router.replace({path:'/trainingPlatform'}); this.checkOrgnizationInfo();
// setSessionStorage('thirdLogin', true);
}).catch(() => { }).catch(() => {
this.message = '参数有误,请检查'; this.message = '参数有误,请检查';
}); });
@ -72,7 +78,35 @@ export default {
} }
}, },
methods:{ methods:{
selectOrg(orgId) {
selectOrgnization(orgId).then(() => { //
this.$router.replace({path:'/trainingPlatform'});
}).catch(err => {
this.$message.error(`登入组织失败!,${err.message}`);
});
},
checkOrgnizationInfo() {
getOrgList().then(resp => {
const orgList = resp.data;
let orgId = '';
if (orgList.length < 2) {
if (orgList.length === 1) {
orgId = orgList[0].orgId;
selectOrgnization(orgId).then(() => { //
this.$router.replace({path:'/trainingPlatform'});
}).catch(err => {
this.$message.error(`登入组织失败!,${err.message}`);
});
} else {
this.$router.replace({path:'/trainingPlatform'});
}
} else {
this.$refs.orgSelect.doShow(orgList);
}
}).catch((error)=>{
this.$message.error(error.message);
});
}
} }
}; };
</script> </script>