| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <template>
-
- <div class="divClass">认证中...</div>
- </template>
- <script>
- import AuthSettingResource from '../api/commom/AuthSettingResource.js';
- export default {
- components: {
-
- },
- data: function () {
- return {
- appName: null,
- corpId: null,
- code: null,
- clientId: null, // 临时设置公司id,必须设置
- authSettingDto: undefined, //authSetting服务器配置信息
- isUniqueLoginModel: false, //唯一认证方式
- }
- },
-
- mounted: function () {
- this.getIsUniqueLoginModel();
- this.initData();
- },
-
- methods: {
- /**
- * 获取认证服务器数据
- * @author GuoZhiBo 20211026
- */
- getAuthSettingDto: function () {
- var _self = this;
- var redirect_uri = window.location.href;
- redirect_uri = redirect_uri.replace('#', '%23');
- var code = _self.getQueryVariable(redirect_uri);
- if (code == undefined) {
- AuthSettingResource.getAuthSettingDto().then(
- successData => {
- if (
- successData != null &&
- successData.defaultAccountLogin != true
- ) {
- _self.authSettingDto = successData;
- var url =
- _self.authSettingDto.authorizedWebsite +
- _self.authSettingDto.jaccountClientId +
- '&redirect_uri=' +
- redirect_uri;
- _self.authSettingDto.redirect_uri = redirect_uri;
- var authSettingDto = JSON.stringify(_self.authSettingDto);
- localStorage.setItem('#authSettingDto', authSettingDto);
- window.location.href = url;
- }
- },
- errorData => {
- Common.processException(errorData);
- },
- );
- } else {
- var authSettingDto_str = localStorage.getItem('#authSettingDto');
- if (authSettingDto_str != undefined) {
- var authSettingDto = JSON.parse(authSettingDto_str);
- _self.profileLogin(
- code,
- authSettingDto.redirect_uri,
- authSettingDto.jaccountClientId,
- authSettingDto.id,
- );
- }
- }
- },
- /**
- * 获取登录方式
- * @author GuoZhiBo 20211110
- */
- getIsUniqueLoginModel: function () {
- var _self = this;
- AuthSettingResource.getAuthSettingDto().then(
- successData => {
- if (successData != null) {
- console.log(successData);
- _self.isUniqueLoginModel = successData.isUniqueLoginModel;
- } else {
- _self.isUniqueLoginModel = undefined;
- }
- _self.loading=false;
- },
- errorData => {
- Common.processException(errorData);
- _self.loading=false;
- },
- );
- },
-
- /**
- * 获取url参数
- * @param {Object} name
- */
- getQueryVariable: function (obj) {
- var index = obj.indexOf('code=');
- if (index == -1) {
- return undefined;
- } else {
- return obj.substring(index + 5, obj.length);
- }
- },
- }
- }
- </script>
- <style scoped>
- .divClass {
- text-align: center;
- font-size: 30px;
- color: red;
- }
- </style>
|