| | |
| | | import { Form, Input, Checkbox } from 'antd' |
| | | import { UserOutlined, LockOutlined } from '@ant-design/icons' |
| | | |
| | | import zhCN from '@/locales/zh-CN/login.js' |
| | | import enUS from '@/locales/en-US/login.js' |
| | | import './index.scss' |
| | | |
| | | class HeaderLoginForm extends Component { |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | remember: false, |
| | | username: '', |
| | | password: '', |
| | |
| | | </Form.Item> : null} |
| | | <Form.Item style={{marginBottom: '0px', height: '60px'}}> |
| | | {getFieldDecorator('username', { |
| | | rules: [{ required: true, message: this.state.dict['login.username.empty'] }], |
| | | rules: [{ required: true, message: '请输入用户名' }], |
| | | initialValue: username, |
| | | })( |
| | | <Input |
| | | prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }}/>} |
| | | placeholder={this.state.dict['login.username']} |
| | | placeholder="用户名" |
| | | autoComplete="off" |
| | | onPressEnter={(e) => {this.handleSubmit(e, 'password')}} |
| | | /> |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.state.dict['login.password.empty'], |
| | | message: '请输入密码', |
| | | } |
| | | ] |
| | | })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'username')}} placeholder={this.state.dict['login.password']} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)} |
| | | })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'username')}} placeholder="密码" prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)} |
| | | </Form.Item> |
| | | {window.GLOB.keepKey ? <Form.Item style={{marginBottom: '10px'}}> |
| | | {getFieldDecorator('remember', { |
| | |
| | | } |
| | | } |
| | | |
| | | GLOB.dict = {} |
| | | |
| | | if (localStorage.getItem(_href + 'js_trans')) { |
| | | let js_trans = JSON.parse(localStorage.getItem(_href + 'js_trans')) |
| | | |
| | | js_trans.forEach(item => { |
| | | if (lang !== item.lang) return |
| | | GLOB.dict[item.key] = item.val |
| | | }) |
| | | } |
| | | |
| | | GLOB.mkActions = {} // 按钮权限集 |
| | | |
| | | Object.defineProperty(GLOB, 'appId', { |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import { styles } from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/login.js' |
| | | import enUS from '@/locales/en-US/login.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | import './index.scss' |
| | |
| | | class Login extends Component { |
| | | state = { |
| | | selectedlang: iszhCN ? 'zh-CN' : 'en-US', |
| | | dict: iszhCN ? zhCN : enUS, |
| | | isDisabled: false, |
| | | auth: false, |
| | | authError: '', |
| | |
| | | platName: res.SysName || '', |
| | | bgImage: res.Banner || '', |
| | | loginlogo: res.loginlogo || '', |
| | | copyRight: res.CopyRightYear && res.CopyRightOrg ? `Copyright©${res.CopyRightYear} 所有相关版权归 ${res.CopyRightOrg}` : '', |
| | | copyRight: res.CopyRightYear && res.CopyRightOrg ? `Copyright©${res.CopyRightYear} ${window.GLOB.dict['copyrights_by'] || '所有相关版权归'} ${res.CopyRightOrg}` : '', |
| | | ICP: res.ICP || '', |
| | | mainlogo: res.indexlogo || '', |
| | | doclogo: res.doclogo || '', |
| | |
| | | localStorage.removeItem(_url) |
| | | } |
| | | |
| | | |
| | | if (res.lang_translation_js && res.lang_data && res.lang_data[0] && (res.lang_data.length > 1 || res.lang_data[0].Lang !== 'zh-CN')) { |
| | | let lang = sessionStorage.getItem('lang') |
| | | let js_trans = res.lang_translation_js.map(item => { |
| | | if (lang === item.lang) { |
| | | window.GLOB.dict[item.msn_code] = item.translation |
| | | } |
| | | |
| | | return { |
| | | lang: item.lang, |
| | | key: item.msn_code, |
| | | val: item.translation |
| | | } |
| | | }) |
| | | |
| | | localStorage.setItem(_href + 'js_trans', JSON.stringify(js_trans)) |
| | | } |
| | | |
| | | let _loginurl = _href + 'loginways' |
| | | let login_ways = [] |
| | | let login_types = [] |
| | | if (res.login_ways && res.login_ways.length > 0) { |
| | | res.login_ways.forEach(item => { |
| | | // 短信验证码登录,必须设置短信Id |
| | | if (item.way_no === 'sms_vcode' && !item.sms_id) return |
| | | if (login_types.includes(item.way_no)) return |
| | | |
| | | login_types.push(item.way_no) |
| | | if (!['sms_vcode', 'uname_pwd', 'app_scan', 'weixin_scan'].includes(item.way_no)) return |
| | | |
| | | login_ways.push({ |
| | | type: item.way_no, |
| | |
| | | </div> |
| | | <div className="login-middle" style={lineColor ? {borderColor: lineColor} : {}}> |
| | | {loginWays ? <LoginForm |
| | | dict={this.state.dict} |
| | | auth={this.state.auth} |
| | | authError={this.state.authError} |
| | | touristLogin={touristLogin} |
| | |
| | | </div> |
| | | {/* 编辑状态登录 */} |
| | | <Modal |
| | | title={this.state.dict['login.sync.cloud']} |
| | | okText={this.state.dict['login.ok']} |
| | | cancelText={this.state.dict['login.cancel']} |
| | | title="同步云端应用" |
| | | visible={this.state.syncApp} |
| | | onOk={this.syncSubmit} |
| | | maskClosable={false} |
| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Input } from 'antd' |
| | | import { UserOutlined, LockOutlined } from '@ant-design/icons' |
| | | import zhCN from '@/locales/zh-CN/login.js' |
| | | import enUS from '@/locales/en-US/login.js' |
| | | import './index.scss' |
| | | |
| | | class HeaderLoginForm extends Component { |
| | | static propTpyes = { |
| | | handleSubmit: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | |
| | | <Form style={{margin: '0px 10px'}}> |
| | | <Form.Item> |
| | | {getFieldDecorator('cloudusername', { |
| | | rules: [{ required: true, message: this.state.dict['login.username.empty'] }], |
| | | rules: [{ required: true, message: '请输入用户名' }], |
| | | initialValue: '', |
| | | })( |
| | | <Input |
| | | prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} |
| | | placeholder={this.state.dict['login.username']} |
| | | placeholder="用户名" |
| | | autoComplete="off" |
| | | onPressEnter={(e) => {this.handleSubmit(e, 'cloudpassword')}} |
| | | /> |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.state.dict['login.password.empty'], |
| | | message: '请输入密码', |
| | | } |
| | | ] |
| | | })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'cloudusername')}} placeholder={this.state.dict['login.password']} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)} |
| | | })(<Input.Password onPressEnter={(e) => {this.handleSubmit(e, 'cloudusername')}} placeholder="密码" prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)} |
| | | </Form.Item> |
| | | </Form> |
| | | ) |
| | |
| | | isDisabled: PropTypes.bool, |
| | | handleSubmit: PropTypes.func, |
| | | authLogin: PropTypes.func, |
| | | dict: PropTypes.object, |
| | | auth: PropTypes.bool, |
| | | authError: PropTypes.string, |
| | | touristLogin: PropTypes.bool, |
| | |
| | | verdisabled: false, |
| | | hasScan: false, |
| | | timeout: false, |
| | | wayLabels: {}, |
| | | dict: window.GLOB.dict, |
| | | users: [] |
| | | } |
| | | |
| | |
| | | let smsId = '' |
| | | let hasScan = false |
| | | let _loginWays = [] |
| | | let wayLabels = {app_scan: 'APP扫码', weixin_scan: '微信扫码', uname_pwd: '账号登录', sms_vcode: '短信登录'} |
| | | |
| | | loginWays.forEach(item => { |
| | | item.label = window.GLOB.dict[item.type] || wayLabels[item.type] |
| | | wayLabels[item.type] = item.label |
| | | if (item.type === 'sms_vcode') { |
| | | item.label = '短信登录' |
| | | smsId = item.smsId |
| | | _loginWays.push(item) |
| | | } else if (item.type === 'uname_pwd') { |
| | | item.label = '账号登录' |
| | | _loginWays.push(item) |
| | | } else if (item.type === 'app_scan') { |
| | | item.label = 'APP扫码' |
| | | _loginWays.push(item) |
| | | hasScan = true |
| | | } else if (item.type === 'weixin_scan') { |
| | | item.label = '微信扫码' |
| | | _loginWays.push(item) |
| | | hasScan = true |
| | | } |
| | |
| | | scanId: activeKey === 'app_scan' || activeKey === 'weixin_scan' ? Utils.getuuid() : '', |
| | | timeout: false, |
| | | remember, |
| | | wayLabels, |
| | | hasScan |
| | | }) |
| | | |
| | |
| | | } |
| | | |
| | | handleSubmit = e => { |
| | | const { activeKey } = this.state |
| | | const { activeKey, dict } = this.state |
| | | // 登录参数检验 |
| | | e && e.preventDefault() |
| | | if (!this.props.auth) { |
| | | warning({ |
| | | title: this.props.authError || this.props.dict['login.auth.tip'], |
| | | okText: this.props.dict['login.ok'], |
| | | cancelText: this.props.dict['login.cancel'], |
| | | title: this.props.authError || dict['auth_tip'] || '系统未授权,请联系管理员。', |
| | | okText: dict['ok'] || '确定', |
| | | cancelText: dict['cancel'] || '取消', |
| | | onOk() {}, |
| | | onCancel() {} |
| | | }) |
| | |
| | | render() { |
| | | const { langList } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { activeKey, verdisabled, delay, loginWays, remember, scanId, timeout, hasScan, users } = this.state |
| | | const wayLabels = {app_scan: 'APP扫码', weixin_scan: '微信扫码', uname_pwd: '账号登录', sms_vcode: '短信登录'} |
| | | const { activeKey, verdisabled, delay, loginWays, remember, scanId, timeout, hasScan, users, wayLabels, dict } = this.state |
| | | |
| | | return ( |
| | | <Form className="login-form" id="login-form" onSubmit={this.handleSubmit}> |
| | |
| | | {activeKey === 'uname_pwd' ? <div className="form-item-wrap"> |
| | | <Form.Item> |
| | | {getFieldDecorator('username', { |
| | | rules: [{ required: true, message: this.props.dict['login.username.empty'] }], |
| | | rules: [{ required: true, message: dict['username_required'] || '请输入用户名' }], |
| | | initialValue: this.state.username || '', |
| | | })( |
| | | <AutoComplete |
| | |
| | | > |
| | | <Input |
| | | prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} |
| | | placeholder={this.props.dict['login.username']} |
| | | placeholder={dict['username'] || '用户名'} |
| | | autoComplete="off" |
| | | /> |
| | | </AutoComplete> |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['login.password.empty'], |
| | | message: dict['password_required'] || '请输入密码', |
| | | } |
| | | ] |
| | | })(<Input.Password placeholder={this.props.dict['login.password']} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)} |
| | | })(<Input.Password placeholder={dict['password'] || '密码'} prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} />)} |
| | | </Form.Item> |
| | | {window.GLOB.keepKey ? <Form.Item className="minline"> |
| | | {getFieldDecorator('remember', { |
| | | valuePropName: 'checked', |
| | | initialValue: remember, |
| | | })(<Checkbox onChange={this.rememberChange}>{this.props.dict['login.remember']}</Checkbox>)} |
| | | })(<Checkbox onChange={this.rememberChange}>{dict['remember_me'] || '记住密码'}</Checkbox>)} |
| | | </Form.Item> : <div style={{height: '30px', float: 'left'}}></div>} |
| | | {langList && langList.length > 0 ? <Form.Item className="minline right"> |
| | | {getFieldDecorator('lang', { |
| | |
| | | </Form.Item> : null} |
| | | <Form.Item className="btn-login"> |
| | | <Button type="primary" htmlType="submit" className="login-form-button" disabled={this.props.isDisabled} loading={this.props.isDisabled}> |
| | | {this.props.dict['login.submit']} |
| | | {dict['log_in'] || '登录'} |
| | | </Button> |
| | | </Form.Item> |
| | | {window.GLOB.sysType === 'cloud' && options.cdomain.indexOf('mk9h') > -1 ? <Form.Item className="register-line"> |
| | |
| | | {activeKey === 'sms_vcode' ? <div className="form-item-wrap"> |
| | | <Form.Item> |
| | | {getFieldDecorator('phone', { |
| | | rules: [{ required: true, message: this.props.dict['login.phone.empty'] }], |
| | | rules: [{ required: true, message: dict['phone_no_required'] || '请输入手机号' }], |
| | | initialValue: '', |
| | | })( |
| | | <Input |
| | | placeholder={this.props.dict['login.phone']} |
| | | placeholder={dict['phone_no'] || '手机号'} |
| | | autoComplete="off" |
| | | /> |
| | | )} |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['login.vercode.empty'], |
| | | message: dict['vercode_required'] || '请输入验证码', |
| | | } |
| | | ] |
| | | })( |
| | | <Input |
| | | addonAfter={ |
| | | <Button type="link" className="vercode" size="small" disabled={verdisabled} onClick={this.getvercode}> |
| | | {delay ? `${delay}s后重新获取` : '获取验证码'} |
| | | {delay ? `${delay}s` : dict['query_vercode'] || '获取验证码'} |
| | | </Button> |
| | | } |
| | | placeholder={this.props.dict['login.vercode']} |
| | | placeholder={dict['vercode'] || '验证码'} |
| | | autoComplete="off" |
| | | /> |
| | | )} |
| | |
| | | </Form.Item> : null} |
| | | <Form.Item className="btn-login"> |
| | | <Button type="primary" htmlType="submit" className="login-form-button" disabled={this.props.isDisabled} loading={this.props.isDisabled}> |
| | | {this.props.dict['login.submit']} |
| | | {dict['log_in'] || '登录'} |
| | | </Button> |
| | | </Form.Item> |
| | | {window.GLOB.sysType === 'cloud' && options.cdomain.indexOf('mk9h') > -1 ? <Form.Item className="register-line"> |
| | |
| | | {scanId ? <QrCode card={{qrWidth: 500, color: '#000000'}} value={`https://cloud.mk9h.cn/mob/mknotice.html?originurl=${window.btoa(window.GLOB.baseurl + 'mob/index.html#/wx/' + scanId)}`}/> : null} |
| | | {timeout ? <div className="qrcode-out"> |
| | | <RedoOutlined onClick={this.reCode} /> |
| | | 二维码已失效。 |
| | | {dict['code_expired'] || '二维码已失效。'} |
| | | </div> : null} |
| | | </div> |
| | | <img src={wxicon} alt=""/>请使用微信扫一扫登录 |
| | | <img src={wxicon} alt=""/>{dict['wechat_scan'] || '请使用微信扫一扫登录'} |
| | | </div> |
| | | </div> : null} |
| | | {activeKey === 'app_scan' ? <div className="form-item-wrap"> |
| | |
| | | {scanId ? <QrCode card={{qrWidth: 500, color: '#000000'}} value={`mkpcscan,${window.GLOB.appkey},${scanId}`}/> : null} |
| | | {timeout ? <div className="qrcode-out"> |
| | | <RedoOutlined onClick={this.reCode} /> |
| | | 二维码已失效。 |
| | | {dict['code_expired'] || '二维码已失效。'} |
| | | </div> : null} |
| | | </div> |
| | | 请使用客户端扫一扫登录 |
| | | {dict['client_scan'] || '请使用客户端扫一扫登录'} |
| | | </div> |
| | | </div> : null} |
| | | <div className={'login-ways ' + (activeKey === 'app_scan' || activeKey === 'weixin_scan' ? 'center' : '')}> |