king
2020-07-21 fe6e87bacbb4be97260427346321edeeee26258e
src/page/main/index.jsx
@@ -1,26 +1,59 @@
import React, {Component} from 'react';
import { Toast } from 'antd-mobile'
import Api from '@/api'
import asyncComponent from '@/utils/asyncPage'
import './index.scss';
const Login1 = asyncComponent(() => import('@/components/login/login-1'))
class Main extends Component {
  state = {
    viewId: this.props.match.params.viewId,
    config: ''
  }
  UNSAFE_componentWillMount () {
    const { viewId } = this.state
    Api.getSystemConfig({
      func: 'sPC_Get_LongParam',
      MenuID: viewId,
      TypeCharOne: 'mob'
    }).then((res) => {
      if (res.status) {
        let config = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
        this.setState({
          config: config
        })
      } else {
        Toast.fail(res.message, 3)
      }
    })
  }
  getComponents = () => {
    const { config } = this.state
    if (!config) return null
    let components = []
    config.components.forEach(item => {
      if (item.type === 'login') {
        if (item.subtype === 'mob-login-1') {
          components.push(<Login1 key={item.uuid} config={item} />)
        }
      }
    })
    return components
  }
  render () {
    const config = {
      type: 'login',
      subtype: 'mob-login-1',
      box: { eleType: 'box', style: {color: '#ffffff', backgroundImage: 'linear-gradient(#378DBE, #46C29E, #48A9D6)'}},
      logo: { eleType: 'img', style: {} },
      title: { eleType: 'text', content: '明科商业智能开放平台', style: {fontSize: '20px', fontWeight: 'bold', color: '#ffffff', textAlign: 'center', marginTop: '15px', marginBottom: '30px'}},
      login: { eleType: 'button', content: '登录', style: {fontSize: '18px', color: '#ffffff', textAlign: 'center', lineHeight: 2.4, borderRadius: '25px'}},
      copyright: { eleType: 'textarea', content: 'Copyright©2017  所有相关版权归  北京明科普华信息技术有限公司', style: {fontSize: '12px', color: '#ffffff', textAlign: 'center'} }
    }
    return (
      <div className="main-page">
        <Login1 config={config} />
        {this.getComponents()}
      </div>
    );
  }