提交 30ea0381 authored 作者: 钟是志's avatar 钟是志

将登录组件抽到 webpublic 里面

上级 b2747db5
...@@ -8,11 +8,12 @@ import { isJSON } from '../utils/utils'; ...@@ -8,11 +8,12 @@ import { isJSON } from '../utils/utils';
let ws = null; let ws = null;
/** /**
* props 定义 * props{
* url: 二维码url * url: 二维码url
* show: 是否显示二维码Modal * show: 是否显示二维码Modal
* wxSocketGateWay: webscoket 链接地址 * wxSocketGateWay: webscoket 链接地址
* mockServer: 接口地址前缀 用于获取sessionid; * mockServer: 接口地址前缀 用于获取sessionid;
* }
* */ * */
export default class LoginWithQrCode extends Component { export default class LoginWithQrCode extends Component {
constructor(props) { constructor(props) {
...@@ -20,10 +21,10 @@ export default class LoginWithQrCode extends Component { ...@@ -20,10 +21,10 @@ export default class LoginWithQrCode extends Component {
const { wxSocketGateWay, mockServer } = this.props; const { wxSocketGateWay, mockServer } = this.props;
this.wxSocketGateWay = wxSocketGateWay; this.wxSocketGateWay = wxSocketGateWay;
this.mockServer = mockServer; this.mockServer = mockServer;
if(!wxSocketGateWay){ if (!wxSocketGateWay) {
this.wxSocketGateWay = config.wxSocketGateWay; this.wxSocketGateWay = config.wxSocketGateWay;
} }
if(!mockServer){ if (!mockServer) {
this.mockServer = config.mockServer; this.mockServer = config.mockServer;
} }
this.state = { this.state = {
...@@ -40,7 +41,7 @@ export default class LoginWithQrCode extends Component { ...@@ -40,7 +41,7 @@ export default class LoginWithQrCode extends Component {
}; };
componentWillUnmount(){ componentWillUnmount() {
this.initWs(); // 组件不加载的时候 注销websocket this.initWs(); // 组件不加载的时候 注销websocket
} }
...@@ -73,7 +74,7 @@ export default class LoginWithQrCode extends Component { ...@@ -73,7 +74,7 @@ export default class LoginWithQrCode extends Component {
// that.getAppId(); // that.getAppId();
that.setState({ that.setState({
showRefresh: true, showRefresh: true,
}) });
}; };
ws.onmessage = (evt) => { ws.onmessage = (evt) => {
if (typeof evt.data === String) { if (typeof evt.data === String) {
...@@ -144,11 +145,11 @@ export default class LoginWithQrCode extends Component { ...@@ -144,11 +145,11 @@ export default class LoginWithQrCode extends Component {
connectTimes: 0, connectTimes: 0,
showRefresh: false, showRefresh: false,
connectStatus: false, connectStatus: false,
}) });
}; };
render() { render() {
const { sessionId, connectStatus,showRefresh, loading } = this.state; const { sessionId, connectStatus, showRefresh, loading } = this.state;
const { url, show } = this.props; const { url, show } = this.props;
if (this.props.show && !connectStatus) { if (this.props.show && !connectStatus) {
this.startConnect(); this.startConnect();
...@@ -160,9 +161,10 @@ export default class LoginWithQrCode extends Component { ...@@ -160,9 +161,10 @@ export default class LoginWithQrCode extends Component {
margin: '0 auto', margin: '0 auto',
}}> }}>
{ {
this.props.show && !connectStatus ? <Spin size="large" style={{ this.props.show && !connectStatus ? <Spin size="large" style={{
height: '200px', height: '200px',
paddingTop: '100px',}}/>: paddingTop: '100px',
}}/> :
<QRCode <QRCode
bgColor="white" bgColor="white"
fgColor='black' fgColor='black'
...@@ -177,7 +179,7 @@ export default class LoginWithQrCode extends Component { ...@@ -177,7 +179,7 @@ export default class LoginWithQrCode extends Component {
marginTop: '10px', marginTop: '10px',
borderTop: '1px solid #eee', borderTop: '1px solid #eee',
}}> }}>
<Icon type="info-circle" style={{color: '#E36968'}}/> <Icon type="info-circle" style={{ color: '#E36968' }}/>
<span style={{ <span style={{
fontWeight: 'blod', fontWeight: 'blod',
}} }}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论