index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, {Component} from 'react'
  2. import {withRouter, Route, Switch} from 'react-router-dom'
  3. import Shop from './shop'
  4. import Goods from './goods'
  5. import Orders from './orders'
  6. import Admin from './admin'
  7. class Manage extends Component {
  8. constructor(props) {
  9. super(props)
  10. this.state = {
  11. page: ''
  12. }
  13. }
  14. componentWillMount() {
  15. let {location} = this.props
  16. if (location && location.state) {
  17. this.props.history.replace({
  18. pathname: '/my/manage/' + location.state.page,
  19. state: {}
  20. })
  21. }
  22. }
  23. render() {
  24. return (
  25. <div className='manage-wrap'>
  26. <Switch>
  27. <Route exact path="/my/manage" component={Orders}/>
  28. <Route path="/my/manage/shop" component={Shop}/>
  29. <Route path="/my/manage/goods" component={Goods}/>
  30. <Route path="/my/manage/orders" component={Orders}/>
  31. <Route path="/my/manage/admin" component={Admin}/>
  32. <Route path="/my/manage/*" component={Orders}/>
  33. </Switch>
  34. </div>
  35. )
  36. }
  37. }
  38. export default withRouter(Manage)