king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
src/views/login/index.jsx
@@ -7,8 +7,6 @@
import Utils from '@/utils/utils.js' 
import MKEmitter from '@/utils/events.js'
import { styles } from '@/store/options.js'
import zhCN from '@/locales/zh-CN/login.js'
import enUS from '@/locales/en-US/login.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncLoadComponent from '@/utils/asyncLoadComponent'
import './index.scss'
@@ -16,14 +14,9 @@
const LoginForm = asyncLoadComponent(() => import('./loginform'))
const Resetpwd = asyncLoadComponent(() => import('@/components/resetPassword'))
const LoginCloudForm = asyncComponent(() => import('./logincloudform'))
const iszhCN = sessionStorage.getItem('lang') !== 'en-US'
const _href = window.location.href.split('#')[0]
class Login extends Component {
  state = {
    selectedlang: iszhCN ? 'zh-CN' : 'en-US',
    dict: iszhCN ? zhCN : enUS,
    isDisabled: false,
    auth: false,
    authError: '',
@@ -37,7 +30,6 @@
    langList: [],
    syncApp: false,
    loginWays: null,
    touristLogin: false,
    syncing: false,
  }
@@ -95,13 +87,10 @@
        window.GLOB.externalDatabase = `[${res.paas_externalDatabase}]..`
      }
      localStorage.setItem(_href + 'lang', param.lang || 'zh-CN')
      sessionStorage.setItem('lang', param.lang || 'zh-CN')
      sessionStorage.removeItem('visitorUserID')
      sessionStorage.removeItem('visitorLoginUID')
      
      let users = localStorage.getItem(_href + 'users')
      let users = localStorage.getItem(window.GLOB.sysSign + 'users')
      
      if (users) {
        try {
@@ -122,9 +111,9 @@
      users.unshift({username: param.username, password: param.remember ? param.password : ''})
      localStorage.setItem(_href + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(users))))
      localStorage.setItem(window.GLOB.sysSign + 'users', window.btoa(window.encodeURIComponent(JSON.stringify(users))))
      let level = localStorage.getItem(_href + 'pwdlevel')
      let level = localStorage.getItem(window.GLOB.sysSign + 'pwdlevel')
      if (level && process.env.NODE_ENV === 'production') {
        let visible = false
@@ -213,9 +202,6 @@
        sessionStorage.setItem('externalDatabase', res.paas_externalDatabase)
        window.GLOB.externalDatabase = `[${res.paas_externalDatabase}]..`
      }
      localStorage.setItem(_href + 'lang', param.lang || 'zh-CN')
      sessionStorage.setItem('lang', param.lang || 'zh-CN')
      sessionStorage.removeItem('visitorUserID')
      sessionStorage.removeItem('visitorLoginUID')
@@ -325,14 +311,14 @@
      }
    }
    const _addressUrl = _href + 'queryAddress'
    const _addressUrl = window.location.href.split('#')[0] + 'queryAddress'
    if (localStorage.getItem(_addressUrl) === 'true') {
      this.queryAddress()
    }
    const timeStamp = new Date().getTime()
    const _authUrl = _href + 'AuthCode'
    const _authUrl = window.location.href.split('#')[0] + 'AuthCode'
    let authCode = localStorage.getItem(_authUrl)
    let _s = md5('mksoft' + moment().format('YYYYMMDD'))
@@ -379,7 +365,7 @@
          lictime = Math.floor(new Date(lictime).getTime() / 86400000)
          let curtime = Math.floor(new Date().getTime() / 86400000)
          let licday = lictime - curtime
          let _mindUrl = _href + 'notMind'
          let _mindUrl = window.location.href.split('#')[0] + 'notMind'
          if (licday < 0 || isNaN(licday)) {
            Modal.warning({
@@ -469,12 +455,12 @@
            localStorage.setItem(_authUrl, box)
            if (res.e_files === 'true') {
              localStorage.setItem(_href + 'files', md5(_href + 'files'))
              localStorage.setItem(_href + 'filesDate', res.e_files_end_date)
              localStorage.setItem(window.GLOB.sysSign + 'files', md5(window.GLOB.sysSign + 'files'))
              localStorage.setItem(window.GLOB.sysSign + 'filesDate', res.e_files_end_date)
              window.GLOB.storeFiles = true
              window.GLOB.storeDate = Math.ceil((new Date(res.e_files_end_date).getTime() - new Date().getTime()) / 86400000)
            } else {
              localStorage.removeItem(_href + 'files')
              localStorage.removeItem(window.GLOB.sysSign + 'files')
              window.GLOB.storeFiles = false
            }
    
@@ -490,7 +476,7 @@
            }
          } else {
            localStorage.removeItem(_authUrl)
            localStorage.removeItem(_href + 'files')
            localStorage.removeItem(window.GLOB.sysSign + 'files')
            window.GLOB.storeFiles = false
            this.setState({
@@ -564,10 +550,6 @@
        sessionStorage.setItem('visitorUserID', result.UserID || '')
        sessionStorage.setItem('visitorLoginUID', result.LoginUID || '')
        if (result.UserID && result.LoginUID) {
          this.setState({touristLogin: true})
        }
        // 获取系统信息
        let _param = {
          func: 's_Get_style',
@@ -609,14 +591,13 @@
              res.menu_type = 'shutter'
            }
            let _url = _href + 'system'
            let systemMsg = {
              favicon: res.titlelogo || '',
              platTitle: res.titleName || '',
              platName: res.SysName || '',
              bgImage: res.Banner || '',
              loginlogo: res.loginlogo || '',
              copyRight: res.CopyRightYear && res.CopyRightOrg ? `Copyright©${res.CopyRightYear}    所有相关版权归    ${res.CopyRightOrg}` : '',
              copyRight: res.CopyRightYear && res.CopyRightOrg ? `Copyright©${res.CopyRightYear}    ${window.GLOB.dict['copyrights_by'] || '所有相关版权归'}    ${res.CopyRightOrg}` : '',
              ICP: res.ICP || '',
              mainlogo: res.indexlogo || '',
              doclogo: res.doclogo || '',
@@ -645,12 +626,12 @@
              level = ''
            }
            localStorage.setItem(_href + 'pwdlevel', level)
            localStorage.setItem(window.GLOB.sysSign + 'pwdlevel', level)
            if (res.srcid) {
              localStorage.setItem(_href + 'srcId', res.srcid)
              localStorage.setItem(window.GLOB.sysSign + 'srcId', res.srcid)
            } else {
              localStorage.removeItem(_href + 'srcId')
              localStorage.removeItem(window.GLOB.sysSign + 'srcId')
            }
            sessionStorage.setItem('home_background', res.index_background_color || '')
@@ -665,21 +646,41 @@
            document.title = systemMsg.platTitle
            try {
              localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify(systemMsg))))
              localStorage.setItem(window.GLOB.sysSign + 'system', window.btoa(window.encodeURIComponent(JSON.stringify(systemMsg))))
            } catch (e) {
              localStorage.removeItem(_url)
              localStorage.removeItem(window.GLOB.sysSign + 'system')
            }
            let _loginurl = _href + 'loginways'
            if (res.lang_translation_js && res.lang_data && res.lang_data[0] && (res.lang_data.length > 1 || res.lang_data[0].Lang !== 'zh-CN')) {
              let lang = sessionStorage.getItem('lang')
              let js_trans = res.lang_translation_js.map(item => {
                if (['not_empty', 'not_zero', 'max_limit', 'less_limit']) {
                  item.translation = ' ' + item.translation
                }
                if (['input_tip', 'select_tip', 'max_limit', 'less_limit']) {
                  item.translation = item.translation + ' '
                }
                if (lang === item.lang) {
                  window.GLOB.dict[item.msn_code] = item.translation
                }
                return {
                  lang: item.lang,
                  key: item.msn_code,
                  val: item.translation
                }
              })
              localStorage.setItem(window.GLOB.sysSign + 'js_trans', JSON.stringify(js_trans))
            }
            let _loginurl = window.GLOB.sysSign + 'loginways'
            let login_ways = []
            let login_types = []
            if (res.login_ways && res.login_ways.length > 0) {
              res.login_ways.forEach(item => {
                // 短信验证码登录,必须设置短信Id
                if (item.way_no === 'sms_vcode' && !item.sms_id) return
                if (login_types.includes(item.way_no)) return
                login_types.push(item.way_no)
                if (!['sms_vcode', 'uname_pwd', 'app_scan', 'weixin_scan'].includes(item.way_no)) return
                login_ways.push({
                  type: item.way_no,
@@ -718,6 +719,13 @@
                  sessionStorage.setItem('subLangList', JSON.stringify(list))
                }
              }
            }
            if (res.lang_data.length === 1 && res.lang_data[0].Lang !== sessionStorage.getItem('lang')) {
              localStorage.setItem(window.location.href.split('#')[0] + 'lang', res.lang_data[0].Lang)
              sessionStorage.setItem('lang', res.lang_data[0].Lang)
              window.location.reload()
              return
            }
            
            this.setState({
@@ -780,7 +788,7 @@
      }
    })
    
    let loginWays = localStorage.getItem(_href + 'loginways')
    let loginWays = localStorage.getItem(window.GLOB.sysSign + 'loginways')
    if (loginWays) {
      try {
        loginWays = JSON.parse(window.decodeURIComponent(window.atob(loginWays)))
@@ -890,7 +898,7 @@
  }
  render () {
    const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP, loginWays, touristLogin } = this.state
    const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP, loginWays } = this.state
    return (
      <div className="login-container" id="mk-login-view" style={bgImage ? {backgroundImage: 'url(' + bgImage + ')'} : {}}>
@@ -900,12 +908,9 @@
        </div>
        <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}>
          {loginWays ? <LoginForm
            dict={this.state.dict}
            auth={this.state.auth}
            authError={this.state.authError}
            touristLogin={touristLogin}
            loginWays={loginWays}
            lang={this.state.selectedlang}
            langList={this.state.langList}
            isDisabled={this.state.isDisabled}
            handleSubmit={() => this.handleSubmit()}
@@ -923,9 +928,7 @@
        </div>
        {/* 编辑状态登录 */}
        <Modal
          title={this.state.dict['login.sync.cloud']}
          okText={this.state.dict['login.ok']}
          cancelText={this.state.dict['login.cancel']}
          title="同步云端应用"
          visible={this.state.syncApp}
          onOk={this.syncSubmit}
          maskClosable={false}