index.js 8.48 KB
Newer Older
1 2
/* eslint-disable prettier/prettier */
/* eslint-disable global-require */
3 4 5 6 7 8 9 10 11 12
import React, {
  useCallback,
  useEffect,
  useState,
} from 'react';

import {
  Space,
  Spin,
} from 'antd';
13 14
import classNames from 'classnames';
import { connect } from 'react-redux';
15 16

import { actionCreators } from '../../containers/App/store';
17 18
import SecurityLayout from '../../layouts/SecurityLayout';
import LoginAction from '../user/login/login';
19 20
import styles from './index.less';

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
class WaterBox extends React.Component {
  // eslint-disable-next-line no-useless-constructor
  constructor(props) {
    super(props);
  }

  renderList(data) {
    const { callback } = this.props;
    /* eslint-disable */
    return (
      data &&
      data.length &&
      data.map(item => (
        <div
          className={classNames(styles.bootPageltbCase, styles.bootPageitem)}
          type={item}
          key={item}
        >
          <div
            className={styles.bootPageitemBall}
            onClick={event => callback(event, item)}
          >
            <img
              className={styles.bootPageitemb}
              src={require(`../../assets/transitionalpage/${item}球.png`)}
            />
            <img
              className={styles.bootPageitemc}
              src={require(`../../assets/transitionalpage/旋转圆.png`)}
            />
          </div>
          <div>{item}</div>
        </div>
      ))
    );
  }
  render() {
    const data = ['供水', '农饮水', '排水', '节水'];
    return (
      <div className={styles.bootPagelTop}>
        <div className={styles.bootPageltTitle}>
          <b>智慧水务</b>
          <span>SMART WATER</span>
        </div>
        <div className={styles.bootPageltBox}>{this.renderList(data)}</div>
      </div>
    );
  }
}
class ProjectBox extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      项目案例: false,
      智慧能源: false,
      智慧消防: false,
    };
  }
  mouseOveHandle(type) {
    this.setState({
      [type]: true,
    });
  }
  mouseOutHandle(type) {
    this.setState({
      [type]: false,
    });
  }
  renderList(data) {
    const { callback } = this.props;
    return (
      data &&
      data.length &&
      data.map(item => {
        return (
          <div
            style={{
邓晓峰's avatar
邓晓峰 committed
98
              background: `url(${require('../../assets/transitionalpage/' +
99
                item +
100
                '项目案例.png')})`,
101
            }}
张苗苗's avatar
张苗苗 committed
102
            key={item}
103 104 105 106 107 108
          >
            <div
              className={classNames(styles.bootPagelbBox, styles.bootPageitem)}
              type={item}
              onClick={event => callback(event, item)}
              style={{
张苗苗's avatar
张苗苗 committed
109 110 111
                background: `url(${require('../../assets/transitionalpage/' +
                  item +
                  '图.jpg')})`,
112
              }}
张苗苗's avatar
张苗苗 committed
113 114
              onMouseEnter={e => this.mouseOveHandle(item)}
              onMouseLeave={e => this.mouseOutHandle(item)}
115
            >
张苗苗's avatar
张苗苗 committed
116 117 118 119 120 121 122
              <img
                src={
                  this.state[item]
                    ? require(`../../assets/transitionalpage/${item}图动.gif`)
                    : require(`../../assets/transitionalpage/${item}图.jpg`)
                }
              />
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
              <div>{item}</div>
            </div>
          </div>
        );
      })
    );
  }
  render() {
    const data = ['项目案例', '智慧能源', '智慧消防'];
    return (
      <div className={styles.bootPagelBottom}>{this.renderList(data)}</div>
    );
  }
}
class RightBox extends React.Component {
  constructor(props) {
    super(props);
张苗苗's avatar
张苗苗 committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153
    this.state = {
      智能大数据: false,
      智能实验室: false,
    };
  }
  mouseOveHandle(type) {
    this.setState({
      [type]: true,
    });
  }
  mouseOutHandle(type) {
    this.setState({
      [type]: false,
    });
154 155 156 157 158 159 160 161 162 163 164 165 166
  }
  renderList(data) {
    const { callback } = this.props;
    return (
      data &&
      data.length &&
      data.map(item => {
        return (
          <div
            className={styles.bootPagerBox}
            type={item}
            key={item}
            onClick={event => callback(event, item)}
张苗苗's avatar
张苗苗 committed
167
            style={{
张苗苗's avatar
张苗苗 committed
168 169 170
              background: `url(${require('../../assets/transitionalpage/' +
                item +
                '图.jpg')})`,
张苗苗's avatar
张苗苗 committed
171
            }}
张苗苗's avatar
张苗苗 committed
172 173
            onMouseEnter={e => this.mouseOveHandle(item)}
            onMouseLeave={e => this.mouseOutHandle(item)}
174
          >
张苗苗's avatar
张苗苗 committed
175 176 177 178 179 180 181
            <img
              src={
                this.state[item]
                  ? require(`../../assets/transitionalpage/${item}图动.gif`)
                  : require(`../../assets/transitionalpage/${item}图.jpg`)
              }
            />
182 183 184 185 186 187 188 189 190 191 192 193 194 195
            <div className={styles.bootPagebTitle}>{item}</div>
          </div>
        );
      })
    );
  }
  render() {
    const data = ['智能大数据', '智能实验室'];
    return <div className={styles.bootPageRight}>{this.renderList(data)}</div>;
  }
}
const BootPage = props => {
  const [loadding, setLoadding] = useState(false);
  const [scale, setScale] = useState(1);
196
  const intl = useIntl();
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
  const handlePage = useCallback((event, type) => {
    event.persist();
    setLoadding(true);
    const config = props.global;
    const loginAction = new LoginAction(props);
    config.uiwidgets = [];
    config.widgets = [];
    config.allWidgets = [];
    props.instance && props.instance.updateConfig(config);
    // props.instance && props.instance.getUserInfoAndConfig('', true, type);
    loginAction.getUserInfoAndConfig('', true, type);

    // eslint-disable-next-line no-shadow
    loginAction.events.on('toggleIndustry', event => {
      setLoadding(false);
      props.history.push(`/?client=${props.global.client}`);
      window.share.event.emit('triggerMicro', props.global);
      props.updateCurrentIndex(0);
      // eslint-disable-next-line no-restricted-globals
      location.reload();
    });
  }, []);
  useEffect(() => {
    // eslint-disable-next-line no-use-before-define
    handleResize();
  }, []);
  const handleResize = () => {
    const width = document.documentElement.clientWidth;
    const height = document.documentElement.clientHeight;
    // eslint-disable-next-line no-shadow
    const scale = width / 1920;
    setScale(scale);
  };
  useEffect(() => {
    window.addEventListener('resize', handleResize);
    return () => {
      window.removeEventListener('resize', handleResize);
    };
  });
  return (
    <SecurityLayout>
      <div className={styles.bootPage}>
        <div className={styles.bootPageMain}>
          <header className={styles.bootPageHead}>
            <img
              src={require(`../../assets/transitionalpage/熊猫图标.png`)}
              alt=""
            />
            <div className={styles.bootPageTitle}>
              <span className={styles.bootPageZh}>
247
                {intl.formatMessage({id: 'pages.settings.bootpage.title'})}
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
              </span>
            </div>
          </header>
          <section className={styles.bootPageSection}>
            <div
              className={classNames(
                styles.bootPagesContent,
                'animate__animated',
              )}
              style={{
                transform: `scale(${scale})`,
                opacity: 1,
              }}
            >
              <div className={styles.bootPageLeft}>
                <WaterBox callback={handlePage} />
                <ProjectBox callback={handlePage} />
              </div>
              <RightBox callback={handlePage} />
            </div>
          </section>
          <div className={styles.bootPagecopyright}>
            Copyright ©
            <a target="_blank" href="https://panda-water.cn">
              熊猫智慧水务
            </a>
            {new Date().getFullYear()} All Rights Reserved
            <a target="_blank" id="IndexCaseNumber" href="">
              ICP11036640-1
            </a>
          </div>
          <Space className={styles.abs}>
            <Spin spinning={loadding} size="large" />
          </Space>
        </div>
      </div>
    </SecurityLayout>
  );
};
const mapStateToProps = state => ({
  global: state.getIn(['global', 'globalConfig']),
  instance: state.getIn(['global', 'instance']),
});
const mapDispatchToProps = dispatch => ({
  updateConfig(config) {
    dispatch(actionCreators.getConfig(config));
  },
  createContext(data) {
    dispatch(actionCreators.createContext(data));
  },
  updateCurrentIndex(index) {
    dispatch(actionCreators.updateCurrentIndex(index));
  },
});
export default connect(
  mapStateToProps,
  mapDispatchToProps,
)(BootPage);