Просмотр исходного кода

Merge branch 'master' of http://gogs.ioobot.com:6680/xy/online

xy 7 лет назад
Родитель
Сommit
b8e97ecb4f

+ 15 - 0
src/case/BillApp/src/App.css

@@ -2,11 +2,14 @@
     position: relative;
     z-index: 2;
     height: 100%;
+    margin-top: 0;
+    padding-top: 45px;
 }
 .scrollPage{
     height: 440px;
     overflow-y: hidden;
     overflow:scroll;
+    margin-top: 1px;
 }
 
 .billApp div.am-tabs-default-bar-tab{
@@ -14,3 +17,15 @@
 }
 
 
+.billApp  .navBars{
+    position: absolute;
+    width: 100%;
+    top: 0;
+    left: 0;
+    z-index:100;
+}
+
+.billApp  div.am-navbar{
+    background-color: black;
+}
+

+ 19 - 14
src/case/BillApp/src/App.js

@@ -4,40 +4,35 @@ 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/HomePage/HomePage'
 import Assets from './components/Assets/Assets'
 import My from './components/My/My'
+import Bill from './components/Bill/Bill'
 
 
 import './App.css';
 
-window.sessionStorage.setItem('opeind',config.APPID)
+window.sessionStorage.setItem('openid',config.APPID)
 
 class BillApp extends Component{
   constructor(){
     super()
     //初始化状态
     this.state={
-      page:"home",
-      navBarText:'微记账本'
+      page:"home"
     }
 
     this.changePage=this.changePage.bind(this)
-    this.setNavBarText=this.setNavBarText.bind(this)
+
   }
 
   //更改页面
-  changePage(page){
+  changePage(page=''){
     console.log(page)
     this.setState({page})
   }
 
-  setNavBarText(text){
-    this.setState({navBarText:text})
-  }
 
   renderBottom(){
     let page=this.state.page
@@ -53,7 +48,7 @@ class BillApp extends Component{
         return(
           <div className="pageWrap">
             <div className="scrollPage">
-              <HomePage setNavBarText={this.setNavBarText}/>
+              <HomePage changePage={this.changePage}/>
             </div>
           </div>
           )
@@ -61,18 +56,29 @@ class BillApp extends Component{
           return(
             <div className="pageWrap">
               <div className="scrollPage">
-                <Assets setNavBarText={this.setNavBarText}/>
+                <Assets changePage={this.changePage}/>
               </div>
             </div>
           )
+
      case('my'):
           return(
             <div className="pageWrap">
               <div className="scrollPage">
-                <My setNavBarText={this.setNavBarText}/>
+                <My changePage={this.changePage}/>
+              </div>
+            </div>
+          )
+
+      case('bill'):
+          return(
+            <div className="pageWrap">
+              <div className="scrollPage">
+                <Bill changePage={this.changePage}/>
               </div>
             </div>
           )
+          
       default:
           return(
             <div>页面加载失败,请刷新页面</div>
@@ -87,7 +93,6 @@ class BillApp extends Component{
         <div className="phone6s">
           <div className="App billApp">
             <PageContext.Provider value={changePage}>
-              <NavBars navBarText={this.state.navBarText} changePage={this.changePage}/>
               {this.renderPage(this.state.page)}
               {this.renderBottom()}
             </PageContext.Provider>

+ 136 - 24
src/case/BillApp/src/api/graphql/billsGraphql.txt → src/case/BillApp/src/api/billsGraphql.txt

@@ -60,6 +60,15 @@ query accountbyid($id: ID) {
 query classbyid($id: ID) {
     classbyid: class_by_id(id: $id) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -73,9 +82,18 @@ query classbyid($id: ID) {
     }
 }
 
-query tagbyprops($account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
-    tagbyprops: tag_by_props(account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt) {
+query tagbyprops($user_id: ID, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
+    tagbyprops: tag_by_props(user_id: $user_id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -106,9 +124,19 @@ query billbyid($id: ID) {
         createdAt
         id
         class
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         tag_id {
             id
 
+
             name
             icon
             createdAt
@@ -117,9 +145,18 @@ query billbyid($id: ID) {
     }
 }
 
-query classbyprops($account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
-    classbyprops: class_by_props(account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
+query classbyprops($user_id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
+    classbyprops: class_by_props(user_id: $user_id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -154,6 +191,15 @@ query accountbyprops($user_id: ID, $accountName: String, $createdAt: String, $up
 query tagbyid($id: ID) {
     tagbyid: tag_by_id(id: $id) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -197,8 +243,8 @@ query collectbyprops($updateAt: String, $remark: String, $account_id: ID, $month
     }
 }
 
-query billbyprops($account_id: ID, $tag_id: ID, $time: String, $money: Float, $class: String, $remark: String, $createdAt: String, $updateAt: String) {
-    billbyprops: bill_by_props(account_id: $account_id tag_id: $tag_id time: $time money: $money class: $class remark: $remark createdAt: $createdAt updateAt: $updateAt) {
+query billbyprops($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $class: String, $user_id: ID, $tag_id: ID) {
+    billbyprops: bill_by_props(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt class: $class user_id: $user_id tag_id: $tag_id) {
         money
         updateAt
         remark
@@ -213,9 +259,19 @@ query billbyprops($account_id: ID, $tag_id: ID, $time: String, $money: Float, $c
         createdAt
         id
         class
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         tag_id {
             id
 
+
             name
             icon
             createdAt
@@ -252,8 +308,8 @@ mutation deleteaccount($id: ID, $user_id: ID, $accountName: String, $createdAt:
     deleteaccount: delete_account(id: $id user_id: $user_id accountName: $accountName createdAt: $createdAt updateAt: $updateAt)
 }
 
-mutation updatebill($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $id: ID, $class: String, $tag_id: ID) {
-    updatebill: update_bill(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt id: $id class: $class tag_id: $tag_id) {
+mutation updatebill($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $id: ID, $class: String, $user_id: ID, $tag_id: ID) {
+    updatebill: update_bill(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt id: $id class: $class user_id: $user_id tag_id: $tag_id) {
         money
         updateAt
         remark
@@ -268,9 +324,19 @@ mutation updatebill($money: Float, $updateAt: String, $remark: String, $account_
         createdAt
         id
         class
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         tag_id {
             id
 
+
             name
             icon
             createdAt
@@ -295,13 +361,22 @@ mutation updateuser($id: ID, $openid: String, $username: String, $password: Stri
     }
 }
 
-mutation deleteclass($id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
-    deleteclass: delete_class(id: $id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt)
+mutation deleteclass($id: ID, $user_id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
+    deleteclass: delete_class(id: $id user_id: $user_id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt)
 }
 
-mutation updateclass($id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
-    updateclass: update_class(id: $id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
+mutation updateclass($id: ID, $user_id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
+    updateclass: update_class(id: $id user_id: $user_id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -315,9 +390,18 @@ mutation updateclass($id: ID, $account_id: ID, $name: String, $createdAt: String
     }
 }
 
-mutation updatetag($id: ID, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
-    updatetag: update_tag(id: $id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt) {
+mutation updatetag($id: ID, $user_id: ID, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
+    updatetag: update_tag(id: $id user_id: $user_id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -361,9 +445,18 @@ mutation createcollect($updateAt: String, $remark: String, $account_id: ID, $mon
     }
 }
 
-mutation createtag($id: ID!, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
-    createtag: create_tag(id: $id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt) {
+mutation createtag($id: ID!, $user_id: ID, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
+    createtag: create_tag(id: $id user_id: $user_id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -418,12 +511,12 @@ mutation createaccount($id: ID!, $user_id: ID, $accountName: String, $createdAt:
     }
 }
 
-mutation deletebill($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $id: ID, $class: String, $tag_id: ID) {
-    deletebill: delete_bill(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt id: $id class: $class tag_id: $tag_id)
+mutation deletebill($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $id: ID, $class: String, $user_id: ID, $tag_id: ID) {
+    deletebill: delete_bill(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt id: $id class: $class user_id: $user_id tag_id: $tag_id)
 }
 
-mutation deletetag($id: ID, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
-    deletetag: delete_tag(id: $id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt)
+mutation deletetag($id: ID, $user_id: ID, $account_id: ID, $name: String, $icon: String, $createdAt: String, $updateAt: String) {
+    deletetag: delete_tag(id: $id user_id: $user_id account_id: $account_id name: $name icon: $icon createdAt: $createdAt updateAt: $updateAt)
 }
 
 mutation updatecollect($updateAt: String, $remark: String, $account_id: ID, $month: String, $createdAt: String, $allIncome: Float, $allPay: Float, $year: String, $id: ID, $user_id: ID) {
@@ -455,9 +548,18 @@ mutation updatecollect($updateAt: String, $remark: String, $account_id: ID, $mon
     }
 }
 
-mutation createclass($id: ID!, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
-    createclass: create_class(id: $id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
+mutation createclass($id: ID!, $user_id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
+    createclass: create_class(id: $id user_id: $user_id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -471,8 +573,8 @@ mutation createclass($id: ID!, $account_id: ID, $name: String, $createdAt: Strin
     }
 }
 
-mutation createbill($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $id: ID!, $class: String, $tag_id: ID) {
-    createbill: create_bill(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt id: $id class: $class tag_id: $tag_id) {
+mutation createbill($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $id: ID!, $class: String, $user_id: ID, $tag_id: ID) {
+    createbill: create_bill(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt id: $id class: $class user_id: $user_id tag_id: $tag_id) {
         money
         updateAt
         remark
@@ -487,9 +589,19 @@ mutation createbill($money: Float, $updateAt: String, $remark: String, $account_
         createdAt
         id
         class
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         tag_id {
             id
 
+
             name
             icon
             createdAt

+ 11 - 2
src/case/BillApp/src/api/graphql/bills.js

@@ -1,5 +1,5 @@
-export const  BILL_BY_PROPS=`query billbyprops($account_id: ID, $tag_id: ID, $time: String, $money: Float, $class: String, $remark: String, $createdAt: String, $updateAt: String) {
-    billbyprops: bill_by_props(account_id: $account_id tag_id: $tag_id time: $time money: $money class: $class remark: $remark createdAt: $createdAt updateAt: $updateAt) {
+export const  BILL_BY_PROPS=`query billbyprops($money: Float, $updateAt: String, $remark: String, $account_id: ID, $time: String, $createdAt: String, $class: String, $user_id: ID, $tag_id: ID) {
+    billbyprops: bill_by_props(money: $money updateAt: $updateAt remark: $remark account_id: $account_id time: $time createdAt: $createdAt class: $class user_id: $user_id tag_id: $tag_id) {
         money
         updateAt
         remark
@@ -13,6 +13,15 @@ export const  BILL_BY_PROPS=`query billbyprops($account_id: ID, $tag_id: ID, $ti
         createdAt
         id
         class
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         tag_id {
             id
             name

+ 22 - 4
src/case/BillApp/src/api/graphql/class.js

@@ -1,6 +1,15 @@
-export const CREATE_CLASS=`mutation createclass($id: ID!, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
-    createclass: create_class(id: $id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
+export const CREATE_CLASS=`mutation createclass($id: ID!, $user_id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
+    createclass: create_class(id: $id user_id: $user_id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 
@@ -14,9 +23,18 @@ export const CREATE_CLASS=`mutation createclass($id: ID!, $account_id: ID, $name
     }
 }`
 
-export const CLASS_BY_PROPS=`query classbyprops($account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
-    classbyprops: class_by_props(account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
+export const CLASS_BY_PROPS=`query classbyprops($user_id: ID, $account_id: ID, $name: String, $createdAt: String, $updateAt: String) {
+    classbyprops: class_by_props(user_id: $user_id account_id: $account_id name: $name createdAt: $createdAt updateAt: $updateAt) {
         id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
         account_id {
             id
 

+ 1 - 1
src/case/BillApp/src/api/url_config.js

@@ -1,5 +1,5 @@
 var config={
-    APPID:"wxc4831335ae194243",
+    APPID:"ovtkn4zONC3IzhpykQ7cSLZ85YFg",
     HTTP_DATA_URL:'http://bills.ioobot.cn/graphql',
     HTTP_PAY_URL:'https://xcx.ioobot.com/payinfo'
 }

+ 0 - 11
src/case/BillApp/src/components/App/NavBar.css

@@ -1,11 +0,0 @@
-.navBars{
-    position: absolute;
-    width: 100%;
-    top: 0;
-    left: 0;
-    z-index:100;
-}
-
-div.am-navbar{
-    background-color: black;
-}

+ 11 - 2
src/case/BillApp/src/components/Assets/Assets.jsx

@@ -1,13 +1,22 @@
 import React, { Component } from 'react'
 
+import NavBars from '../common/NavBar'
+
 export default class Assets extends Component {
+  constructor(props){
+    super(props)
+    this.state={
+      navBarText:'资产统计'
+    }
+  }
   componentWillMount(){
-    this.props.setNavBarText('资产统计')
+   
   }
   render() {
     return (
       <div>
-        资产
+       <NavBars navBarText={this.state.navBarText} changePage={this.props.changePage}/>
+       资产
       </div>
     )
   }

+ 130 - 0
src/case/BillApp/src/components/Bill/Bill.jsx

@@ -0,0 +1,130 @@
+import React, { Component } from 'react'
+import TabBar from './TabBar'
+import NavBars from '../common/NavBar'
+
+import {graphqls} from '../../api/graphql_request'
+import {ACCOUNT_BY_PROPS} from '../../api/graphql/account'
+import {CLASS_BY_PROPS} from '../../api/graphql/class'
+
+
+export default class Bill extends Component {
+  constructor(props){
+      super(props)
+      this.state={
+          tabs:[{title:'收入'},{title:'支出'}],
+          class:'收入',
+          account:[],
+          classs:[]
+      }
+
+    this.tabChange=this.tabChange.bind(this)
+  }
+
+  componentDidMount(){
+    this.getAccount()
+    this.getClass()
+  }
+
+  getAccount(){
+    let user_id=sessionStorage.getItem('openid')
+    console.log(user_id)
+    graphqls(ACCOUNT_BY_PROPS,{user_id}).then((e)=>{
+        console.log(e.accountbyprops)
+        this.setState({
+            account:e.accountbyprops
+        })
+    })
+  }
+
+  getClass(){
+    let user_id=sessionStorage.getItem('openid')
+    graphqls(CLASS_BY_PROPS,{user_id}).then((e)=>{
+        console.log(e.classbyprops)
+        this.setState({
+            clsss:e.classbyprops
+        })
+    })
+  }
+
+
+  tabChange(e){
+      console.log(e)
+      this.setState({class:e.title})
+  }
+
+
+    /*
+    account_id: ID
+    class: String
+    createdAt: String
+    id: ID!
+    money: Float
+    remark: String
+    tag_id: ID
+    time: String
+    updateAt: String
+
+    金额
+
+    类别
+    账户
+    时间
+
+    备注
+
+
+    accountName: "shuying"
+createdAt: "2018-11-19 2:42:25"
+id: "1542609745385"
+updateAt: ""
+user_id: null
+    */
+
+  render() {
+    const account=this.state.account
+    const classs=this.state.class
+    return (
+      <div>
+        <NavBars page='home' navBarText='记一笔' changePage={this.props.changePage}/>
+        <TabBar tabs={this.state.tabs} tabChange={this.tabChange}/>
+        <div className="money">
+        <input name="money"/>
+        </div>
+        
+
+        <div className="class">
+            {}
+        </div>
+    
+        <select name="account">
+            <option value="0">下拉选择你的账户</option>
+            {
+                account.map((item)=>{
+                    return(
+                        <option key={item.id} value={item.id}>{item.accountName}</option> 
+                    )
+                })            
+            } 
+        </select>
+
+        <select name="class">
+            <option value="0">下拉选择你的账户</option>
+            {
+                account.map((item)=>{
+                    return(
+                        <option key={item.id} value={item.id}>{item.accountName}</option> 
+                    )
+                })            
+            } 
+        </select>
+      
+
+        
+
+        <div className="timeWrap">
+            <label>shijian </label><input name="time"/>
+        </div>
+      </div>
+    )
+  }
+}

+ 1 - 0
src/case/BillApp/src/components/HomePage/TabBar.jsx → src/case/BillApp/src/components/Bill/TabBar.jsx

@@ -4,6 +4,7 @@ import { Tabs, WhiteSpace } from 'antd-mobile';
 
 
 class TabBar extends Component {
+  
     render() {
       //console.log('this.state.products',this.state.products)
       return (

+ 0 - 60
src/case/BillApp/src/components/HomePage/Bill.jsx

@@ -1,60 +0,0 @@
-import React, { Component } from 'react'
-
-import TabBar from './TabBar'
-
-export default class Bill extends Component {
-  constructor(props){
-      super(props)
-      this.state={
-          tabs:[{title:'收入'},{title:'支出'}],
-          class:'收入'
-      }
-
-    this.tabChange=this.tabChange.bind(this)
-  }
-
-  tabChange(e){
-      console.log(e)
-      this.setState({class:e.title})
-  }
-
-
-    /*
-    account_id: ID
-    class: String
-    createdAt: String
-    id: ID!
-    money: Float
-    remark: String
-    tag_id: ID
-    time: String
-    updateAt: String
-
-    金额
-
-    类别
-    账户
-    成员
-    时间
-
-    备注
-    */
-
-  render() {
-    return (
-      <div>
-        <TabBar tabs={this.state.tabs} tabChange={this.tabChange}/>
-        <input className="money"/>
-
-        <div className="class">
-            {}
-        </div>
-        <select name="select">
-            <option value="value1">Value 1</option> 
-            <option value="value2" selected>Value 2</option>
-            <option value="value3">Value 3</option>
-        </select>
-      </div>
-    )
-  }
-}

+ 1 - 1
src/case/BillApp/src/components/HomePage/Button.jsx

@@ -17,7 +17,7 @@ export default class Buttons extends Component{
     render(){
         return (
             <WingBlank>
-                <Button type="primary" style={this.state.buttonStyle} onClick={this.props.handleChange}>+记一笔</Button><WhiteSpace />
+                <Button type="primary" style={this.state.buttonStyle} onClick={()=>this.props.changePage('bill')}>+记一笔</Button><WhiteSpace />
             </WingBlank>
         )
     }

+ 14 - 31
src/case/BillApp/src/components/HomePage/HomePage.jsx

@@ -1,9 +1,12 @@
 import React, { Component } from 'react';
 
+
+import NavBars from '../common/NavBar'
 import Lists from './List'
 import Buttons from './Button'
 import IconList from './IconList'
-import Bill from './Bill'
+
+
 
 import {graphqls} from '../../api/graphql_request'
 import {BILL_BY_PROPS} from '../../api/graphql/bills'
@@ -27,15 +30,14 @@ class HomePage  extends Component{
             weekBottom:'',
             weekTop:'',
             bills:[],
-            page:'index'
+            navBarText:'微记账本'
         }
 
-        this.handleChange=this.handleChange.bind(this)
+        //this.handleChange=this.handleChange.bind(this)
     }
 
     componentDidMount(){
         //console.log('组件已加载')
-        this.props.setNavBarText('微记账本')
         this.getBills()
         let today=new Date().toLocaleString('chinese', { hour12: false }).slice(0,10)
 
@@ -59,39 +61,20 @@ class HomePage  extends Component{
         })
     }
 
-    handleChange(){
-        console.log('---')
-        this.setState({page:'bill'})
-    }
-
-    renderPage(){
+    render(){
         const page=this.state.page
         const weekTop=this.state.weekTop
         const weekBottom=this.state.weekBottom
-        if(page==='index'){
-            return(
-                <div>
-                    <div className="dateWrap"><span className="month"> {this.state.month} </span> / {this.state.year}</div>
+        return(
+            <div>
+                <NavBars navBarText={this.state.navBarText} changePage={this.props.changePage} />
+                <div className="dateWrap"><span className="month"> {this.state.month} </span> / {this.state.year}</div>
                     <Lists bills={this.state.bills} year={this.state.year} month={this.state.month}/>
                     <div className="buttonWrap">
-                    <Buttons handleChange={this.handleChange}/>
-                    </div>
-                    <IconList bills={this.state.bills} week={{weekTop,weekBottom}}/>
+                    <Buttons changePage={this.props.changePage}/>
                 </div>
-            )
-        }else{
-            return(
-                <div>
-                    <Bill />
-                </div>
-            )
-        }
-
-    }
-
-    render(){
-        return(
-            <div>{this.renderPage()}</div>
+                <IconList bills={this.state.bills} week={{weekTop,weekBottom}}/>
+            </div>
         )
     }
 }

+ 12 - 2
src/case/BillApp/src/components/My/My.jsx

@@ -1,13 +1,23 @@
 import React, { Component } from 'react'
 
+
+import NavBars from '../common/NavBar'
+
 export default class My extends Component {
+  constructor(props){
+    super(props)
+    this.state={
+      navBarText:'我的'
+    }
+  }
   componentWillMount(){
-    this.props.setNavBarText('我的')
+    
   }
   render() {
     return (
       <div>
-        My
+        <NavBars navBarText={this.state.navBarText} changePage={this.props.changePage}/>
+        my
       </div>
     )
   }

+ 13 - 6
src/case/BillApp/src/components/App/NavBar.jsx → src/case/BillApp/src/components/common/NavBar.jsx

@@ -1,19 +1,20 @@
 import React, { Component } from 'react';
 import { NavBar, Icon } from 'antd-mobile';
 
-import './NavBar.css'
+import {PageContext} from '../context'
+
+
 
 export default class NavBars extends Component{
-    goBack(){
-        console.log('back')
-    }
     render(){
+        let page=this.props.page||'home'
+        console.log(page)
         return(
             <div className="navBars">
                 <NavBar
                 mode="dark"
-                icon={<Icon type="left" />}
-                onLeftClick={() => this.props.changePage('home')}
+                icon={ <Icon type="left" /> }
+                onLeftClick={() => this.props.changePage(page)}
                 rightContent={[
                     <Icon key="0" type="search" style={{ marginRight: '16px' }} />,
                     <Icon key="1" type="ellipsis" />,
@@ -27,3 +28,9 @@ export default class NavBars extends Component{
 
 
 
+
+
+
+
+
+