From 48a18736c461ad730bd264b0ac7b40b68a0e33a1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 28 六月 2020 20:30:20 +0800 Subject: [PATCH] 2020-06-28 --- src/views/login/index.jsx | 106 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 67 insertions(+), 39 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index e4a840c..b6cf556 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -1,20 +1,21 @@ -import React, {Component} from 'react' +import React, { Component } from 'react' import { message, Modal } from 'antd' +import { connect } from 'react-redux' import md5 from 'md5' import moment from 'moment' + import Api from '@/api' +import Utils from '@/utils/utils.js' +import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/login.js' import enUS from '@/locales/en-US/login.js' -import options from '@/store/options.js' -import Utils from '@/utils/utils.js' -import asyncComponent from '@/utils/asyncComponent' import asyncLoadComponent from '@/utils/asyncLoadComponent' +import { modifyMemberLevel } from '@/store/action' import './index.scss' const LoginForm = asyncLoadComponent(() => import('./loginform')) const LoginCloudForm = asyncLoadComponent(() => import('./logincloudform')) -const Action = asyncComponent(() => import('@/tabviews/zshare/actionList')) -const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN' +const iszhCN = localStorage.getItem('lang') !== 'en-US' class Login extends Component { state = { @@ -22,15 +23,14 @@ dict: iszhCN ? zhCN : enUS, isDisabled: false, auth: false, - loginlogo: window.GLOB.loginlogo, - bgImage: window.GLOB.bgImage, - platName: window.GLOB.platName, - copyRight: window.GLOB.copyRight, - ICP: window.GLOB.ICP, - lineColor: window.GLOB.lineColor, - webSite: window.GLOB.webSite, + loginlogo: window.GLOB.loginlogo || '', + bgImage: window.GLOB.bgImage || '', + platName: window.GLOB.platName || '', + copyRight: window.GLOB.copyRight || '', + ICP: window.GLOB.ICP || '', + lineColor: window.GLOB.lineColor || '', + webSite: window.GLOB.webSite || '', langList: [], - loaded: false, syncApp: false, syncing: false } @@ -58,6 +58,13 @@ } async loginsubmit (param) { + if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 涓氬姟绯荤粺蹇呴』璁剧疆鍗曠偣鍦板潃 + Modal.warning({ + title: '鏈缃崟鐐规湇鍔″櫒鍦板潃锛岃鑱旂郴绠$悊鍛橈紒' + }) + return + } + // 鐧诲綍鎻愪氦 let res = await Api.getusermsg(param.username, param.password) if (res.status) { @@ -84,7 +91,7 @@ } else { this.props.history.replace('/main') } - } else if (res.ErrCode === 'Need_Get_Appkey' && options.systemType === 'SSO') { + } else if (res.ErrCode === 'Need_Get_Appkey' && options.sysType === 'SSO') { message.warning('搴旂敤灏氭湭鍒涘缓锛岃鍚戜簯绔悓姝ュ簲鐢紒') this.setState({ @@ -103,8 +110,8 @@ let timeStamp = new Date().getTime() let _appId = window.GLOB.appId - if (options.systemType === 'cloud') { // 浜戠浣跨敤绯荤粺閰嶇疆appid - _appId = options.AppId + if (options.sysType === 'cloud') { // 浜戠浣跨敤绯荤粺閰嶇疆appid + _appId = options.caId } let str = md5('MK19' + _appId + timeStamp) @@ -136,6 +143,11 @@ auth: false }) } + } else if (res.ErrCode === 'N') { + localStorage.removeItem('AuthCode') + this.setState({ + auth: false + }) } }) @@ -175,8 +187,12 @@ ICP: res.ICP || '', mainlogo: res.indexlogo || '', doclogo: res.doclogo || '', + style: res.CSS || '', webSite: res.WebSite || '' } + + // url鏍囬 + document.title = systemMsg.platTitle try { localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify(systemMsg)))) @@ -189,12 +205,21 @@ ...systemMsg }) + window.GLOB.mainlogo = systemMsg.mainlogo + if (res.titlelogo && window.GLOB.favicon !== res.titlelogo) { let link = document.querySelector("link[rel*='icon']") || document.createElement('link') link.type = 'image/x-icon' link.rel = 'shortcut icon' link.href = res.titlelogo document.getElementsByTagName('head')[0].appendChild(link) + } + + let memberLevel = res.member_level + + if (typeof(memberLevel) === 'number' && memberLevel > 10 && parseInt(memberLevel / 10) * 10 === memberLevel) { + sessionStorage.setItem('Member_Level', md5('mksoft' + moment().format('YYYYMM') + memberLevel)) + this.props.modifyMemberLevel(memberLevel) } } else { message.warning(res.message) @@ -211,7 +236,7 @@ func: 's_get_app_from_cloud', UserName: '', Password: '', - systemType: options.systemType, + systemType: options.sysType, Type: 'X', debug: 'Y' } @@ -238,6 +263,10 @@ Appkey: window.GLOB.appkey || '' } + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + _param.secretkey = Utils.encrypt(_param.LTextOut, _param.timestamp) + _param.open_key = Utils.encrypt(_param.secretkey, _param.timestamp, true) + Api.dostarInterface(_param).then(response => { if (response.status) { message.success('搴旂敤鍒涘缓鎴愬姛銆�') @@ -263,6 +292,15 @@ }) } + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + render () { const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP } = this.state @@ -281,7 +319,6 @@ isDisabled={this.state.isDisabled} changelang={(value) => this.changelang(value)} handleSubmit={() => this.handleSubmit()} - handleloaded={() => {this.setState({loaded: true})}} wrappedComponentRef={(inst) => this.loginformRef = inst} /> </div> @@ -307,28 +344,19 @@ > <LoginCloudForm handleSubmit={() => this.syncSubmit()} wrappedComponentRef={(inst) => this.logincloudRef = inst}/> </Modal> - {this.state.loaded ? <div style={{position: 'fixed', bottom: '-300px'}}> - <Action - BID="" - type="" - menuType="" - setting={{}} - actions={[]} - triggerBtn={{}} - dict={{}} - MenuID="" - permRoles={{}} - logcolumns={[]} - ContainerId="" - refreshdata={() => {}} - triggerPopview={() => {}} - getexceloutparam={() => {}} - gettableselected={() => {}} - /> - </div> : null} </div> ) } } -export default Login \ No newline at end of file +const mapStateToProps = () => { + return {} +} + +const mapDispatchToProps = (dispatch) => { + return { + modifyMemberLevel: (memberLevel) => dispatch(modifyMemberLevel(memberLevel)) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(Login) \ No newline at end of file -- Gitblit v1.8.0