From 76766991b5e2fd5c7e85fdb1c8323f4dbacb4eb3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 17 八月 2021 17:15:05 +0800 Subject: [PATCH] 2021-08-17 --- src/views/login/loginform.jsx | 114 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 91 insertions(+), 23 deletions(-) diff --git a/src/views/login/loginform.jsx b/src/views/login/loginform.jsx index 3e19642..4a5edd9 100644 --- a/src/views/login/loginform.jsx +++ b/src/views/login/loginform.jsx @@ -1,22 +1,25 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' import { Form, Icon, Input, Button, Checkbox, Select, Modal, message } from 'antd' import md5 from 'md5' import moment from 'moment' import Api from '@/api' +import Utils from '@/utils/utils.js' import options from '@/store/options.js' +import asyncLoadComponent from '@/utils/asyncLoadComponent' import './index.scss' const { warning } = Modal let LoginVerCodeTimer = null +const QrCode = asyncLoadComponent(() => import('@/components/qrcode')) class LoginTabForm extends Component { static propTpyes = { isDisabled: PropTypes.bool, changelang: PropTypes.func, handleSubmit: PropTypes.func, + authLogin: PropTypes.func, dict: PropTypes.object, auth: PropTypes.bool, authError: PropTypes.string, @@ -29,14 +32,19 @@ state = { activeKey: 'uname_pwd', + scanId: '', username: '', password: '', remember: true, delay: null, loginWays: [], smsId: '', - verdisabled: false + verdisabled: false, + timeout: false } + + timer = null + splitTime = 0 UNSAFE_componentWillMount () { const { loginWays } = this.props @@ -55,36 +63,64 @@ _loginWays.push(item) } else if (item.type === 'uname_pwd') { _loginWays.push(item) + } else if (item.type === 'app_scan') { + _loginWays.push(item) } }) + + let activeKey = _loginWays[0].type this.setState({ smsId: smsId, loginWays: _loginWays, - activeKey: _loginWays[0].type, + activeKey, + scanId: activeKey === 'app_scan' ? Utils.getuuid() : '', + timeout: false, remember }) + + if (activeKey === 'app_scan') { + this.splitTime = 0 + this.timer = setTimeout(() => { + this.checkResult() + }, 10000) + } } - UNSAFE_componentWillReceiveProps (nextProps) { - if (!is(fromJS(this.props.loginWays), fromJS(nextProps.loginWays))) { - let smsId = '' - let _loginWays = [] - nextProps.loginWays.forEach(item => { - if (item.type === 'sms_vcode') { - smsId = item.smsId - _loginWays.push(item) - } else if (item.type === 'uname_pwd') { - _loginWays.push(item) - } - }) + checkResult = () => { + const { scanId } = this.state - this.setState({ - smsId: smsId, - loginWays: _loginWays, - activeKey: _loginWays[0].type - }) + this.splitTime += 10000 + + let _param = { + func: 'webapi_get_binding_key', + scan_type: 'pc', + id: scanId, + UserName: '' } + + _param.userid = sessionStorage.getItem('visitorUserID') + _param.LoginUID = sessionStorage.getItem('visitorLoginUID') + + if (this.splitTime >= 180000) { + this.setState({ + timeout: true + }) + return + } + + Api.getSystemConfig(_param).then(res => { + if (!res.status) { + message.warning(res.message) + return + } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) { + this.props.authLogin(res.thd_party_appid, res.thd_party_openid, res.thd_party_member_id, scanId) + } else { + this.timer = setTimeout(() => { + this.checkResult() + }, 10000) + } + }) } handleConfirm = () => { @@ -183,7 +219,29 @@ } onChangeTab = (activeKey) => { - this.setState({activeKey}) + this.setState({activeKey, scanId: activeKey === 'app_scan' ? Utils.getuuid() : ''}) + + if (this.state.activeKey === 'app_scan') { + this.timer && clearTimeout(this.timer) + } + + if (activeKey === 'app_scan') { + this.splitTime = 0 + this.setState({timeout: false}) + this.timer = setTimeout(() => { + this.checkResult() + }, 10000) + } + } + + reCode = () => { + this.splitTime = 0 + + this.setState({timeout: false, scanId: Utils.getuuid()}) + + this.timer = setTimeout(() => { + this.checkResult() + }, 10000) } getvercode = () => { @@ -297,7 +355,7 @@ render() { const { getFieldDecorator } = this.props.form - const { activeKey, verdisabled, delay, loginWays, remember } = this.state + const { activeKey, verdisabled, delay, loginWays, remember, scanId, timeout } = this.state return ( <Form className="login-form" id="login-form" onSubmit={this.handleSubmit}> @@ -368,7 +426,7 @@ initialValue: remember, })(<Checkbox onChange={this.rememberChange}>{this.props.dict['login.remember']}</Checkbox>)} </Form.Item> : null} - {this.props.langList && this.props.langList.length > 0 ? <Form.Item className="minline right"> + {activeKey !== 'app_scan' && this.props.langList && this.props.langList.length > 0 ? <Form.Item className="minline right"> {getFieldDecorator('lang', { initialValue: this.props.lang, })( @@ -387,6 +445,16 @@ {this.props.dict['login.submit']} </Button> </Form.Item> : null} + {activeKey === 'app_scan' ? <div className="form-scan-wrap"> + <div className="qr-wrap"> + {scanId ? <QrCode card={{qrWidth: 500, color: '#000000'}} value={`mkpcscan,${window.GLOB.appkey},${scanId}`}/> : null} + {timeout ? <div className="qrcode-out"> + <Icon onClick={this.reCode} type="redo" /> + 浜岀淮鐮佸凡澶辨晥銆� + </div> : null} + </div> + 璇蜂娇鐢ㄥ鎴风鎵竴鎵櫥褰� + </div> : null} {options.sysType === 'cloud' && options.cdomain.indexOf('mk9h') > -1 ? <Form.Item className="register-line"> <a href="http://minkesoft.com/#/signup" target="_blank" rel="noopener noreferrer" className="register">娉ㄥ唽</a> <a href="http://minkesoft.com/#/forgotPwd" target="_blank" rel="noopener noreferrer" className="forgot">蹇樿瀵嗙爜锛�</a> -- Gitblit v1.8.0