From 56c0d6e2f83d72f622744fea76fdc64b09e30f1d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 01 四月 2020 18:54:07 +0800 Subject: [PATCH] 2020-04-01 --- src/views/login/index.jsx | 196 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 169 insertions(+), 27 deletions(-) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index cd7dc49..e4a840c 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -1,5 +1,5 @@ import React, {Component} from 'react' -import { message } from 'antd' +import { message, Modal } from 'antd' import md5 from 'md5' import moment from 'moment' import Api from '@/api' @@ -9,11 +9,10 @@ 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 = asyncLoadComponent(() => import('./loginform')) +const LoginCloudForm = asyncLoadComponent(() => import('./logincloudform')) const Action = asyncComponent(() => import('@/tabviews/zshare/actionList')) const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN' @@ -23,15 +22,17 @@ dict: iszhCN ? zhCN : enUS, isDisabled: false, auth: false, - 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鍙�', - bgColor: window.GLOB.bgColor || '#000000', - lineColor: window.GLOB.lineColor || '#1890ff', - website: window.GLOB.website || (!window.GLOB.copyRight && 'http://minkesoft.com'), - loaded: false + loginlogo: window.GLOB.loginlogo, + bgImage: window.GLOB.bgImage, + platName: window.GLOB.platName, + copyRight: window.GLOB.copyRight, + ICP: window.GLOB.ICP, + lineColor: window.GLOB.lineColor, + webSite: window.GLOB.webSite, + langList: [], + loaded: false, + syncApp: false, + syncing: false } changelang (item) { @@ -67,7 +68,7 @@ sessionStorage.setItem('Full_Name', res.FullName) sessionStorage.setItem('avatar', res.icon || '') - localStorage.setItem('lang', param.lang) + localStorage.setItem('lang', param.lang || 'zh-CN') let _url = window.location.href.split('#')[0] @@ -83,6 +84,13 @@ } else { this.props.history.replace('/main') } + } else if (res.ErrCode === 'Need_Get_Appkey' && options.systemType === 'SSO') { + message.warning('搴旂敤灏氭湭鍒涘缓锛岃鍚戜簯绔悓姝ュ簲鐢紒') + + this.setState({ + isDisabled: false, + syncApp: true + }) } else { message.warning(res.message) this.setState({ @@ -100,7 +108,15 @@ } let str = md5('MK19' + _appId + timeStamp) - Api.systemauth(_appId, timeStamp).then(res => { + + let param = { + rduri: 'http://minkesoft.com/mksepc/webapi/dostar', + func: 'sEmpowerCloud_Get_LinkUrl', + AppID: _appId, + TimeStamp: timeStamp + } + + Api.dostarInterface(param).then(res => { if (res.status) { if (res.EPC === str) { let box = [] @@ -131,26 +147,137 @@ }) } - // 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) + // 鑾峰彇绯荤粺淇℃伅 + let _param = { + func: 's_Get_style', + Appkey: window.GLOB.appkey || '', + TypeCharOne: 'PC', + LText: `select '${window.GLOB.appkey}'`, + } + + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + + if (window.GLOB.mainSystemApi) { + _param.rduri = window.GLOB.mainSystemApi.replace('dostars', 'dostar') + } + + Api.dostarInterface(_param).then(res => { + if (res.status) { + let _url = window.location.href.split('#')[0] + '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}` : '', + ICP: res.ICP || '', + mainlogo: res.indexlogo || '', + doclogo: res.doclogo || '', + webSite: res.WebSite || '' + } + + try { + localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify(systemMsg)))) + } catch { + localStorage.removeItem(_url) + } + + this.setState({ + langList: res.lang_data || [], + ...systemMsg + }) + + if (res.titlelogo && window.GLOB.favicon !== res.titlelogo) { + let link = document.querySelector("link[rel*='icon']") || document.createElement('link') + link.type = 'image/x-icon' + link.rel = 'shortcut icon' + link.href = res.titlelogo + document.getElementsByTagName('head')[0].appendChild(link) + } + } else { + message.warning(res.message) + } + }) + } + + syncSubmit = () => { + this.setState({ + syncing: true + }) + + let param = { + func: 's_get_app_from_cloud', + UserName: '', + Password: '', + systemType: options.systemType, + Type: 'X', + debug: 'Y' + } + + param.appkey = window.GLOB.appkey || '' + + if (options.cloudServiceApi) { + param.rduri = options.cloudServiceApi.replace('dostars', 'dostar') + } + + + this.logincloudRef.handleConfirm().then(result => { + param.UserName = result.cloudusername + param.Password = result.cloudpassword + + param.Password = Utils.formatOptions(param.Password) + + Api.dostarInterface(param).then(res => { + if (res.status) { + let _param = { + func: 's_sDataDictb_TBBack', + LTextOut: res.LTextOut, + lid: res.Lid, + Appkey: window.GLOB.appkey || '' + } + + Api.dostarInterface(_param).then(response => { + if (response.status) { + message.success('搴旂敤鍒涘缓鎴愬姛銆�') + this.setState({ + syncing: false, + syncApp: false + }) + } else { + this.setState({ + syncing: false + }) + message.warning(response.message) + } + }) + + } else { + this.setState({ + syncing: false + }) + message.warning(res.message) + } + }) + }) } render () { + const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP } = this.state return ( - <div className="login-container" style={{backgroundImage: 'url(' + this.state.bgImage + ')', backgroundColor: this.state.bgColor}}> - <div className="logo" style={{borderColor: this.state.lineColor}}> - <img src={this.state.logo} alt=""/> + <div className="login-container" style={bgImage ? {backgroundImage: 'url(' + bgImage + ')'} : {}}> + <div className="logo" style={lineColor ? {borderColor: lineColor} : {}}> + {loginlogo ? <img src={loginlogo} alt=""/> : null} </div> - <div className="login-middle" style={{borderColor: this.state.lineColor}}> + <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}> <LoginForm platName={this.state.platName} dict={this.state.dict} auth={this.state.auth} lang={this.state.selectedlang} + langList={this.state.langList} isDisabled={this.state.isDisabled} changelang={(value) => this.changelang(value)} handleSubmit={() => this.handleSubmit()} @@ -159,12 +286,27 @@ /> </div> <div className="login-bottom"> - {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> + {webSite && copyRight ? + <a target="blank" href={webSite} dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></a> : + <p dangerouslySetInnerHTML={{ __html: copyRight ? copyRight.replace(/\s/ig, ' ') : '' }}></p> } - <p dangerouslySetInnerHTML={{ __html: this.state.ICP.replace(/\s/ig, ' ') }}></p> + {ICP ? <p dangerouslySetInnerHTML={{ __html: ICP.replace(/\s/ig, ' ') }}></p> : null} </div> + {/* 缂栬緫鐘舵�佺櫥褰� */} + <Modal + title={this.state.dict['login.sync.cloud']} + okText={this.state.dict['login.auth.ok']} + cancelText={this.state.dict['login.auth.cancel']} + visible={this.state.syncApp} + onOk={this.syncSubmit} + className="sync-cloud-application" + width={'430px'} + confirmLoading={this.state.syncing} + onCancel={() => {this.setState({ syncApp: false, syncing: false })}} + destroyOnClose + > + <LoginCloudForm handleSubmit={() => this.syncSubmit()} wrappedComponentRef={(inst) => this.logincloudRef = inst}/> + </Modal> {this.state.loaded ? <div style={{position: 'fixed', bottom: '-300px'}}> <Action BID="" -- Gitblit v1.8.0