From e003a8ee8843aa60b0b7135f413b2b99857acff9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 30 十二月 2020 18:49:43 +0800
Subject: [PATCH] 2020-12-30

---
 src/page/main/index.jsx |   65 +++++++++++++++++++++-----------
 1 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/src/page/main/index.jsx b/src/page/main/index.jsx
index 36d48c4..bdde824 100644
--- a/src/page/main/index.jsx
+++ b/src/page/main/index.jsx
@@ -1,48 +1,67 @@
-import React, {Component} from 'react';
-import { Toast } from 'antd-mobile'
+import React, {Component} from 'react'
+// import { Toast } from 'antd-mobile'
 
-import Api from '@/api'
+// import Api from '@/api'
 import asyncComponent from '@/utils/asyncPage'
-import './index.scss';
+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,
+    // viewId: this.props.match.params.viewId,
     config: ''
   }
 
   UNSAFE_componentWillMount () {
-    const { viewId } = this.state
+    // 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)
-      }
+    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) return null
+    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} config={item} />)
+          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} />)
         }
       }
     })
@@ -55,8 +74,8 @@
       <div className="main-page">
         {this.getComponents()}
       </div>
-    );
+    )
   }
 }
 
-export default Main;
+export default Main

--
Gitblit v1.8.0