king
2020-07-21 fe6e87bacbb4be97260427346321edeeee26258e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
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 () {
    return (
      <div className="main-page">
        {this.getComponents()}
      </div>
    );
  }
}
 
export default Main;