Browse Source

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

xy 7 năm trước cách đây
mục cha
commit
b960496526

+ 34 - 6
src/case/BillApp/src/App.js

@@ -4,11 +4,16 @@ import {PageContext} from './components/context'
 import config from './api/url_config'
 
 
+import {graphqls} from './api/graphql_request'
+import {BILL_BY_PROPS} from './api/graphql/bills'
+import {getMonDayAndSunDay} from './untils/date'
+
 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 BillDetail from './components/BillDetail/BillDetail'
 
 
 import './App.css';
@@ -20,11 +25,15 @@ class BillApp extends Component{
     super()
     //初始化状态
     this.state={
-      page:"home"
+      weekBottom:'',
+      weekTop:'',
+      bills:[],
+      page:"home",
+      detail:'day'
     }
 
     this.changePage=this.changePage.bind(this)
-
+    this.setDetail=this.setDetail.bind(this)
   }
 
   //更改页面
@@ -32,8 +41,6 @@ class BillApp extends Component{
     console.log(page)
     this.setState({page})
   }
-
-
   renderBottom(){
     let page=this.state.page
     if(page==='home'||page==='assets'||page==='my'){
@@ -41,6 +48,20 @@ class BillApp extends Component{
     }
   }
 
+  setDetail(detail){
+    this.setState({detail})
+  }
+
+  //获取数据
+  getBills(){
+    graphqls(BILL_BY_PROPS,{}).then((e)=>{
+        //console.log('1----',e.billbyprops)
+        this.setState({
+            bills:e.billbyprops
+        })
+    })
+  }
+
   //根据状态渲染页面
   renderPage(page){
     switch(page){
@@ -48,7 +69,7 @@ class BillApp extends Component{
         return(
           <div className="pageWrap">
             <div className="scrollPage">
-              <HomePage changePage={this.changePage}/>
+              <HomePage changePage={this.changePage} setDetail={this.setDetail}/>
             </div>
           </div>
           )
@@ -60,7 +81,6 @@ class BillApp extends Component{
               </div>
             </div>
           )
-
      case('my'):
           return(
             <div className="pageWrap">
@@ -78,6 +98,14 @@ class BillApp extends Component{
               </div>
             </div>
           )
+      case('detail'):
+          return (
+            <div className="pageWrap">
+              <div className="scrollPage">
+                <BillDetail changePage={this.changePage} detail={this.state.detail}/>
+              </div>
+            </div>
+          )
           
       default:
           return(

+ 39 - 0
src/case/BillApp/src/components/BillDetail/BillDetail.jsx

@@ -0,0 +1,39 @@
+import React, { Component } from 'react'
+
+import NavBars from '../common/NavBar'
+
+//import {setSessionStorage,getSessionStorage} from '../../untils/session_help'
+import {collectByDate} from '../../untils/date'
+
+export default class BillDetail extends Component {
+    constructor(props){
+        super(props)
+        this.state={
+            bill:[]
+        }
+        console.log('detailPage',props)
+    }
+
+    componentDidMount(){
+
+    }
+
+    componentWillUnmount(){
+
+    }
+
+    classBill(bill){
+
+    }
+
+    render() {
+        return (
+        <div>
+            <NavBars changePage={this.props.changePage} page="home"/>
+            <div className="deatilWrap">
+                detailPAGE
+            </div>
+        </div>
+        )
+    }
+}

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

@@ -73,7 +73,7 @@ class HomePage  extends Component{
                     <div className="buttonWrap">
                     <Buttons changePage={this.props.changePage} toPage='bill' buttonText='+ 记一笔'/>
                 </div>
-                <IconList bills={this.state.bills} week={{weekTop,weekBottom}}/>
+                <IconList bills={this.state.bills} week={{weekTop,weekBottom}} changePage={this.props.changePage} setDetail={this.props.setDetail}/>
             </div>
         )
     }

+ 30 - 14
src/case/BillApp/src/components/HomePage/IconList.jsx

@@ -1,6 +1,7 @@
 import React, { Component } from 'react';
 import { List } from 'antd-mobile';
 import {collectByDate} from '../../untils/date'
+//import {setSessionStorage} from '../../untils/session_help'
 const Item = List.Item;
 
 
@@ -20,7 +21,6 @@ export default class IconList extends Component{
         }
     }
     componentWillReceiveProps(props){
-        
         let {bills,week}=props
         this.getDayCollect(bills)
         this.getWeekCollect(bills,week)
@@ -30,14 +30,14 @@ export default class IconList extends Component{
 
     
     getDayCollect(bills=[]){
-
         let day=new Date().toDateString()
-
-        console.log(day)
-
         bills.forEach((item)=>{
             let itemDay=new Date(item.time).toDateString()
             if(itemDay===day){
+
+                console.log('todayBill',[item])
+                //setSessionStorage('todayBill',[item])
+
                 if(item.class==='pay'){
                     this.setState({
                         dayPay:item.money
@@ -50,6 +50,7 @@ export default class IconList extends Component{
                 return 0
             }
         })
+        
 
     }
 
@@ -60,6 +61,8 @@ export default class IconList extends Component{
        // console.log(bottom,top)
         let weeks=collectByDate(bills,bottom,top)
         //console.log('weeks',weeks)
+        console.log('weekBill',weeks.arr)
+        //setSessionStorage('weekBill',weeks.arr)
         this.setState({
             weekPay:weeks.Pay,
             weekIncome:weeks.Income
@@ -71,8 +74,10 @@ export default class IconList extends Component{
         const year=new Date().getFullYear()
         let bottom=new Date(year+'/'+month+'/1').getTime(),
             top=new Date(year+'/'+month+'/31').getTime();
-        let collect=collectByDate(bills,bottom,top)
-        this.setState({monthPay:collect.Pay,monthIncome:collect.Income})
+        let months=collectByDate(bills,bottom,top)
+        console.log('monthBill',months.arr)
+        //setSessionStorage('monthBill',months.arr)
+        this.setState({monthPay:months.Pay,monthIncome:months.Income})
     }
 
     getAllCollect(bills=[]){
@@ -84,12 +89,11 @@ export default class IconList extends Component{
                 allIncome+=item.money
             }
         })
-
+        console.log('allBill',bills)
+        //setSessionStorage('allBill',bills)
         this.setState({allPay,allIncome})
     }
 
-    
-
     render(){
         return (
             <div className="listWrap">
@@ -97,7 +101,10 @@ export default class IconList extends Component{
                     <Item
                     thumb="https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/today.svg"
                     arrow="horizontal"
-                    onClick={() => {}}
+                    onClick={() => {
+                        this.props.setDetail('day')
+                        this.props.changePage('detail')
+                    }}
                     >
                         <div className="itemWrap">
                             <div>今日</div>
@@ -111,7 +118,10 @@ export default class IconList extends Component{
                 <List>
                     <Item
                     thumb="https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/week.svg"
-                    onClick={() => {}}
+                    onClick={() => {
+                        this.props.setDetail('week')
+                        this.props.changePage('detail')
+                    }}
                     arrow="horizontal"
                     >
                     <div className="itemWrap">
@@ -126,7 +136,10 @@ export default class IconList extends Component{
                 <List>
                     <Item
                     thumb="https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/month.svg"
-                    onClick={() => {}}
+                    onClick={() => {
+                        this.props.setDetail('month')
+                        this.props.changePage('detail')
+                    }}
                     arrow="horizontal"
                     >
                     <div className="itemWrap">
@@ -141,7 +154,10 @@ export default class IconList extends Component{
                 <List>
                     <Item
                     thumb="https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/all.svg"
-                    onClick={() => {}}
+                    onClick={() => {
+                        this.props.setDetail('all')
+                        this.props.changePage('detail')
+                    }}
                     arrow="horizontal"
                     >
                     <div className="itemWrap">

+ 1 - 1
src/case/BillApp/src/untils/date.js

@@ -49,7 +49,7 @@ export function collectByDate(arr=[],bottom,top){
             Income+=item.money
         }
     })
-    return{Pay,Income}
+    return{Pay,Income,arr}
 }
 
 

+ 7 - 0
src/case/BillApp/src/untils/session_help.js

@@ -0,0 +1,7 @@
+export const setSessionStorage = (key,value) =>{
+    return sessionStorage.setItem(key,JSON.stringify(value))  
+}
+
+export const getSessionStorage = (key)=>{
+    return JSON.parse(sessionStorage.getItem(key))
+}