From 461e4fff4b51d067671244eec63b097cd9012b6e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 30 三月 2020 09:25:41 +0800 Subject: [PATCH] 2020-03-30 --- src/views/login/index.jsx | 144 ++++++++++++++++++++++++++++++----------------- 1 files changed, 91 insertions(+), 53 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 297814e..cd7dc49 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -8,11 +8,13 @@ import options from '@/store/options.js' import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' +import asyncLoadComponent from '@/utils/asyncLoadComponent' import logourl from '@/assets/img/login-logo.png' import loginbg from '@/assets/img/loginbg.jpg' import './index.scss' -const LoginForm = asyncComponent(() => import('./loginform')) +const LoginForm = asyncLoadComponent(() => import('./loginform')) +const Action = asyncComponent(() => import('@/tabviews/zshare/actionList')) const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN' class Login extends Component { @@ -24,10 +26,12 @@ logo: window.GLOB.logo || logourl, bgImage: window.GLOB.bgImage || loginbg, platName: window.GLOB.platName || '鏄庣鍟嗕笟鏅鸿兘寮�鏀惧钩鍙�', - copyright: window.GLOB.copyright || 'Copyright漏2017 鎵�鏈夌浉鍏崇増鏉冨綊 鍖椾含鏄庣鏅崕淇℃伅鎶�鏈湁闄愬叕鍙�', - ICP: window.GLOB.ICP || 'ICP澶囨锛� 浜琁CP澶�12007830鍙�', + copyright: window.GLOB.copyRight || 'Copyright漏2017 鎵�鏈夌浉鍏崇増鏉冨綊 鍖椾含鏄庣鏅崕淇℃伅鎶�鏈湁闄愬叕鍙�', + ICP: window.GLOB.icp || 'ICP澶囨锛� 浜琁CP澶�12007830鍙�', bgColor: window.GLOB.bgColor || '#000000', - lineColor: window.GLOB.lineColor || '#06b4f7' + lineColor: window.GLOB.lineColor || '#1890ff', + website: window.GLOB.website || (!window.GLOB.copyRight && 'http://minkesoft.com'), + loaded: false } changelang (item) { @@ -54,37 +58,33 @@ async loginsubmit (param) { // 鐧诲綍鎻愪氦 - // let password = this.md5Password(param.password) - let password = param.password - let result = await Api.loginsystem(param.username, password) - if (!result.IsError) { - Api.getusermsg(param.username, password).then(res => { - if (res.status) { - sessionStorage.setItem('UserID', res.UserID) - sessionStorage.setItem('SessionUid', Utils.getuuid()) - sessionStorage.setItem('LoginUID', res.LoginUID) - localStorage.setItem('lang', param.lang) - - if (param.remember) { // 璁颁綇瀵嗙爜鏃惰处鍙峰瘑鐮佸瓨鍏ocalStorage - localStorage.setItem('username', param.username) - localStorage.setItem('password', param.password) - } else { - localStorage.removeItem('username') - localStorage.removeItem('password') - } - - if (this.props.location.state && this.props.location.state.from.pathname) { - // 鏌ョ湅鏄惁涓哄叾浠栭〉闈㈣烦杞紝璺緞瀛樺湪鏃讹紝璺冲洖鍘熼〉闈� - this.props.history.replace(this.props.location.state.from.pathname) - } else { - this.props.history.replace('/main') - } - } else { - message.warning(res.message) - } - }) + let res = await Api.getusermsg(param.username, param.password) + if (res.status) { + sessionStorage.setItem('UserID', res.UserID) + sessionStorage.setItem('SessionUid', Utils.getuuid()) + sessionStorage.setItem('LoginUID', res.LoginUID) + sessionStorage.setItem('User_Name', res.UserName) + sessionStorage.setItem('Full_Name', res.FullName) + sessionStorage.setItem('avatar', res.icon || '') + + localStorage.setItem('lang', param.lang) + + let _url = window.location.href.split('#')[0] + + if (param.remember) { // 璁颁綇瀵嗙爜鏃惰处鍙峰瘑鐮佸瓨鍏ocalStorage + localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({username: param.username, password: param.password})))) + } else { + localStorage.removeItem(_url) + } + + if (this.props.location.state && this.props.location.state.from.pathname) { + // 鏌ョ湅鏄惁涓哄叾浠栭〉闈㈣烦杞紝璺緞瀛樺湪鏃讹紝璺冲洖鍘熼〉闈� + this.props.history.replace(this.props.location.state.from.pathname) + } else { + this.props.history.replace('/main') + } } else { - message.warning(result.Message) + message.warning(res.message) this.setState({ isDisabled: false }) @@ -93,25 +93,33 @@ componentDidMount () { let timeStamp = new Date().getTime() - let str = md5('MK19' + options.AppId + timeStamp) - Api.systemauth(options.AppId, timeStamp).then(res => { - if (res.status && 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('AuthCode', box) + let _appId = window.GLOB.appId - this.setState({ - auth: true - }) - } else { - localStorage.removeItem('AuthCode') - this.setState({ - auth: false - }) + if (options.systemType === 'cloud') { // 浜戠浣跨敤绯荤粺閰嶇疆appid + _appId = options.AppId + } + + let str = md5('MK19' + _appId + timeStamp) + Api.systemauth(_appId, timeStamp).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('AuthCode', box) + + this.setState({ + auth: true + }) + } else { + localStorage.removeItem('AuthCode') + this.setState({ + auth: false + }) + } } }) @@ -122,9 +130,16 @@ auth: true }) } + + // let link = document.querySelector("link[rel*='icon']") || document.createElement('link') + // link.type = 'image/x-icon' + // link.rel = 'shortcut icon' + // link.href = 'http://www.stackoverflow.com/favicon.ico' + // document.getElementsByTagName('head')[0].appendChild(link) } render () { + return ( <div className="login-container" style={{backgroundImage: 'url(' + this.state.bgImage + ')', backgroundColor: this.state.bgColor}}> <div className="logo" style={{borderColor: this.state.lineColor}}> @@ -139,13 +154,36 @@ isDisabled={this.state.isDisabled} changelang={(value) => this.changelang(value)} handleSubmit={() => this.handleSubmit()} + handleloaded={() => {this.setState({loaded: true})}} wrappedComponentRef={(inst) => this.loginformRef = inst} /> </div> <div className="login-bottom"> - <p dangerouslySetInnerHTML={{ __html: this.state.copyright.replace(/\s/ig, ' ') }}></p> + {this.state.website ? + <a target="blank" href={this.state.website} dangerouslySetInnerHTML={{ __html: this.state.copyright.replace(/\s/ig, ' ') }}></a> : + <p dangerouslySetInnerHTML={{ __html: this.state.copyright.replace(/\s/ig, ' ') }}></p> + } <p dangerouslySetInnerHTML={{ __html: this.state.ICP.replace(/\s/ig, ' ') }}></p> </div> + {this.state.loaded ? <div style={{position: 'fixed', bottom: '-300px'}}> + <Action + BID="" + type="" + menuType="" + setting={{}} + actions={[]} + triggerBtn={{}} + dict={{}} + MenuID="" + permRoles={{}} + logcolumns={[]} + ContainerId="" + refreshdata={() => {}} + triggerPopview={() => {}} + getexceloutparam={() => {}} + gettableselected={() => {}} + /> + </div> : null} </div> ) } -- Gitblit v1.8.0