Commit 59e1d5b2 authored by 陶晶晶's avatar 陶晶晶

feat:爱众集成登录页开发

parent f1f00349
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -17,6 +17,7 @@ import MilePage from './project/mile'; ...@@ -17,6 +17,7 @@ import MilePage from './project/mile';
import DongyingPage from './project/dongying'; import DongyingPage from './project/dongying';
import QinzhouPage from './project/qinzhou'; import QinzhouPage from './project/qinzhou';
import WuliangyePage from './project/wuliangye'; import WuliangyePage from './project/wuliangye';
import AizhongPage from './project/aizhong';
import JianshiPage from './project/jianshi'; import JianshiPage from './project/jianshi';
import XinyuanPage from './project/xinyuan'; import XinyuanPage from './project/xinyuan';
import SuzhouPage from './project/suzhou'; import SuzhouPage from './project/suzhou';
...@@ -78,6 +79,11 @@ export const guidePage = [ ...@@ -78,6 +79,11 @@ export const guidePage = [
value: 'wulaingyePage', value: 'wulaingyePage',
previewSrc: require('@/assets/images/integration/previewImg/五粮液.png'), previewSrc: require('@/assets/images/integration/previewImg/五粮液.png'),
}, },
{
label: '爱众液集成登录',
value: 'aizhongPage',
previewSrc: require('@/assets/images/integration/previewImg/五粮液.png'),
},
{ {
label: '建始集成登录', label: '建始集成登录',
value: 'jianshiPage', value: 'jianshiPage',
...@@ -120,5 +126,6 @@ export const BootPageTemplate = { ...@@ -120,5 +126,6 @@ export const BootPageTemplate = {
jianshiPage: JianshiPage, jianshiPage: JianshiPage,
xinyuanPage: XinyuanPage, xinyuanPage: XinyuanPage,
wulaingyePage: WuliangyePage, wulaingyePage: WuliangyePage,
aizhongPage: AizhongPage,
suzhouPage: SuzhouPage, suzhouPage: SuzhouPage,
}; };
/* eslint-disable prettier/prettier */
import Icon1 from "@/assets/images/integration/aizhong/二次供水管理系统.png";
import Icon2 from "@/assets/images/integration/aizhong/无人化泵站管理系统.png";
import Icon3 from "@/assets/images/integration/aizhong/水厂生成运维系统.png";
import Icon9 from "@/assets/images/integration/aizhong/物联接入.png";
import Icon10 from "@/assets/images/integration/aizhong/视频接入.png";
import Icon11 from "@/assets/images/integration/aizhong/运营管理.png";
import Icon12 from "@/assets/images/integration/aizhong/web组态.png";
import Icon13 from "@/assets/images/integration/aizhong/报表搭建.png";
export default {
modalConfig: [
{ name: '二次供水管理系统', bgImg: Icon1, style: { width: 498, height: 251 } },
{ name: '无人化泵站管理系统', bgImg: Icon2, style: { width: 606, height: 251 } },
{ name: '水厂生产运维系统', bgImg: Icon3, style: { width: 498, height: 251 } },
],
BIConfig: [
{ name: '物联接入', icon: Icon9 },
{ name: '视频接入', icon: Icon10 },
{ name: '运维管理', icon: Icon11 },
{ name: 'Web组态', icon: Icon12 },
{ name: '报表搭建', icon: Icon13 },
{ name: '', },
]
}
\ No newline at end of file
/* eslint-disable import/no-unresolved */
/* eslint-disable indent */
/* eslint-disable react/jsx-first-prop-new-line */
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable prettier/prettier */
import { appService } from '@/api';
import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons';
import { message, Button } from 'antd';
import classNames from 'classnames';
import { debounce } from 'lodash';
import { searchUrl } from '@/utils/utils';
import React, { useRef, useEffect, useState, useMemo } from 'react';
import backImg from '@/assets/images/demonstration/返回.png';
import arrowLeftImg from '@/assets/images/demonstration/左箭头.png';
import LoadPage from '@/components/LoadPage';
import { connect } from 'react-redux';
import { actionCreators } from '@/containers/App/store';
import { getWebSiteConfig } from '@/api/service/base';
import axios from 'axios';
import { useHistory, useAliveController } from '@wisdom-utils/runtime';
import Cookies from 'js-cookie';
import { store } from '@wisdom-utils/utils';
import LoginAction from '@/pages/user/login/login';
import { defaultApp } from '@/micro';
import useFullScreen from '../../demonstration/components/useFullScreen';
import styles from './index.less';
import BGIcon from "@/assets/images/integration/aizhong/爱众背景.png";
import reback from "@/assets/images/integration/aizhong/返回.png";
import pageConfig from "./config";
import moment from 'moment';
const { modalConfig, BIConfig } = pageConfig
const boxWidth = 1663;
const boxHeight = 930;
const IntegrationQinzhou = props => {
const integratedConfig = props.integratedConfig?.toObject
? props.integratedConfig.toObject()
: props.integratedConfig || {};
const [ref, isFullscreen, handleFullScreen, handleExitFullScreen] = useFullScreen(false);
const clientRef = useRef(props.global.client);
const integrationClient = integratedConfig?.client || window?.globalConfig?.client || 'city'; // 集成登录client
const [integrationData, setIntegrationData] = useState(JSON.parse(localStorage.getItem('integrationData')) || {}); // 所有子站
const loadingTime = integratedConfig?.loadingTime || 5;
const history = useHistory();
const { clear } = useAliveController();
const timer2 = useRef(null);
const timer3 = useRef(null);
const backRef = useRef(null);
const timeRef = useRef(null);
const progressRef2 = useRef(0);
const [boxSize, setBoxSize] = useState({
scale: 1,
boxHeight: 930,
});
const [jumpLoading, setJumpLoading] = useState(false);
const [progressValue2, setProgressValue2] = useState(0);
const [loginAction, setAction] = useState(() => new LoginAction(props));
const [currentTime, setCurrentTime] = useState(moment().format('YYYY-MM-DD HH:mm:ss'))
const jumpProgressStart = () => {
if (timer2.current) {
clearInterval(timer2.current);
timer2.current = null;
}
progressRef2.current = 0;
setProgressValue2(0);
timer2.current = setInterval(() => {
if (progressRef2.current < 97.5) {
progressRef2.current += 2.5;
setProgressValue2(progressRef2.current);
} else {
setProgressValue2(99);
timer2.current && clearInterval(timer2.current);
timer2.current = null;
}
}, 100);
};
const jumpProgressEnd = () => {
setProgressValue2(100);
timer2.current && clearInterval(timer2.current);
timer2.current = null;
};
const getData = async () => {
const client = integratedConfig?.client || sessionStorage.getItem('client') || props?.global?.client || '';
localStorage.setItem('integrationClient', client);
appService
.GetIntegrationConfig({
type: '集成登录',
userId: window.globalConfig.userInfo?.OID ?? null,
isEnable: true,
client,
})
.then(res1 => {
const list = res1.data || [];
const obj = {};
list.forEach(i => {
obj[i.name] = i;
});
list.length && localStorage.setItem('integrationData', JSON.stringify(obj));
setIntegrationData(obj);
});
};
const onResize = () => {
if (ref?.current) {
const { clientWidth, clientHeight } = ref.current;
if (!boxWidth || !boxHeight) return;
const xScale = clientWidth / boxWidth;
const yScale = clientHeight / boxHeight;
const poor = clientHeight / clientWidth - boxHeight / boxWidth;
let n = Math.min(xScale, yScale);
let bHeight = boxHeight;
if (poor > 0.05) {
bHeight = boxHeight + 30;
}
// 高度为偶数
bHeight = parseInt(bHeight, 10);
if (bHeight % 2 !== 0) {
bHeight += 1;
}
n = Number(n.toFixed(4));
setBoxSize({
scale: n,
boxHeight: bHeight,
});
}
};
const startTiming = (time = 2) => {
if (timer3.current) {
clearInterval(timer3.current);
timer3.current = null;
}
timer3.current = setTimeout(() => {
setJumpLoading(false);
timer2.current && clearInterval(timer2.current);
timer2.current = null;
}, time * 1000);
};
const toRevenue = async item => {
setJumpLoading(true);
jumpProgressStart();
startTiming(6);
try {
const res = await appService.getTicketByToken({ token: window.globalConfig?.token });
if (res.code === 0) {
// 营收是api-bcs,直饮水是api-ddw
// /api-ddw/sysUser/ssoGCK
// res.data = 'e44a2883a2ac4c4b8c8f1186cf27ca1dcc406c1dda1247cabe04bff3c06d28e7'; // 测试token
const apiPath = `${item.url + (item.url.indexOf('?') > 0 ? '&' : '?') + item.paramValue}=${res.data}`;
if (item?.openOpt === '当前页打开') {
props.history.push('/thirdParty', { linkUrl: apiPath });
} else {
setJumpLoading(false);
jumpProgressEnd();
window.open(apiPath, '_blank');
}
} else {
res.msg && message.error(res.msg);
setJumpLoading(false);
jumpProgressEnd();
}
} catch (error) {
setJumpLoading(false);
jumpProgressEnd();
}
};
const toClient = async (item, loginA) => {
const token = props.global?.token || Cookies.get('token');
const cli = item.client;
const res = await getWebSiteConfig({
identity: token,
client: cli,
});
if (!res?.data?.[0]?.widgets?.length) {
message.error({
duration: 3,
content: '您没有该板块权限,请联系管理员',
});
return;
}
if (window.qiankunIsCache) {
store.set('event:dropCache');
}
Cookies.set('client', cli, {
expires: 86400000 / (24 * 60 * 60 * 1000),
path: '/',
});
sessionStorage.setItem('client', cli);
const currentProduct = `__global__recent_productIndex__micro_${window.location.hostname}_${window.globalConfig
?.client ?? 'city'}`;
sessionStorage.removeItem(currentProduct);
const currentProductNew = `__global__recent_productIndex__micro_${window.location.hostname}_${cli || 'city'}`;
sessionStorage.setItem(currentProductNew, 0);
// 用全局存跳转信息,跳转过程页面会刷新
window.clientInfo = item;
clientRef.current = cli;
const config = props.global;
config.uiwidgets = [];
config.widgets = [];
config.allWidgets = [];
window.qiankunStarted = false;
if (cli) {
config.client = cli;
}
setJumpLoading(true);
jumpProgressStart();
startTiming(loadingTime);
window.jumpLoadingProgress = 99;
loginA && loginA.getUserInfoAndConfig('', true, item.type);
};
const onLink = (item, loginA) => {
if (!item) return;
if (window.clientInfo) {
window.clientInfo = null;
}
const token = props.global?.token || Cookies.get('token');
if (!token) {
history.push(`/user/login?client=${integrationClient}`, { reload: true });
clear();
props.logout();
return;
}
const { url, client } = item;
if (item.subType === '内链' && client) {
toClient(item, loginA);
} else {
if (!url) return;
if (url?.indexOf('{userId}') >= 0) {
item.url = url.replace('{userId}', window.globalConfig?.userInfo?.OID);
}
let link = item.url;
if (item.paramName) {
link = `${item.url + (item.url.indexOf('?') > 0 ? '&' : '?') + item.paramName}=${window.globalConfig?.token}`;
}
if (item.subType === '外链') {
if (item.paramValue === 'ticket') {
toRevenue(item); // 去营收
return;
}
if (item?.openOpt === '当前页打开') {
props.history.push('/thirdParty', { linkUrl: url });
} else {
window.open(url, '_blank');
}
return;
}
axios({
url: link,
method: 'get',
dataType: 'json',
}).then(res => {
if (res?.data?.code === 0) {
if (item?.openOpt === '当前页打开') {
props.history.push('/thirdParty', { linkUrl: res.data?.data });
} else {
window.open(res.data?.data, '_blank');
}
}
});
}
};
useEffect(() => {
getData();
window.addEventListener('resize', debounce(onResize, 300));
onResize();
const timer = setInterval(() => {
setCurrentTime(moment().format('YYYY-MM-DD HH:mm:ss'))
}, 1000)
return () => {
window.removeEventListener('resize', onResize);
timer2.current && clearInterval(timer2.current);
timer2.current = null;
timer3.current && clearInterval(timer3.current);
timer3.current = null;
clearInterval(timer);
};
}, []);
useEffect(() => {
const handleToggleIndustry = event => {
setJumpLoading(false);
jumpProgressEnd();
window.jumpLoadingProgress = 0;
let url = '';
if (window.clientInfo?.url && window.clientInfo.subType === '内链') {
url = searchUrl(window.clientInfo.url);
window.clientInfo = null;
}
props.history.push(`/?client=${clientRef.current || props.global.client}`);
props.updateCurrentIndex && props.updateCurrentIndex(0);
defaultApp(url);
};
const handleError = () => {
setJumpLoading(false);
jumpProgressEnd();
};
loginAction.events.on('toggleIndustry', handleToggleIndustry);
loginAction.events.on('loginError', handleError);
return () => {
loginAction && loginAction.events && loginAction.events.removeListener('toggleIndustry', handleToggleIndustry);
loginAction && loginAction.events && loginAction.events.removeListener('loginError', handleError);
};
}, [loginAction.events, props]);
return (
<div className={classNames(styles.integrationQinzhou, 'integrationQinzhou')} style={{ background: `url(${BGIcon}) center/100% 100% no-repeat` }} ref={ref} >
{/* 动态特效 */}
{
jumpLoading ? (
<div className={styles.integrationJumpLoad} key="jumpLoading">
<div style={{ width: '285px' }}>
<LoadPage percent={progressValue2 / 100} text="页面加载中~" />
</div>
</div>
) : null
}
{/* 正文 */}
<div
className={styles.integration_content}
style={{
width: boxWidth,
height: boxSize.boxHeight,
transform: `scale(${boxSize.scale}) translate(-50%,-50%)`,
}}
>
{/* 返回 */}
<div ref={backRef} className={styles.reback} style={{ left: '-103px' }} onClick={() => window.history.back()}>
<img src={reback} /> 返回上一级
</div>
{/* 当前时间 */}
<div ref={timeRef} style={{ right: '-103px' }} className={styles.integrationQinzhou_exit} >{currentTime}</div>
<div style={{ width: '100%', height: 327 }}></div>
<div className={styles.integration_row} type="业务应用">
<div className={styles.integration_row_list}>
<div className={styles.integration_row_grid} type="业务应用">
{modalConfig.length &&
modalConfig.map(item => (
<div
key={item.name}
className={classNames(
styles.integration_row_col,
item.name ? integrationData[item.name] ? styles.integration_row_col_link : styles.integration_row_col_no : '',
)}
title={`点击${item.name}跳转`}
type="业务应用"
style={item.style || {}}
onClick={() => { item.name ? onLink(integrationData[item.name], loginAction) : null }}
>
{item.name ? <img src={item.bgImg} /> : null}
</div>
))}
</div>
</div>
</div>
<div className={styles.integrationTips}>
{
BIConfig.map(item => {
return <div
title={`点击${item.name}跳转`}
className={classNames(styles.integration_card,
item.name ? integrationData[item.name] ? styles.integration_row_col_link : styles.integration_row_col_no : '',
)}
name={item.name}
onClick={() => { item.name ? onLink(integrationData[item.name], loginAction) : null }}
>
<img src={item.icon} />
</div>
})
}
</div>
</div>
</div >
);
};
const mapStateToProps = state => ({
global: state.getIn(['global', 'globalConfig']),
integratedConfig: state.getIn(['global', 'integratedConfig']),
});
const mapDispatchToProps = dispatch => ({
updateConfig(config) {
dispatch(actionCreators.getConfig(config));
},
createContext(data) {
dispatch(actionCreators.createContext(data));
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
logout() {
dispatch(actionCreators.logout());
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(IntegrationQinzhou);
.integrationQinzhou {
width: 100%;
position: relative;
height: 100%;
overflow: hidden;
// ('@/assets/images/integration2/right.png')
background: url('@/assets/images/integration/wuliangye/五粮液背景.png') center/100% 100% no-repeat;
.reback {
font-family: Microsoft YaHei;
font-weight: bold;
font-size: 14px;
color: #FFFFFF;
position: absolute;
cursor: pointer;
top: 10px;
left: 10px;
img {
margin-right: 8px;
width: 24px;
}
}
.DX1 {
width: 256px;
height: 256px;
background-size: cover;
mix-blend-mode: screen;
position: absolute;
left: calc(30vw + 40px);
bottom: 130px;
}
.DX2 {
width: 256px;
height: 256px;
background-size: cover;
mix-blend-mode: screen;
position: absolute;
left: calc(50vw + 70px);
bottom: 200px;
}
.DX3 {
width: 243px;
height: 449px;
background-size: cover;
mix-blend-mode: screen;
position: absolute;
right: 0px;
bottom: 0px;
}
.DX4 {
width: 243px;
height: 449px;
background-size: cover;
mix-blend-mode: screen;
position: absolute;
left: 0px;
bottom: 0px;
}
.iframeExitIcon {
position: absolute;
top: 0;
left: -45px;
display: flex;
height: 44px;
width: 44px;
background: rgba(28, 94, 180, 0.95);
border-radius: 0 7px 7px 0;
flex-direction: column;
justify-content: space-around;
align-items: center;
font-size: 12px;
transition: all 0.2s;
padding: 3px 0;
img {
width: 17px;
height: 12px;
}
}
.iframeExit:hover {
.iframeExitIcon {
left: 0;
}
.iframeBackLeft {
left: -15px;
}
}
.iframeBackLeft {
position: absolute;
top: 0;
left: 0;
width: 14px;
height: 44px;
background: rgba(28, 94, 180, 0.95);
border-radius: 0 7px 7px 0;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s;
img {
width: 6px;
height: 11px;
}
}
.iframeExit {
width: 44px;
height: 44px;
position: absolute;
top: 4px;
left: 0;
color: #FFF;
cursor: pointer;
user-select: none;
position: absolute;
z-index: 110;
}
.integrationQinzhou_exit {
position: absolute;
right: 10px;
top: 10px;
z-index: 100;
font-family: Microsoft YaHei;
font-weight: bold;
font-size: 14px;
color: #FFFFFF;
}
.integration_content {
width: 1663px;
display: flex;
flex-direction: column;
align-items: center;
transform-origin: left top;
position: absolute;
left: 50%;
top: 50%;
padding: 0px 20px 10px;
}
.integration_row {
width: 1663px;
display: flex;
width: 100%;
overflow: hidden;
margin-bottom: 14px;
padding: 0px 20px;
.integration_row_title {
flex: none;
margin-right: 8px;
position: relative;
writing-mode: vertical-rl;
font-weight: bold;
font-size: 18px;
color: #fff;
line-height: 33px;
text-shadow: 0 0 18px rgba(0, 144, 255, 0.5);
display: flex;
align-items: flex-start;
justify-content: center;
letter-spacing: 3px;
padding-right: 30px;
}
.integration_row_list {
flex: 1;
display: flex;
align-items: center;
}
}
.showCenter {
position: absolute;
text-align: center;
align-items: center;
display: flex;
justify-content: center;
// top: calc(50vh - 290px);
bottom: 185px;
img {
width: 344px;
height: 580px;
}
}
.integrationTips {
display: flex;
position: relative;
justify-content: space-around;
width: 1150px;
top: -11px;
height: 360px;
margin-right: 20px;
.integration_card {
text-align: center;
position: relative;
width: 112px;
}
.integration_card[name='物联接入'] {
top: 17px;
}
.integration_card[name='视频接入'] {
right: 12px;
top: 67px;
}
.integration_card[name='运维管理'] {
right: 20px;
top: 94px;
}
.integration_card[name='Web组态'] {
top: 94px;
left: 34px;
}
.integration_card[name='报表搭建'] {
top: 67px;
}
}
.integration_row_col {
position: relative;
cursor: pointer;
}
.integration_row_col_text {
font-weight: bold;
font-size: 20px;
color: #FFFFFF;
transition: all 0.1s;
position: relative;
white-space: nowrap;
}
.integration_row_col_no {
filter: grayscale(100%) brightness(90%);
cursor: not-allowed;
}
.integration_row_col_link {
transition: transform 0.3s ease;
/* 平滑过渡 */
}
.integration_row_col_link:hover {
filter: brightness(120%);
transform: translateY(-5px);
}
// 业务应用start
.integration_row[type='业务应用'] {
overflow: hidden;
display: flex;
align-items: center;
.integration_row_list {
height: 100%;
padding-top: 6px;
flex: 1;
padding-left: 2px;
}
}
.integration_row_grid[type='业务应用'] {
display: flex;
justify-content: space-between;
width: 100%;
}
.integration_row_col[type='业务应用'] {
width: 194px;
height: 426px;
position: relative;
flex: none;
}
}
.integrationJumpLoad {
width: 100%;
height: 100%;
position: absolute;
display: flex;
align-items: center;
justify-content: center;
top: 0;
left: 0;
z-index: 1080;
padding-bottom: 50px;
background-color: rgba(0, 0, 0, 0.6);
}
.hide {
visibility: hidden;
}
@-webkit-keyframes scale-in-center {
0% {
-webkit-transform: scaleY(0);
transform: scaleY(0);
opacity: 1;
}
100% {
-webkit-transform: scaleY(1);
transform: scaleY(1);
opacity: 1;
}
}
@keyframes scale-in-center {
0% {
-webkit-transform: scaleY(0);
transform: scaleY(0);
opacity: 1;
}
100% {
-webkit-transform: scaleY(1);
transform: scaleY(1);
opacity: 1;
}
}
.scaleInCenter {
visibility: visible;
-webkit-animation: scale-in-center .3s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: scale-in-center .3s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
& :global {
.integrationQinzhou {
.anticon {
vertical-align: 0.125em;
}
}
}
\ No newline at end of file
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