king
2020-12-30 e003a8ee8843aa60b0b7135f413b2b99857acff9
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, {Component} from 'react'
// import { Toast } from 'antd-mobile'
 
// import Api from '@/api'
import asyncComponent from '@/utils/asyncPage'
import '@/assets/css/iconfont.css'
import '@/assets/css/style.css'
import './index.scss'
 
const Login1 = asyncComponent(() => import('@/components/login/login-1'))
const NavBar1 = asyncComponent(() => import('@/components/navbar/navbar-1'))
const StabList = asyncComponent(() => import('@/components/list/stab-list'))
 
class Main extends Component {
  state = {
    // viewId: this.props.match.params.viewId,
    config: ''
  }
 
  UNSAFE_componentWillMount () {
    // const { viewId } = this.state
 
    if (!this.props.location.state) {
      this.props.history.replace({pathname: `/loading/${this.props.match.params.viewId}`})
      return
    }
 
    this.setState({
      config: this.props.location.state.config
    })
 
    // 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 || !config.components) return null
 
    let components = []
 
    config.components.forEach(item => {
      if (item.type === 'login') {
        if (item.subtype === 'mob-login-1') {
          components.push(<Login1 key={item.uuid} history={this.props.history} config={item} />)
        }
      } else if (item.type === 'navBar') {
        components.push(<NavBar1 key={item.uuid} history={this.props.history} config={item} />)
      } else if (item.type === 'list') {
        if (item.subtype === 'stab-list') {
          components.push(<StabList key={item.uuid} history={this.props.history} config={item} />)
        }
      }
    })
 
    return components
  }
 
  render () {
    return (
      <div className="main-page">
        {this.getComponents()}
      </div>
    )
  }
}
 
export default Main