第三方登录增加组织选择

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">
{{ message }}
</div>
<org-select ref="orgSelect" @select="selectOrg" />
</div>
</template>
<script>
import { LoginParams } from '@/utils/login';
import { getOrgList, selectOrgnization } from '@/api/login';
import { thirdCountLogin } from '@/api/management/user';
import md5 from 'js-md5';
import { setToken, getToken } from '@/utils/auth';
import OrgSelect from '../login/orgSelect';
// , ProjectLoginStyleList, VersionBaseNoShow, MainBodyNoShow, NoQrcodeList, localPackageProject, RegisterCodeList
// import { loginInfo, ProjectIcon } from '@/scripts/ProjectConfig';
export default {
name:'ThirdLogin',
components: {
OrgSelect
},
data() {
return {
message:''
@ -52,7 +58,8 @@ export default {
const header = { group: '', 'X-Token': tokenKey };
this.$store.dispatch('setToken', tokenKey);
this.$store.dispatch('subscribe', {header, type:'class'});
this.$router.replace({path:'/trainingPlatform'});
// this.$router.replace({path:'/trainingPlatform'});
this.checkOrgnizationInfo();
} else {
thirdCountLogin(model).then(resp=> {
const token = resp.data;
@ -60,8 +67,7 @@ export default {
setToken(token);
this.$store.dispatch('setToken', token);
this.$store.dispatch('subscribe', {header, type:'class'});
this.$router.replace({path:'/trainingPlatform'});
// setSessionStorage('thirdLogin', true);
this.checkOrgnizationInfo();
}).catch(() => {
this.message = '参数有误,请检查';
});
@ -72,7 +78,35 @@ export default {
}
},
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>