import React from 'react'
import {
  BrowserRouter as Router,
  Route,
  Redirect,
  Switch,
} from 'react-router-dom'
// import {browserHistory} from 'react-router'
import BindPhone from '../pages/bindPhone/BindPhone'
import Approval from '../pages/approval/Approval'
import BindResult from '../pages/bindPhone/BindResult'
import RedirectPage from '../pages/RedirectPage'
import ApprovalHome from '../pages/approval/ApprovalHome'
import ApprovalAdd from '../pages/approval/ApprovalAdd'
import UasApproval from '../pages/approval/UasApproval'

export class Routes extends React.Component {

  componentWillUnmount () {
    let storage = window.localStorage
    storage.removeItem('paramJson')
  }

  render () {
    return <Router
      basename={process.env.REACT_APP_ROUTER_BASE_NAME || '/ERP/uas'}>
      <div style={{ width: '100%', height: '100%' }}>
        <Switch>
          {/*<Route exact path='/bindPhone' component={BindPhone}/>*/}
          <Route path='/uasApproval' component={UasApproval}/>
          <Route path='/approvalHome' component={ApprovalHome}/>
          <Route path='/approval/:paramsStr?' component={Approval}/>
          <Route path='/approvalAdd/:caller/:master/:id?'
                 component={ApprovalAdd}/>
          <Route path='/redirect/:paramsStr?' component={RedirectPage}/>
          <Route path='/bindPhone/:openId?' component={BindPhone}/>
          <Route path='/bindResult/:result' component={BindResult}/>
          {/*<Redirect path='/' to={{pathname: '/bindPhone'}}/>*/}

          {/*404页面*/}
          <Route render={() => (
            // <Redirect to={'/redirect'}/>
            <Redirect to={'/uasApproval'}/>
          )}/>
        </Switch>
      </div>
    </Router>
  }
}


