From 0d2f88497895dd118ee083028bf5d4d71d004ecc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 13 五月 2025 11:44:20 +0800 Subject: [PATCH] 2025-05-13 --- src/views/login/index.jsx | 287 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 212 insertions(+), 75 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 20043a7..c6ad6c2 100644 --- a/src/views/login/index.jsx +++ b/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 = { @@ -27,6 +28,8 @@ ICP: window.GLOB.ICP || '', lineColor: window.GLOB.lineColor || '', webSite: window.GLOB.webSite || '', + prolType: window.GLOB.prolType || '', + prolCont: window.GLOB.prolCont || '', langList: [], syncApp: false, loginWays: null, @@ -102,6 +105,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) @@ -148,12 +161,31 @@ } } - let iframe = sessionStorage.getItem('iframe') - if (iframe) { - sessionStorage.removeItem('iframe') - this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID)) + if (['20210626201522493D7AD7591D7A547278685', '20210626201956190740F1DF384914A3CA9EF'].includes(window.GLOB.appkey) && process.env.NODE_ENV === 'production' && param.username !== 'IF_DMS_APP') { + let _param = { + UserName: param.username, + Password: param.password, + BasePath: '/' + } + Api.loginAndRedirect(_param).then(result => { + if (result.IsError) { + this.setState({ + isDisabled: false + }) + message.warning('鐧诲綍澶辫触,鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒!') + } else { + let lang = sessionStorage.getItem('lang') !== 'en-US' ? '/zh-CN' : '/en-US' + window.location.replace(document.location.origin + lang + '/Home/Index') + } + }) } else { - this.props.history.replace('/main') + let iframe = sessionStorage.getItem('iframe') + if (iframe) { + sessionStorage.removeItem('iframe') + this.props.history.replace(iframe.replace(/@loginuid@/, res.LoginUID)) + } else { + this.props.history.replace('/main') + } } } else if (res.ErrCode === 'Need_Get_Appkey' && window.GLOB.sysType === 'SSO') { message.warning('搴旂敤灏氭湭鍒涘缓锛岃鍚戜簯绔悓姝ュ簲鐢紒') @@ -296,7 +328,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(() => { @@ -576,29 +607,44 @@ 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' } + + let loginOtop = '' + let loginOleft = '' + let windowWidth = window.innerWidth + let fix = null + res.login_screen_offset && res.login_screen_offset.forEach(item => { + if (!item.offset_x && !item.offset_y) return + + if (fix === null || Math.abs(windowWidth - item.resolution_width) < fix) { + fix = Math.abs(windowWidth - item.resolution_width) + loginOtop = item.offset_y + item.y_unit + loginOleft = item.offset_x + item.x_unit + } + }) let systemMsg = { favicon: res.titlelogo || '', @@ -613,12 +659,27 @@ style: res.CSS || '', showline: res.split_line_show || 'true', webSite: res.WebSite || '', + prolType: '', + prolCont: '', navBar: res.menu_type, // shutter 鐧惧彾绐椼�乴inkage_navigation 鑱斿姩鑿滃崟銆乴inkage 鑱斿姩鑿滃崟_鏃犲鑸爮銆乵enu_board 鑿滃崟闈㈡澘銆乵enu_board_navigation 鑿滃崟闈㈡澘_鏍囩椤� app_version: res.app_version, Member_Level: 0, appname: res.appname || '', - loginOtop: res.loginOtop || '', - loginOleft: res.loginOleft || '' + loginOtop: loginOtop, + loginOleft: loginOleft + } + + if (['every_time', 'once', 'not_required'].includes(res.require_legal_consent) && res.legal_documents) { + systemMsg.prolCont = res.legal_documents + try { + systemMsg.prolCont = window.decodeURIComponent(window.atob(systemMsg.prolCont)) + if (res.require_legal_consent !== 'not_required') { + systemMsg.prolType = res.require_legal_consent + } + } catch(e) { + systemMsg.prolType = '' + systemMsg.prolCont = '' + } } if ([10, 20, 30, 40, 50, 60, 70, 80, 90, 100].includes(res.member_level)) { @@ -710,20 +771,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')) { @@ -733,12 +782,16 @@ return } + let langList = res.lang_data.map(item => ({Lang: item.Lang, LangName: item.LangName})) + + localStorage.setItem(window.GLOB.sysSign + 'langList', JSON.stringify(langList)) + window.GLOB.loginOtop = systemMsg.loginOtop window.GLOB.loginOleft = systemMsg.loginOleft this.setState({ loginWays: login_ways, - langList: res.lang_data || [], + langList: langList, ...systemMsg }) @@ -761,32 +814,32 @@ } // positecgroup - // if (res.users_upt === 'true' && window.GLOB.systemType === 'production') { - // Api.genericInterface ({ - // func: 's_Get_local_u_deleted', - // users_upt_date: res.users_upt_date, - // userid: result.UserID, - // LoginUID: result.LoginUID - // }).then(localres => { - // if (!localres.status) return - // Api.getSystemConfig({ - // func: 's_get_sso_u_create', - // user_ids: localres.user_ids, - // user_ids_local: localres.user_ids_local, - // users_upt_date: localres.users_upt_date, - // userid: result.UserID, - // LoginUID: result.LoginUID - // }).then(ssores => { - // if (!ssores.status) return - // Api.genericInterface ({ - // func: 's_get_local_u_create', - // user_ids_local: ssores.user_ids_local, - // userid: result.UserID, - // LoginUID: result.LoginUID - // }) - // }) - // }) - // } + if (['20210626201522493D7AD7591D7A547278685', '20210626201956190740F1DF384914A3CA9EF'].includes(window.GLOB.appkey) && res.users_upt === 'true' && window.GLOB.systemType === 'production') { + Api.genericInterface({ + func: 's_Get_local_u_deleted', + users_upt_date: res.users_upt_date, + userid: result.UserID, + LoginUID: result.LoginUID + }).then(localres => { + if (!localres.status) return + Api.getSystemConfig({ + func: 's_get_sso_u_create', + user_ids: localres.user_ids, + user_ids_local: localres.user_ids_local, + users_upt_date: localres.users_upt_date, + userid: result.UserID, + LoginUID: result.LoginUID + }).then(ssores => { + if (!ssores.status) return + Api.genericInterface({ + func: 's_get_local_u_create', + user_ids_local: ssores.user_ids_local, + userid: result.UserID, + LoginUID: result.LoginUID + }) + }) + }) + } } else { message.warning(res.message) } @@ -806,6 +859,19 @@ this.setState({ loginWays: loginWays + }) + } + + let langs = localStorage.getItem(window.GLOB.sysSign + 'langList') + if (langs) { + try { + langs = JSON.parse(langs) + } catch (e) { + langs = [] + } + + this.setState({ + langList: langs }) } } @@ -896,6 +962,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鏇存柊 */ @@ -906,7 +1025,7 @@ } render () { - const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP, loginWays } = this.state + const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP, loginWays, prolType, prolCont } = this.state let wrapStyle = {} @@ -931,6 +1050,8 @@ auth={this.state.auth} authError={this.state.authError} loginWays={loginWays} + prolType={prolType} + prolCont={prolCont} langList={this.state.langList} isDisabled={this.state.isDisabled} handleSubmit={() => this.handleSubmit()} @@ -939,11 +1060,13 @@ /> : null} </div> <div className="login-bottom"> - {webSite && copyRight ? - <a target="_blank" rel="noopener noreferrer" href={webSite} dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></a> : - <p dangerouslySetInnerHTML={{ __html: copyRight ? copyRight.replace(/\s/ig, ' ') : '' }}></p> - } - <br/> + <p> + {webSite && copyRight ? + <a target="_blank" rel="noopener noreferrer" href={webSite} dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></a> : + <span dangerouslySetInnerHTML={{ __html: copyRight ? copyRight.replace(/\s/ig, ' ') : '' }}></span> + } + {prolCont && !prolType ? <span style={{marginLeft: '15px'}} dangerouslySetInnerHTML={{ __html: prolCont }}></span> : null} + </p> {ICP ? <a target="_blank" rel="noopener noreferrer" href="https://beian.miit.gov.cn/#/Integrated/index" dangerouslySetInnerHTML={{ __html: ICP.replace(/\s/ig, ' ') }}></a> : null} </div> {/* 缂栬緫鐘舵�佺櫥褰� */} @@ -962,6 +1085,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> ) } -- Gitblit v1.8.0