diff --git a/src/routes/Userinfo/BaseView.js b/src/routes/Userinfo/BaseView.js index 960e18c6930175f74a1e8ebe7aa6cab0543c4af7..b73275c8d974d4c076093098e036c6ea569d4feb 100644 --- a/src/routes/Userinfo/BaseView.js +++ b/src/routes/Userinfo/BaseView.js @@ -1,5 +1,7 @@ import React, { Component, Fragment } from 'react'; import { Form, Input, Upload, Select, Button } from 'antd'; +import Debounce from 'lodash-decorators/debounce'; +import Bind from 'lodash-decorators/bind'; import styles from './BaseView.less'; import GeographicView from './GeographicView'; import PhoneView from './PhoneView'; @@ -46,8 +48,16 @@ const validatorPhone = (rule, value, callback) => { @Form.create() export default class BaseView extends Component { + state = { + md: false, + }; componentDidMount() { this.setBaseInfo(); + this.resize(); + window.addEventListener('resize', this.resize); + } + componentWillUnmount() { + window.removeEventListener('resize', this.resize); } setBaseInfo = () => { const { currentUser } = this.props; @@ -65,10 +75,29 @@ export default class BaseView extends Component { 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'; return url; } + getViewDom = (ref) => { + this.view = ref; + }; + @Bind() + @Debounce(200) + resize() { + if (this.view.offsetWidth > 696) { + this.setState({ + md: false, + }); + return; + } + this.setState({ + md: true, + }); + } render() { const { getFieldDecorator } = this.props.form; return ( -