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 ( -
+
@@ -98,7 +127,7 @@ export default class BaseView extends Component { { required: true, message: 'Please input your country!' }, ], })( - diff --git a/src/routes/Userinfo/BaseView.less b/src/routes/Userinfo/BaseView.less index e8e3ab1daa277e22aac844c6fc6f2cf922de5650..c0bc53a285527062826d1fa30030c19bd01e2efb 100644 --- a/src/routes/Userinfo/BaseView.less +++ b/src/routes/Userinfo/BaseView.less @@ -2,8 +2,18 @@ .baseView { display: flex; + &.md { + flex-direction: column-reverse; + .right { + padding: 20px; + display: flex; + flex-direction: column; + align-items: center; + } + } .left { - width: 448px; + max-width: 448px; + min-width: 224px; } .right { flex: 1; diff --git a/src/routes/Userinfo/GeographicView.js b/src/routes/Userinfo/GeographicView.js index 15be9314ea42588f1df0fc5dfddb8e9b4f2f8bc7..345e6bb258ff012c8439f717aa245ebcfff4aecb 100644 --- a/src/routes/Userinfo/GeographicView.js +++ b/src/routes/Userinfo/GeographicView.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import { Select, Spin } from 'antd'; import { connect } from 'dva'; +import styles from './GeographicView.less'; const { Option } = Select; @@ -17,7 +18,7 @@ const nullSlectItem = { isLoading, }; }) -export default class ProvinceSelect extends PureComponent { +export default class GeographicView extends PureComponent { componentDidMount = () => { this.props.dispatch({ type: 'geographic/fetchProvince', @@ -78,22 +79,22 @@ export default class ProvinceSelect extends PureComponent { render() { const { province, city } = this.conversionObject(); return ( - + diff --git a/src/routes/Userinfo/GeographicView.less b/src/routes/Userinfo/GeographicView.less new file mode 100644 index 0000000000000000000000000000000000000000..046d9345c5d9de430cf4fb3f08689bdc932662b8 --- /dev/null +++ b/src/routes/Userinfo/GeographicView.less @@ -0,0 +1,17 @@ +@import '~antd/lib/style/themes/default.less'; + +.row { + .item { + width: 220px; + } + .item:first-child { + margin-right: 8px; + } +} + +@media screen and (max-width: @screen-sm) { + .item:first-child { + margin: 0; + margin-bottom: 8px; + } +} diff --git a/src/routes/Userinfo/Info.js b/src/routes/Userinfo/Info.js index a978ecd523fb2d583c7544d31b14e3b23157a697..68683b9e1910a4b1e4929b617301a0e6149b5799 100644 --- a/src/routes/Userinfo/Info.js +++ b/src/routes/Userinfo/Info.js @@ -48,7 +48,7 @@ export default class Info extends PureComponent {
diff --git a/src/routes/Userinfo/Info.less b/src/routes/Userinfo/Info.less index b419400e293b56513ec7a69913f65903ccadbb1b..d0f245e167b724a1e722345459b7e6b8c1e56e6b 100644 --- a/src/routes/Userinfo/Info.less +++ b/src/routes/Userinfo/Info.less @@ -7,6 +7,7 @@ display: flex; padding-top: 16px; padding-bottom: 16px; + overflow: auto; .leftmenu { width: 224px; border-right: 1px solid #e8e8e8; @@ -69,3 +70,16 @@ color: red; } } + +@media screen and (max-width: @screen-md) { + .main { + flex-direction: column; + .leftmenu { + width: 100%; + border: none; + } + .right { + padding: 40px; + } + } +} diff --git a/src/routes/Userinfo/PhoneView.js b/src/routes/Userinfo/PhoneView.js index 5e5a920aa3ef6baeeaaba9ded2aff60c905a3242..75430f30b1e8e315f32097825b72eb2ce19d0ed9 100644 --- a/src/routes/Userinfo/PhoneView.js +++ b/src/routes/Userinfo/PhoneView.js @@ -1,5 +1,6 @@ import React, { Fragment, PureComponent } from 'react'; import { Input } from 'antd'; +import styles from './PhoneView.less'; class PhoneView extends PureComponent { render() { @@ -11,18 +12,18 @@ class PhoneView extends PureComponent { return ( { onChange(`${e.target.value}-${values[1]}`); }} - style={{ width: 128, marginRight: 8 }} /> { onChange(`${values[0]}-${e.target.value}`); }} value={values[1]} - style={{ width: 312 }} /> ); diff --git a/src/routes/Userinfo/PhoneView.less b/src/routes/Userinfo/PhoneView.less new file mode 100644 index 0000000000000000000000000000000000000000..bc1e3a430f1263b693b80af3d6def5f426356d56 --- /dev/null +++ b/src/routes/Userinfo/PhoneView.less @@ -0,0 +1,20 @@ +@import '~antd/lib/style/themes/default.less'; + +.area_code { + width: 128px; + margin-right: 8px; +} +.phone_number { + width: 312px; +} + +@media screen and (max-width: @screen-sm) { + .area_code { + width: 100%; + margin: 0; + margin-bottom: 8px; + } + .phone_number { + width: 100%; + } +}