From cbeffcc0902631909c0373f274752a97ddaf2d4e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 06 八月 2022 01:41:54 +0800
Subject: [PATCH] 2022-08-06

---
 src/components/header/index.jsx |  108 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 88 insertions(+), 20 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index c086846..afbac7f 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -4,7 +4,8 @@
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import moment from 'moment'
-import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Input } from 'antd'
+import { Dropdown, Menu, Modal, Form, notification, Switch, Input } from 'antd'
+import { SearchOutlined, DownOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
 
 import {
   toggleCollapse,
@@ -13,7 +14,7 @@
   initMenuPermission,
   logout
 } from '@/store/action'
-import asyncComponent from '@/utils/asyncComponent'
+import asyncComponent from '@/utils/asyncSpinComponent'
 import Api from '@/api'
 import MKEmitter from '@/utils/events.js'
 import options from '@/store/options.js'
@@ -37,7 +38,8 @@
     visible: false, // 淇敼瀵嗙爜妯℃�佹
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     confirmLoading: false,
-    userName: sessionStorage.getItem('User_Name'),
+    userName: '',
+    fullName: '',
     logourl: window.GLOB.mainlogo,
     appVersion: window.GLOB.appVersion,
     loginVisible: false,
@@ -65,6 +67,8 @@
   }
 
   resetPwdSubmit = () => {
+    if (!this.formRef) return
+
     this.formRef.handleConfirm().then(res => {
       this.setState({
         confirmLoading: true
@@ -188,10 +192,19 @@
 
         const { menulist, thdMenuList } = this.getMenulist(result)
 
+        let systems = []
+        if ((options.sysType === 'local' || options.sysType === 'SSO') && result.sys_list) {
+          systems = result.sys_list
+
+          if (options.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) {
+            systems.length = 10
+          }
+        }
+
         this.setState({
           menulist,
           thdMenuList,
-          systems: window.GLOB.systemType === 'production' || options.sysType === 'SSO' ? (result.sys_list || []) : []
+          systems: systems
         })
         
         let mainMenu = menulist[0] || ''
@@ -388,12 +401,31 @@
   }
 
   loginSubmit = () => {
+    if (!this.loginRef) return
+
     this.setState({
       loginLoading: true
     })
+
     this.loginRef.handleConfirm().then(param => {
       Api.getusermsg(param.username, param.password, true).then(res => {
         if (res.status) {
+          this.setState({
+            loginLoading: false
+          })
+
+          if (res.modifydate) {
+            let s = (new Date().getTime() - new Date(res.modifydate).getTime()) / (1000 * 24 * 60 * 60)
+            if (!isNaN(s) && s > 90) {
+              Modal.warning({
+                width: 520,
+                title: <span>绯荤粺妫�娴嬪埌鎮ㄧ殑璐︽埛瀛樺湪椋庨櫓锛岃鍙婃椂鍒�<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">浜戜腑蹇�</a>淇敼瀵嗙爜锛�</span>,
+                okText: '鐭ラ亾浜�'
+              })
+              return
+            }
+          }
+
           sessionStorage.setItem('CloudUserID', res.UserID)
           sessionStorage.setItem('CloudLoginUID', res.LoginUID)
           sessionStorage.setItem('CloudUserName', res.UserName)
@@ -445,7 +477,6 @@
             message: result.message,
             duration: 10
           })
-          return
         } else if (result.func_detail && result.func_detail.length > 0) {
           this.writeFuncs(result.func_detail)
         }
@@ -550,18 +581,40 @@
       url = url + '/'
     }
 
-    let href = url + 'index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
-      UserID: sessionStorage.getItem('UserID'),
-      LoginUID: sessionStorage.getItem('LoginUID'),
-      User_Name: sessionStorage.getItem('User_Name'),
-      Full_Name: sessionStorage.getItem('Full_Name'),
-      avatar: sessionStorage.getItem('avatar'),
-      dataM: system.dataM ? 'true' : '',
-      debug: system.debug || '',
-      role_id: system.role_id || ''
-    })))
+    let key = Utils.getuuid()
 
-    window.open(href)
+    let _param = {
+      func: 'webapi_scan_binding_key',
+      binding_type: 'mk',
+      scan_type: 'toggle',
+      scan_appkey: system.scan_appkey,
+      id: key
+    }
+
+    Api.getSystemConfig(_param).then(res => {
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+      } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) {
+        let href = url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
+          appid: res.thd_party_appid,
+          memberId: res.thd_party_member_id,
+          openid: res.thd_party_openid,
+          key: key
+        })))
+
+        window.open(href)
+      } else {
+        notification.warning({
+          top: 92,
+          message: '淇℃伅缂哄け锛岃鑱旂郴绠$悊鍛橈紒',
+          duration: 5
+        })
+      }
+    })
   }
 
   dropdownMenuChange = (visible) => {
@@ -578,6 +631,15 @@
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.getRolesMenu()
+
+    let fullName = sessionStorage.getItem('Full_Name') || ''
+    let userName = sessionStorage.getItem('User_Name') || ''
+
+    if (fullName.toLowerCase() === userName.toLowerCase()) {
+      userName = ''
+    }
+
+    this.setState({fullName, userName})
   }
 
   componentDidMount () {
@@ -585,6 +647,12 @@
     setTimeout(() => {
       Api.getAppVersion().then(() => {}, () => {})
     }, 1000)
+    // Api.genericInterface({
+    //   func: 's_get_fcc_account_data',
+    //   fcc_date: '2022-03-01',
+    //   search_type: ''
+    // }).then(res => {
+    // })
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -606,7 +674,7 @@
       let url = `${ssodomain}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`
       window.open(url)
     } else if (options.sysType === 'SSO' || options.sysType === 'cloud') {
-      window.open(`${window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
+      window.open(`${window.location.href.replace(/\/admin(.*)|\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
     }
   }
 
@@ -701,7 +769,7 @@
       <header className="header-container ant-menu-dark" id="main-header-container">
         <div className={'header-logo ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}><img src={this.state.logourl} alt=""/></div>
         <div className={'header-collapse ' + (collapse && navBar !== 'topmenu' ? 'collapse' : '')}>
-          {navBar !== 'topmenu' ? <Icon type={collapse ? 'menu-unfold' : 'menu-fold'} onClick={this.handleCollapse}/> : null}
+          {navBar !== 'topmenu' ? (collapse ? <MenuUnfoldOutlined onClick={this.handleCollapse}/> : <MenuFoldOutlined onClick={this.handleCollapse}/>) : null}
         </div>
         {/* 姝e父鑿滃崟 */}
         {navBar !== 'topmenu' && menulist ?
@@ -801,7 +869,7 @@
           <div>
             <img src={this.state.avatar || avatar} alt=""/>
             <span>
-              <span className="username">{this.state.userName}</span> <Icon type="down" />
+              <span className="username"><span>{this.state.fullName}</span>{this.state.userName ? <span>{this.state.userName}</span> : null}</span> <DownOutlined />
             </span>
           </div>
         </Dropdown>
@@ -838,7 +906,7 @@
               </div>
             </div>
           } trigger={['click']} className="search-menu" placement="bottomRight" onVisibleChange={this.dropdownMenuChange}>
-            <Icon className="search-menu" type="search" />
+            <SearchOutlined className="search-menu" />
           </Dropdown> : null
         }
         {/* 淇敼瀵嗙爜 */}

--
Gitblit v1.8.0