From f3167f8371d19d0ea8fe7d0e7af5517ff0b08cd2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 07 四月 2021 23:25:29 +0800 Subject: [PATCH] 2021-04-07 --- src/views/login/index.jsx | 95 ++++++++++++++++++++++++++++++++++++----------- 1 files changed, 73 insertions(+), 22 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index c0cef5d..edc38e7 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -6,7 +6,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' -import options from '@/store/options.js' +import options, { styles } from '@/store/options.js' import zhCN from '@/locales/zh-CN/login.js' import enUS from '@/locales/en-US/login.js' import asyncLoadComponent from '@/utils/asyncLoadComponent' @@ -15,7 +15,7 @@ const LoginForm = asyncLoadComponent(() => import('./loginform')) const LoginCloudForm = asyncLoadComponent(() => import('./logincloudform')) -const iszhCN = localStorage.getItem('lang') !== 'en-US' +const iszhCN = sessionStorage.getItem('lang') !== 'en-US' const _href = window.location.href.split('#')[0] if (localStorage.getItem(_href + 'paramsmain')) { @@ -40,7 +40,9 @@ syncApp: false, loginWays: null, touristLogin: false, - syncing: false + syncing: false, + ipAddress: '', + city: '' } UNSAFE_componentWillMount() { @@ -90,6 +92,7 @@ * @param {Object} param 鐢ㄦ埛鍚嶅瘑鐮佺瓑淇℃伅 */ async loginsubmit (param) { + const { ipAddress, city } = this.state if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 涓氬姟绯荤粺蹇呴』璁剧疆鍗曠偣鍦板潃 Modal.warning({ title: '鏈缃崟鐐规湇鍔″櫒鍦板潃锛岃鑱旂郴绠$悊鍛橈紒' @@ -98,7 +101,7 @@ } // 鐧诲綍鎻愪氦 - let res = await Api.getusermsg(param.username, param.password) + let res = await Api.getusermsg(param.username, param.password, false, ipAddress, city) if (res.status) { localStorage.setItem('UserID', res.UserID) localStorage.setItem('LoginUID', res.LoginUID) @@ -189,6 +192,7 @@ } async phoneloginsubmit (param) { + const { ipAddress, city } = this.state if (options.sysType === 'local' && !window.GLOB.mainSystemApi) { // 涓氬姟绯荤粺蹇呴』璁剧疆鍗曠偣鍦板潃 Modal.warning({ title: '鏈缃崟鐐规湇鍔″櫒鍦板潃锛岃鑱旂郴绠$悊鍛橈紒' @@ -197,7 +201,7 @@ } // 鐧诲綍鎻愪氦 - let res = await Api.getphoneusermsg(param.phone, param.vercode) + let res = await Api.getphoneusermsg(param.phone, param.vercode, false, ipAddress, city) if (res.status) { sessionStorage.setItem('UserID', res.UserID) sessionStorage.setItem('LoginUID', res.LoginUID) @@ -210,7 +214,13 @@ sessionStorage.setItem('role_id', res.role_id || '') sessionStorage.setItem('localRole_id', res.role_id || '') - localStorage.setItem('lang', param.lang || 'zh-CN') + let _url = window.location.href.split('#')[0] + + localStorage.setItem(_url + 'lang', param.lang || 'zh-CN') + sessionStorage.setItem('lang', param.lang || 'zh-CN') + + sessionStorage.removeItem('visitorUserID') + sessionStorage.removeItem('visitorLoginUID') let _history = sessionStorage.getItem('history') if (_history) { @@ -236,6 +246,15 @@ } componentDidMount () { + // 鑾峰彇ip鍙婂煄甯備俊鎭� + Api.directRequest('http://epc.mk9h.cn/webapi/iploc', 'get', null, 'true').then(res => { + if (!res || !res.location) return + sessionStorage.setItem('city', res.location) + this.setState({ + ipAddress: res.ip || '', + city: res.location + }) + }) const timeStamp = new Date().getTime() const _authUrl = window.location.href.split('#')[0] + 'AuthCode' @@ -263,16 +282,24 @@ 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 + LoginUID: _id, + nonc: Utils.getuuid() } + + let keys = Object.keys(param).sort() + let values = '' + keys.forEach(key => { + values += key + param[key] + }) + param.sign = md5(values) + param.t = new Date().getTime() - Api.dostarToDostars(param).then(res => { + Api.directRequest(_rduri + '/sEmpowerCloud_Get_LinkUrl', 'post', param, 'true').then(res => { if (res.status) { if (res.EPC === str) { let box = [] @@ -303,12 +330,8 @@ Api.getTouristMsg().then(result => { if (result.status) { - if (result.UserID && !sessionStorage.getItem('UserID')) { - sessionStorage.setItem('UserID', result.UserID) - } - if (result.LoginUID && !sessionStorage.getItem('LoginUID')) { - sessionStorage.setItem('LoginUID', result.LoginUID) - } + sessionStorage.setItem('visitorUserID', result.UserID || '') + sessionStorage.setItem('visitorLoginUID', result.LoginUID || '') if (result.UserID && result.LoginUID) { this.setState({touristLogin: true}) @@ -321,11 +344,19 @@ LText: `select '${window.GLOB.appkey}'`, } + _param.userid = result.UserID + _param.LoginUID = result.LoginUID _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) { + // positecgroup + res.Banner = res.Banner ? res.Banner.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' + res.doclogo = res.doclogo ? res.doclogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' + res.indexlogo = res.indexlogo ? res.indexlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' + res.loginlogo = res.loginlogo ? res.loginlogo.replace(/:8080/ig, '').replace(/http:/ig, 'https:') : '' + let _url = window.location.href.split('#')[0] + 'system' let systemMsg = { favicon: res.titlelogo || '', @@ -339,7 +370,8 @@ doclogo: res.doclogo || '', style: res.CSS || '', showline: res.split_line_show || 'true', - webSite: res.WebSite || '' + webSite: res.WebSite || '', + navBar: res.menu_type } sessionStorage.setItem('home_background', res.index_background_color) @@ -392,9 +424,10 @@ window.GLOB.mainlogo = systemMsg.mainlogo window.GLOB.style = systemMsg.style + window.GLOB.navBar = systemMsg.navBar - if (window.GLOB.style && options.styles[window.GLOB.style]) { - document.body.className = options.styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') + if (window.GLOB.style && styles[window.GLOB.style]) { + document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '') } if (res.titlelogo && window.GLOB.favicon !== res.titlelogo) { @@ -413,11 +446,28 @@ } if (res.users_upt === 'true' && window.GLOB.systemType === 'production') { - Api.getLocalConfig ({func: 's_Get_local_u_deleted', users_upt_date: res.users_upt_date}).then(localres => { + Api.getLocalConfig ({ + 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}).then(ssores => { + 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.getLocalConfig ({func: 's_get_local_u_create', user_ids_local: ssores.user_ids_local}) + Api.getLocalConfig ({ + func: 's_get_local_u_create', + user_ids_local: ssores.user_ids_local, + userid: result.UserID, + LoginUID: result.LoginUID + }) }) }) } @@ -545,7 +595,7 @@ </div> <div className="login-bottom"> {webSite && copyRight ? - <a target="blank" href={webSite} dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></a> : + <a target="_blank" rel="noopener noreferrer" href={webSite} dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></a> : <p dangerouslySetInnerHTML={{ __html: copyRight ? copyRight.replace(/\s/ig, ' ') : '' }}></p> } {ICP ? <p dangerouslySetInnerHTML={{ __html: ICP.replace(/\s/ig, ' ') }}></p> : null} @@ -557,6 +607,7 @@ cancelText={this.state.dict['login.auth.cancel']} visible={this.state.syncApp} onOk={this.syncSubmit} + maskClosable={false} className="sync-cloud-application" width={'430px'} confirmLoading={this.state.syncing} -- Gitblit v1.8.0