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

fix: '优化配置'

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