|
|
@@ -1,23 +1,93 @@
|
|
|
import React, { Component } from 'react';
|
|
|
import { BrowserRouter as Router, Switch, Route} from 'react-router-dom';
|
|
|
+import {PageContext} from './components/context'
|
|
|
+import config from './api/url_config'
|
|
|
+
|
|
|
+
|
|
|
|
|
|
import NavBars from './components/App/NavBar'
|
|
|
import TabBarBottom from './components/App/TabBarBottom'
|
|
|
+import HomePage from './components/Bill/Bill'
|
|
|
+import Assets from './components/Assets/Assets'
|
|
|
+import My from './components/My/My'
|
|
|
+
|
|
|
|
|
|
import './App.css';
|
|
|
|
|
|
+window.sessionStorage.setItem('opeind',config.APPID)
|
|
|
+
|
|
|
class BillApp extends Component{
|
|
|
- render(){
|
|
|
- return(
|
|
|
- <div className="AppWrap">
|
|
|
- <div className="phone6s">
|
|
|
- <div className="App">
|
|
|
- <NavBars />
|
|
|
- <TabBarBottom />
|
|
|
+ constructor(){
|
|
|
+ super()
|
|
|
+ //初始化状态
|
|
|
+ this.state={
|
|
|
+ page:"bill",
|
|
|
+ navBarText:'账单'
|
|
|
+ }
|
|
|
+
|
|
|
+ this.changePage=this.changePage.bind(this)
|
|
|
+ this.setNavBarText=this.setNavBarText.bind(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ //更改页面
|
|
|
+ changePage(page){
|
|
|
+ this.setState({page})
|
|
|
+ }
|
|
|
+
|
|
|
+ setNavBarText(text){
|
|
|
+ this.setState({navBarText:text})
|
|
|
+ }
|
|
|
+
|
|
|
+ renderBottom(){
|
|
|
+ let page=this.state.page
|
|
|
+ if(page==='bill'||page==='assets'||page==='my'){
|
|
|
+ return(<TabBarBottom changePage={this.changePage}/>)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据状态渲染页面
|
|
|
+ renderPage(page){
|
|
|
+ switch(page){
|
|
|
+ case ('bill'):
|
|
|
+ return(
|
|
|
+ <div className="pageWrap">
|
|
|
+ <HomePage />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ case('assets'):
|
|
|
+ return(
|
|
|
+ <div className="pageWrap">
|
|
|
+ <Assets />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ case('my'):
|
|
|
+ return(
|
|
|
+ <div className="pageWrap">
|
|
|
+ <My />
|
|
|
</div>
|
|
|
+ )
|
|
|
+ default:
|
|
|
+ return(
|
|
|
+ <div>页面加载失败,请刷新页面</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ render(){
|
|
|
+ const changePage=this.changePage
|
|
|
+ return(
|
|
|
+ <div className="AppWrap">
|
|
|
+ <div className="phone6s">
|
|
|
+ <div className="App billApp">
|
|
|
+ <PageContext.Provider value={changePage}>
|
|
|
+ <NavBars navBarText={this.state.navBarText}/>
|
|
|
+ {this.renderPage(this.state.page)}
|
|
|
+ {this.renderBottom()}
|
|
|
+ </PageContext.Provider>
|
|
|
</div>
|
|
|
</div>
|
|
|
- )
|
|
|
+ </div>
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
export default BillApp;
|