king
2020-12-03 569ccb3c1ff82f30ffefa7d3700571448d742662
src/views/login/index.jsx
@@ -17,6 +17,12 @@
const LoginCloudForm = asyncLoadComponent(() => import('./logincloudform'))
const iszhCN = localStorage.getItem('lang') !== 'en-US'
const _href = window.location.href.split('#')[0]
if (localStorage.getItem(_href + 'paramsmain')) {
  sessionStorage.setItem('history', localStorage.getItem(_href + 'paramsmain'))
  localStorage.removeItem(_href + 'paramsmain')
}
class Login extends Component {
  state = {
    selectedlang: iszhCN ? 'zh-CN' : 'en-US',
@@ -64,6 +70,10 @@
    })
  }
  /**
   * @description 账号密码登录
   * @param {Object} param 用户名密码等信息
   */
  async loginsubmit (param) {
    if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 业务系统必须设置单点地址
      Modal.warning({
@@ -80,6 +90,9 @@
      sessionStorage.setItem('User_Name', res.UserName)
      sessionStorage.setItem('Full_Name', res.FullName)
      sessionStorage.setItem('avatar', res.icon || '')
      sessionStorage.setItem('dataM', res.dataM ? 'true' : '')
      sessionStorage.setItem('debug', res.debug || '')
      sessionStorage.setItem('role_id', res.role_id || '')
      localStorage.setItem('lang', param.lang || 'zh-CN')
@@ -91,9 +104,16 @@
        localStorage.removeItem(_url)
      }
      if (this.props.location.state && this.props.location.state.from.pathname) {
      // if (this.props.location.state && this.props.location.state.from.pathname) {
      //   // 查看是否为其他页面跳转,路径存在时,跳回原页面
      //   this.props.history.replace(this.props.location.state.from.pathname)
      // }
      let _history = sessionStorage.getItem('history')
      if (_history) {
        sessionStorage.removeItem('history')
        // 查看是否为其他页面跳转,路径存在时,跳回原页面
        this.props.history.replace(this.props.location.state.from.pathname)
        this.props.history.replace(_history)
      } else {
        this.props.history.replace('/main')
      }
@@ -106,6 +126,17 @@
      })
    } else {
      message.warning(res.message)
      if (res.message.indexOf('密码错误') > -1) {
        const input = document.getElementById('password')
        if (input) {
          input.select()
        }
      } else if (res.message.indexOf('登录权限') > -1) {
        const input = document.getElementById('username')
        if (input) {
          input.select()
        }
      }
      this.setState({
        isDisabled: false
      })
@@ -128,12 +159,17 @@
      sessionStorage.setItem('User_Name', res.UserName)
      sessionStorage.setItem('Full_Name', res.FullName)
      sessionStorage.setItem('avatar', res.icon || '')
      sessionStorage.setItem('dataM', res.dataM ? 'true' : '')
      sessionStorage.setItem('debug', res.debug || '')
      sessionStorage.setItem('role_id', res.role_id || '')
      localStorage.setItem('lang', param.lang || 'zh-CN')
      if (this.props.location.state && this.props.location.state.from.pathname) {
      let _history = sessionStorage.getItem('history')
      if (_history) {
        sessionStorage.removeItem('history')
        // 查看是否为其他页面跳转,路径存在时,跳回原页面
        this.props.history.replace(this.props.location.state.from.pathname)
        this.props.history.replace(_history)
      } else {
        this.props.history.replace('/main')
      }
@@ -155,57 +191,66 @@
  componentDidMount () {
    const timeStamp = new Date().getTime()
    const _authUrl = window.location.href.split('#')[0] + 'AuthCode'
    let _appId = window.GLOB.appId
    if (options.sysType === 'cloud') { // 云端使用系统配置appid
      _appId = options.caId
    let authCode = localStorage.getItem(_authUrl)
    let _s = md5('mksoft' + moment().format('YYYYMMDD'))
    authCode = authCode ? authCode.split(',') : []
    let index = authCode.findIndex(key => key === _s)
    if (index > -1) {
      this.setState({
        auth: true
      })
    }
    let str = md5('MK19' + _appId + timeStamp)
    let param = {
      rduri: 'http://minkesoft.com/mksepc/webapi/dostars',
      func: 'sEmpowerCloud_Get_LinkUrl',
      AppID: _appId,
      TimeStamp: timeStamp,
      appkey: window.GLOB.appkey,
      userid: 'bh0bapabtd45epsgra79segbch6c1ibk',
      LoginUID: 'bh0bapabtd45epsgra79segbch6c1ibk'
    }
    Api.dostarToDostars(param).then(res => {
      if (res.status) {
        if (res.EPC === str) {
          let box = []
          for (let i = 0; i < 15; i++) {
            let s = 'mksoft' + moment().add(i, 'days').format('YYYYMMDD')
            box.push(md5(s))
          }
          box = box.join(',')
          localStorage.setItem(_authUrl, box)
    if (index === -1 || index > 5) {
      let _appId = window.GLOB.appId
  
          this.setState({
            auth: true
          })
        } else {
      if (options.sysType === 'cloud') { // 云端使用系统配置appid
        _appId = options.caId
      }
      let str = md5('MK19' + _appId + timeStamp)
      let _rduri = window.atob('aHR0cDovL2VwYy5tazloL$mkmNuL3dlYmFwaS9kb3N0YXJz'.replace(/\$mk/ig, ''))
      let _func = window.atob('c0VtcG93ZXJDbG91$mkZF9HZXRfTGlua1VybA=='.replace(/\$mk/ig, ''))
      let _id = window.atob('YmgwYmFwYWJ0ZDQ1ZXBz$mkZ3JhNzlzZWdiY2g2YzFpYms='.replace(/\$mk/ig, ''))
      let param = {
        rduri: _rduri,
        func: _func,
        AppID: _appId,
        TimeStamp: timeStamp,
        appkey: window.GLOB.appkey,
        userid: _id,
        LoginUID: _id
      }
      Api.dostarToDostars(param).then(res => {
        if (res.status) {
          if (res.EPC === str) {
            let box = []
            for (let i = 0; i < 15; i++) {
              let s = 'mksoft' + moment().add(i, 'days').format('YYYYMMDD')
              box.push(md5(s))
            }
            box = box.join(',')
            localStorage.setItem(_authUrl, box)
            this.setState({
              auth: true
            })
          } else {
            localStorage.removeItem(_authUrl)
            this.setState({
              auth: false
            })
          }
        } else if (res.ErrCode === 'N') {
          localStorage.removeItem(_authUrl)
          this.setState({
            auth: false
          })
        }
      } else if (res.ErrCode === 'N') {
        localStorage.removeItem(_authUrl)
        this.setState({
          auth: false
        })
      }
    })
    let authCode = localStorage.getItem(_authUrl)
    let _s = md5('mksoft' + moment().format('YYYYMMDD'))
    if (authCode && authCode.includes(_s)) {
      this.setState({
        auth: true
      })
    }
@@ -222,7 +267,17 @@
          this.setState({touristLogin: true})
        }
        Api.getSystemStyle().then(res => {
        // 获取系统信息
        let _param = {
          func: 's_Get_style',
          TypeCharOne: 'PC',
          LText: `select '${window.GLOB.appkey}'`,
        }
        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
        Api.getSystemConfig(_param).then(res => {
          if (res.status) {
            let _url = window.location.href.split('#')[0] + 'system'
            let systemMsg = {
@@ -286,6 +341,11 @@
            })
            window.GLOB.mainlogo = systemMsg.mainlogo
            window.GLOB.style = systemMsg.style
            if (window.GLOB.style && options.styles[window.GLOB.style]) {
              document.getElementById('root').className = options.styles[window.GLOB.style]
            }
            if (res.titlelogo && window.GLOB.favicon !== res.titlelogo) {
              let link = document.querySelector("link[rel*='icon']") || document.createElement('link')
@@ -362,9 +422,9 @@
            Appkey: window.GLOB.appkey || ''
          }
          _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
          _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
          _param.secretkey = Utils.encrypt(_param.LTextOut, _param.timestamp)
          _param.open_key = Utils.encrypt(_param.secretkey, _param.timestamp, true)
          _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp)
          Api.dostarInterface(_param).then(response => {
            if (response.status) {
@@ -407,6 +467,7 @@
      <div className="login-container" style={bgImage ? {backgroundImage: 'url(' + bgImage + ')'} : {}}>
        <div className="logo" style={lineColor ? {borderColor: lineColor} : {}}>
          {loginlogo ? <img src={loginlogo} alt=""/> : null}
          {this.state.platName ? <p className="plat-name">{this.state.platName}</p> : null}
        </div>
        <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}>
          {loginWays ? <LoginForm