king
2025-05-08 b6c698c8833836971184a0a9c2645a15f8174d37
src/views/login/index.jsx
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { message, Modal } from 'antd'
import { message, Modal, notification } from 'antd'
import md5 from 'md5'
import moment from 'moment'
@@ -14,6 +14,7 @@
const LoginForm = asyncLoadComponent(() => import('./loginform'))
const Resetpwd = asyncLoadComponent(() => import('@/components/resetPassword'))
const LoginCloudForm = asyncComponent(() => import('./logincloudform'))
const LoginCodeForm = asyncComponent(() => import('./logincodeform'))
class Login extends Component {
  state = {
@@ -103,6 +104,16 @@
        }
      } else {
        users = []
      }
      // positecgroup
      if (res.token) {
        this.setState({
          isDisabled: false,
          verify: {...res, $password: param.password},
          codeVisible: true
        })
        return
      }
      users = users.filter(item => item.username !== param.username)
@@ -298,7 +309,6 @@
    // md5("/ws/location/v1/ip?callback=callbackFunction&key=key&output=jsonp secret key")
    // md5("/ws/location/v1/ip?callback=callbackFunction&key=BA7BZ-4QB65-LFCIA-QPDA6-4G6O7-MJB4Q&output=jsonpuThL4ZM3XOj642ksEQh76tyHFjh4")
    sessionStorage.removeItem('subLangList')
    sessionStorage.removeItem('langList')
    setTimeout(() => {
@@ -578,25 +588,26 @@
          if (!res) return
          
          if (res.status) {
            if (res.member_type && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
              if (md5(('mk' + appkey + res.sys_datetime + res.member_type + res.registry_date).toLowerCase()) !== res.secret_key) {
                Modal.warning({
                  title: '密钥错误,请联系管理员!',
                  okText: '知道了'
                })
                this.setState({
                  auth: false,
                  authError: '密钥错误,请联系管理员!'
                })
                return
              } else if (res.member_type === 'personal' && res.registry_date) {
                let saveDelay = 0
                try {
                  saveDelay = parseInt((new Date().getTime() - new Date(res.registry_date).getTime()) / 4320000)
                  sessionStorage.setItem('mkDelay', saveDelay)
                } catch(e) {}
              }
            }
            // positecgroup
            // if (res.member_type && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
            //   if (md5(('mk' + window.GLOB.appkey + res.sys_datetime + res.member_type + res.registry_date).toLowerCase()) !== res.secret_key) {
            //     Modal.warning({
            //       title: '密钥错误,请联系管理员!',
            //       okText: '知道了'
            //     })
            //     this.setState({
            //       auth: false,
            //       authError: '密钥错误,请联系管理员!'
            //     })
            //     return
            //   } else if (res.member_type === 'personal' && res.registry_date) {
            //     let saveDelay = 0
            //     try {
            //       saveDelay = parseInt((new Date().getTime() - new Date(res.registry_date).getTime()) / 4320000)
            //       sessionStorage.setItem('mkDelay', saveDelay)
            //     } catch(e) {}
            //   }
            // }
            if (!['shutter', 'linkage_navigation', 'linkage', 'menu_board', 'menu_board_navigation'].includes(res.menu_type)) {
              res.menu_type = 'shutter'
@@ -741,20 +752,8 @@
            }
            if (res.lang_data && res.lang_data.length > 1 && window.GLOB.systemType !== 'production') {
              let list = res.lang_data.map(item => item.Lang)
              let lang = 'zh-CN'
              if (window.GLOB.defLang && list.includes(window.GLOB.defLang)) {
                lang = window.GLOB.defLang
              }
              if (list.includes(lang)) {
                list = [lang, ...list.filter(item => item !== lang)]
                if (lang === sessionStorage.getItem('lang')) {
                  sessionStorage.setItem('langList', JSON.stringify(list))
                } else {
                  sessionStorage.setItem('subLangList', JSON.stringify(list))
                }
              }
              let list = res.lang_data.map(item => item.Lang).filter(n => n !== 'zh-CN')
              sessionStorage.setItem('langList', JSON.stringify(list))
            }
            if (res.lang_data.length === 1 && res.lang_data[0].Lang !== sessionStorage.getItem('lang')) {
@@ -797,7 +796,7 @@
            // positecgroup
            // if (res.users_upt === 'true' && window.GLOB.systemType === 'production') {
            //   Api.genericInterface ({
            //   Api.genericInterface({
            //     func: 's_Get_local_u_deleted',
            //     users_upt_date: res.users_upt_date,
            //     userid: result.UserID,
@@ -813,7 +812,7 @@
            //       LoginUID: result.LoginUID
            //     }).then(ssores => {
            //       if (!ssores.status) return
            //       Api.genericInterface ({
            //       Api.genericInterface({
            //         func: 's_get_local_u_create',
            //         user_ids_local: ssores.user_ids_local,
            //         userid: result.UserID,
@@ -944,6 +943,59 @@
    })
  }
  codeSubmit = () => {
    const { verify } = this.state
    this.codeRef.handleConfirm().then(res => {
      this.setState({
        codeLoading: true
      })
      Api.verifycode({...verify, code: res.code}).then(result => {
        this.setState({
          codeVisible: false,
          codeLoading: false
        })
        if (result.verifyResult === 'success') {
          let level = localStorage.getItem(window.GLOB.sysSign + 'pwdlevel')
          if (level) {
            let visible = false
            let tip = '密码强度不够,请修改密码!'
            if (verify.$password.length < 8) {
              visible = true
            } else if (level === 'letter_num' && /^([^0-9]*|[^a-zA-Z]*)$/.test(verify.$password)) {
              visible = true
            } else if ((level === 'char_num' || level === 'char_num_90') && /^([^0-9]*|[^a-zA-Z]*|[^!@#$%^&*()_]*)$/.test(verify.$password)) {
              visible = true
            } else if (level === 'char_num_90' && verify.modifydate) {
              let s = (new Date().getTime() - new Date(verify.modifydate).getTime()) / (1000 * 24 * 60 * 60)
              if (!isNaN(s) && s > 90) {
                visible = true
                tip = '您已90天未修改密码,请更换密码后使用!'
              }
            }
            if (visible) {
              message.warning(tip)
              this.setState({
                isDisabled: false,
                visible: true
              })
              return
            }
          }
          this.props.history.replace('/main')
        } else {
          notification.warning({
            top: 92,
            message: '验证码无效,请重新登录!',
            duration: 5
          })
        }
      })
    }, () => {})
  }
  /**
   * @description 组件销毁,清除state更新
   */
@@ -1014,6 +1066,20 @@
        </Modal>
        {/* 修改密码 */}
        <Resetpwd />
        {/* 二次验证 */}
        <Modal
          title="二次验证"
          okText={window.GLOB.dict['ok'] || '确定'}
          cancelText={window.GLOB.dict['cancel'] || '取消'}
          visible={this.state.codeVisible}
          onOk={this.codeSubmit}
          maskClosable={false}
          confirmLoading={this.state.codeLoading}
          onCancel={() => this.setState({codeVisible: false, codeLoading: false})}
          destroyOnClose
        >
          <LoginCodeForm verify={this.state.verify} wrappedComponentRef={(inst) => this.codeRef = inst} handleSubmit={this.codeSubmit}/>
        </Modal>
      </div>
    )
  }