Procházet zdrojové kódy

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

xy před 7 roky
rodič
revize
fcfe08d976

+ 5 - 5
src/case/BillApp/src/App.js

@@ -7,7 +7,7 @@ import config from './api/url_config'
 
 import NavBars from './components/App/NavBar'
 import TabBarBottom from './components/App/TabBarBottom'
-import Bill from './components/Bill/Bill'
+import HomePage from './components/HomePage/HomePage'
 import Assets from './components/Assets/Assets'
 import My from './components/My/My'
 
@@ -21,7 +21,7 @@ class BillApp extends Component{
     super()
     //初始化状态
     this.state={
-      page:"bill",
+      page:"home",
       navBarText:'微记账本'
     }
 
@@ -41,7 +41,7 @@ class BillApp extends Component{
 
   renderBottom(){
     let page=this.state.page
-    if(page==='bill'||page==='assets'||page==='my'){
+    if(page==='home'||page==='assets'||page==='my'){
       return(<TabBarBottom changePage={this.changePage}/>)
     }
   }
@@ -49,11 +49,11 @@ class BillApp extends Component{
   //根据状态渲染页面
   renderPage(page){
     switch(page){
-      case ('bill'):
+      case ('home'):
         return(
           <div className="pageWrap">
             <div className="scrollPage">
-              <Bill setNavBarText={this.setNavBarText}/>
+              <HomePage setNavBarText={this.setNavBarText}/>
             </div>
           </div>
           )

+ 9 - 10
src/case/BillApp/src/api/graphql/bills.js

@@ -1,25 +1,24 @@
-export const  getBill=`query billbyprops($account_id: ID, $tag_id: ID, $money: Float, $class: String, $remark: String, $createdAt: String, $updateAt: String) {
-    billbyprops: bill_by_props(account_id: $account_id tag_id: $tag_id money: $money class: $class remark: $remark createdAt: $createdAt updateAt: $updateAt) {
-        id
+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) {
+        money
+        updateAt
+        remark
         account_id {
             id
-
             accountName
             createdAt
             updateAt
         }
+        time
+        createdAt
+        id
+        class
         tag_id {
             id
-
             name
             icon
             createdAt
             updateAt
         }
-        money
-        class
-        remark
-        createdAt
-        updateAt
     }
 }`

+ 430 - 0
src/case/BillApp/src/api/graphql/billsGraphql.txt

@@ -0,0 +1,430 @@
+query collectbyid($id: ID) {
+    collectbyid: collect_by_id(id: $id) {
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        month
+        createdAt
+        allIncome
+        allPay
+        year
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+    }
+}
+
+query userbyid($id: ID) {
+    userbyid: user_by_id(id: $id) {
+        id
+        openid
+        username
+        password
+        avatar
+        createdAt
+        updateAt
+    }
+}
+
+query accountbyid($id: ID) {
+    accountbyid: account_by_id(id: $id) {
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+        accountName
+        createdAt
+        updateAt
+    }
+}
+
+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) {
+        id
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        name
+        icon
+        createdAt
+        updateAt
+    }
+}
+
+query billbyid($id: ID) {
+    billbyid: bill_by_id(id: $id) {
+        money
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        time
+        createdAt
+        id
+        class
+        tag_id {
+            id
+
+            name
+            icon
+            createdAt
+            updateAt
+        }
+    }
+}
+
+query accountbyprops($user_id: ID, $accountName: String, $createdAt: String, $updateAt: String) {
+    accountbyprops: account_by_props(user_id: $user_id accountName: $accountName createdAt: $createdAt updateAt: $updateAt) {
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+        accountName
+        createdAt
+        updateAt
+    }
+}
+
+query tagbyid($id: ID) {
+    tagbyid: tag_by_id(id: $id) {
+        id
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        name
+        icon
+        createdAt
+        updateAt
+    }
+}
+
+query collectbyprops($updateAt: String, $remark: String, $account_id: ID, $month: String, $createdAt: String, $allIncome: Float, $allPay: Float, $year: String, $user_id: ID) {
+    collectbyprops: collect_by_props(updateAt: $updateAt remark: $remark account_id: $account_id month: $month createdAt: $createdAt allIncome: $allIncome allPay: $allPay year: $year user_id: $user_id) {
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        month
+        createdAt
+        allIncome
+        allPay
+        year
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+    }
+}
+
+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) {
+        money
+        updateAt
+        remark
+        account_id {
+            id
+            accountName
+            createdAt
+            updateAt
+        }
+        time
+        createdAt
+        id
+        class
+        tag_id {
+            id
+
+            name
+            icon
+            createdAt
+            updateAt
+        }
+    }
+}
+
+query userbyprops($openid: String, $username: String, $password: String, $avatar: String, $createdAt: String, $updateAt: String) {
+    userbyprops: user_by_props(openid: $openid username: $username password: $password avatar: $avatar createdAt: $createdAt updateAt: $updateAt) {
+        id
+        openid
+        username
+        password
+        avatar
+        createdAt
+        updateAt
+    }
+}
+
+mutation createuser($id: ID!, $openid: String, $username: String, $password: String, $avatar: String, $createdAt: String, $updateAt: String) {
+    createuser: create_user(id: $id openid: $openid username: $username password: $password avatar: $avatar createdAt: $createdAt updateAt: $updateAt) {
+        id
+        openid
+        username
+        password
+        avatar
+        createdAt
+        updateAt
+    }
+}
+
+mutation deleteaccount($id: ID, $user_id: ID, $accountName: String, $createdAt: String, $updateAt: String) {
+    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) {
+        money
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        time
+        createdAt
+        id
+        class
+        tag_id {
+            id
+
+            name
+            icon
+            createdAt
+            updateAt
+        }
+    }
+}
+
+mutation deletecollect($updateAt: String, $remark: String, $account_id: ID, $month: String, $createdAt: String, $allIncome: Float, $allPay: Float, $year: String, $id: ID, $user_id: ID) {
+    deletecollect: delete_collect(updateAt: $updateAt remark: $remark account_id: $account_id month: $month createdAt: $createdAt allIncome: $allIncome allPay: $allPay year: $year id: $id user_id: $user_id)
+}
+
+mutation updateuser($id: ID, $openid: String, $username: String, $password: String, $avatar: String, $createdAt: String, $updateAt: String) {
+    updateuser: update_user(id: $id openid: $openid username: $username password: $password avatar: $avatar createdAt: $createdAt updateAt: $updateAt) {
+        id
+        openid
+        username
+        password
+        avatar
+        createdAt
+        updateAt
+    }
+}
+
+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) {
+        id
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        name
+        icon
+        createdAt
+        updateAt
+    }
+}
+
+mutation createcollect($updateAt: String, $remark: String, $account_id: ID, $month: String, $createdAt: String, $allIncome: Float, $allPay: Float, $year: String, $id: ID!, $user_id: ID) {
+    createcollect: create_collect(updateAt: $updateAt remark: $remark account_id: $account_id month: $month createdAt: $createdAt allIncome: $allIncome allPay: $allPay year: $year id: $id user_id: $user_id) {
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        month
+        createdAt
+        allIncome
+        allPay
+        year
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+    }
+}
+
+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) {
+        id
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        name
+        icon
+        createdAt
+        updateAt
+    }
+}
+
+mutation deleteuser($id: ID, $openid: String, $username: String, $password: String, $avatar: String, $createdAt: String, $updateAt: String) {
+    deleteuser: delete_user(id: $id openid: $openid username: $username password: $password avatar: $avatar createdAt: $createdAt updateAt: $updateAt)
+}
+
+mutation updateaccount($id: ID, $user_id: ID, $accountName: String, $createdAt: String, $updateAt: String) {
+    updateaccount: update_account(id: $id user_id: $user_id accountName: $accountName createdAt: $createdAt updateAt: $updateAt) {
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+        accountName
+        createdAt
+        updateAt
+    }
+}
+
+mutation createaccount($id: ID!, $user_id: ID, $accountName: String, $createdAt: String, $updateAt: String) {
+    createaccount: create_account(id: $id user_id: $user_id accountName: $accountName createdAt: $createdAt updateAt: $updateAt) {
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+        accountName
+        createdAt
+        updateAt
+    }
+}
+
+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 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 updatecollect($updateAt: String, $remark: String, $account_id: ID, $month: String, $createdAt: String, $allIncome: Float, $allPay: Float, $year: String, $id: ID, $user_id: ID) {
+    updatecollect: update_collect(updateAt: $updateAt remark: $remark account_id: $account_id month: $month createdAt: $createdAt allIncome: $allIncome allPay: $allPay year: $year id: $id user_id: $user_id) {
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        month
+        createdAt
+        allIncome
+        allPay
+        year
+        id
+        user_id {
+            id
+            openid
+            username
+            password
+            avatar
+            createdAt
+            updateAt
+        }
+    }
+}
+
+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) {
+        money
+        updateAt
+        remark
+        account_id {
+            id
+
+            accountName
+            createdAt
+            updateAt
+        }
+        time
+        createdAt
+        id
+        class
+        tag_id {
+            id
+
+            name
+            icon
+            createdAt
+            updateAt
+        }
+    }
+}

+ 1 - 1
src/case/BillApp/src/components/App/TabBarBottom.jsx

@@ -55,7 +55,7 @@ class TabBarBottom extends React.Component {
               this.setState({
                 selectedTab: 'bill',
               });
-              this.handleChange('bill')
+              this.handleChange('home')
             }}
             data-seed="logId"
           >

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


+ 0 - 0
src/case/BillApp/src/components/Bill/Bill.css → src/case/BillApp/src/components/HomePage/HomePage.css


+ 5 - 5
src/case/BillApp/src/components/Bill/Bill.jsx → src/case/BillApp/src/components/HomePage/HomePage.jsx

@@ -5,16 +5,16 @@ import Buttons from './Button'
 import IconList from './IconList'
 
 import {graphqls} from '../../api/graphql_request'
-import {getBill} from '../../api/graphql/bills'
+import {BILL_BY_PROPS} from '../../api/graphql/bills'
 import {getMonDayAndSunDay} from '../../untils/date'
 
 
 
 
 
-import './Bill.css'
+import './HomePage.css'
 //console.log(new Date().toLocaleString('chinese', { hour12: false }).slice(0,10))
-class Bill  extends Component{
+class HomePage  extends Component{
 
     constructor(props){
         super(props)
@@ -31,7 +31,7 @@ class Bill  extends Component{
 
 
     getBills(){
-        graphqls(getBill,{}).then((e)=>{
+        graphqls(BILL_BY_PROPS,{}).then((e)=>{
             console.log('1----',e.billbyprops)
             this.setState({
                 bills:e.billbyprops
@@ -71,4 +71,4 @@ class Bill  extends Component{
     }
 }
 
-export default Bill
+export default HomePage

+ 5 - 3
src/case/BillApp/src/components/Bill/IconList.jsx → src/case/BillApp/src/components/HomePage/IconList.jsx

@@ -20,8 +20,8 @@ export default class IconList extends Component{
         }
     }
     componentWillReceiveProps(props){
+        
         let {bills,week}=props
-
         this.getDayCollect(bills)
         this.getWeekCollect(bills,week)
         this.getMonthCollect(bills)
@@ -30,11 +30,13 @@ export default class IconList extends Component{
 
     
     getDayCollect(bills=[]){
+
         let day=new Date().toDateString()
+
         console.log(day)
 
         bills.forEach((item)=>{
-            let itemDay=new Date(item.createdAt).toDateString()
+            let itemDay=new Date(item.time).toDateString()
             if(itemDay===day){
                 if(item.class==='pay'){
                     this.setState({
@@ -68,7 +70,7 @@ export default class IconList extends Component{
         const month =new Date().getMonth()+1
         const year=new Date().getFullYear()
         let bottom=new Date(year+'/'+month+'/1').getTime(),
-        top=new Date(year+'/'+month+'/31').getTime();
+            top=new Date(year+'/'+month+'/31').getTime();
         let collect=collectByDate(bills,bottom,top)
         this.setState({monthPay:collect.Pay,monthIncome:collect.Income})
     }

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


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

@@ -39,7 +39,7 @@ export function collectByDate(arr=[],bottom,top){
     //console.log('log',bottom,top)
     let Pay=0,Income=0;
     arr=arr.filter((item)=>{
-        return (new Date(item.createdAt).getTime()>=bottom&&new Date(item.createdAt).getTime()<=top)
+        return (new Date(item.time).getTime()>=bottom&&new Date(item.time).getTime()<=top)
     })
 
     arr.forEach(item => {
@@ -49,7 +49,6 @@ export function collectByDate(arr=[],bottom,top){
             Income+=item.money
         }
     })
-
     return{Pay,Income}
 }