Commit 58da0b31 authored by 皮倩雯's avatar 皮倩雯

fix: '优化配置'

parent 77b109b9
Pipeline #77735 passed with stages
......@@ -4,18 +4,25 @@ import Iframe from 'react-iframe';
import { appService } from '@/api';
import Empty from '@wisdom-components/empty';
import axios from 'axios';
import { Spin, notification } from 'antd';
import { Message, Spin, notification } from 'antd';
import styles from './index.less';
const IntegratedLogin = props => {
const { sysName } = props.params;
const [linkUrl, setLinkUrl] = useState('');
const [loading, setLoading] = useState(false);
const ticketData = useRef();
const getTicket = () => {
appService.getTicketByToken({ token: window.globalConfig.token }).then(res => {
if (res.code === 0) {
return res.data;
ticketData.current = res.data;
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
});
};
......@@ -29,12 +36,14 @@ const IntegratedLogin = props => {
}
return false;
})
.catch(error => false);
.catch(error => {
return false;
});
};
const getUrlParam = url => {
let arrObj = url.split('?');
const params = Object.create(null);
let params = Object.create(null);
if (arrObj.length > 1) {
arrObj = arrObj[1].split('&');
arrObj.forEach(item => {
......@@ -46,78 +55,86 @@ const IntegratedLogin = props => {
};
const getSiteConfig = () => {
if (linkUrl) {
return;
}
let ticket = '';
setLoading(true);
appService.getIntegratedLoginbyName({ sysName }).then(res => {
if (res.code === 0) {
if (res.data.AccountParam[0].value === 1) {
ticket = getTicket();
}
const parma = res.data.AccountParam[0].value === 1 ? ticket : window.globalConfig.token;
if (res.data.siteType === 1) {
// 集成SaaS平台
const userId = window.globalConfig.userInfo.OID;
axios({
method: 'get',
url: `${window.location.origin}${res.data.serviceUrl}?userId=${userId}`,
}).then(resData => {
const url = resData.data.data;
if (res.data.target === 1) {
window.open(url);
} else {
setLinkUrl(url);
}
});
} else {
// 第三方接入
const pingState = ping;
let url = '';
// 外网通
if (pingState) {
if (res.data.InternetAddress) {
url = res.data.InternetAddress;
} else {
url = res.data.IntranetAddress;
}
appService
.getIntegratedLoginbyName({ sysName })
.then(res => {
if (res.code === 0) {
if (res.data.AccountParam[0].value === 1) {
ticket = ticketData.current;
}
const parma = res.data.AccountParam[0].value === 1 ? ticket : window.globalConfig.token;
if (res.data.siteType === 1) {
// 集成SaaS平台
const userId = window.globalConfig.userInfo.OID;
axios({
method: 'get',
url: `${window.location.origin}${res.data.serviceUrl}?userId=${userId}`,
}).then(resData => {
const url = resData.data.data;
if (res.data.target === 1) {
window.open(url);
} else {
setLinkUrl(url);
}
});
} else {
if (res.data.IntranetAddress) {
url = res.data.IntranetAddress;
// 第三方接入
const pingState = ping;
let url = '';
// 外网通
if (pingState) {
if (res.data.InternetAddress) {
url = res.data.InternetAddress;
} else {
url = res.data.IntranetAddress;
}
} else {
this.$message.error('请配置内网地址');
url = res.data.InternetAddress;
return;
if (res.data.IntranetAddress) {
url = res.data.IntranetAddress;
} else {
Message.error('请配置内网地址');
url = res.data.InternetAddress;
return;
}
}
}
if (url) {
const params = getUrlParam(url);
if (JSON.stringify(params) === '{}') {
url = `${url}?${res.data.AccountParam[0].key}=${parma}`;
} else {
url = `${url}&${res.data.AccountParam[0].key}=${parma}`;
if (url) {
const params = getUrlParam(url);
if (JSON.stringify(params) === '{}') {
url = `${url}?${res.data.AccountParam[0].key}=${parma}`;
} else {
url = `${url}&${res.data.AccountParam[0].key}=${parma}`;
}
}
}
if (res.data.target === 1) {
window.open(url);
} else {
setLinkUrl(url);
if (res.data.target === 1) {
window.open(url);
} else {
setLinkUrl(url);
}
}
setLoading(false);
} else {
setLoading(false);
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
setLoading(false);
} else {
setLoading(false);
notification.error({
message: '提交失败',
description: res.message,
});
}
});
})
.catch(error => {});
};
useEffect(() => {
getTicket();
getSiteConfig();
}, [getSiteConfig]);
}, []);
return (
<div className={styles.IntegratedLogin}>
......
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 to comment