king
2020-06-28 48a18736c461ad730bd264b0ac7b40b68a0e33a1
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,7 +58,7 @@
  }
  async loginsubmit (param) {
    if (options.systemType === 'local' && !window.GLOB.mainSystemApi) { // 业务系统必须设置单点地址
    if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 业务系统必须设置单点地址
      Modal.warning({
        title: '未设置单点服务器地址,请联系管理员!'
      })
@@ -91,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({
@@ -110,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)
@@ -187,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))))
@@ -210,6 +214,13 @@
          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)
      }
@@ -225,7 +236,7 @@
      func: 's_get_app_from_cloud',
      UserName: '',
      Password: '',
      systemType: options.systemType,
      systemType: options.sysType,
      Type: 'X',
      debug: 'Y'
    }
@@ -251,6 +262,10 @@
            lid: res.Lid,
            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) {
@@ -304,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>
@@ -330,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
const mapStateToProps = () => {
  return {}
}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyMemberLevel: (memberLevel) => dispatch(modifyMemberLevel(memberLevel))
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(Login)