Browse Source

修复订单中心不能加载数据的问题

wly 7 năm trước cách đây
mục cha
commit
8dcb025f87

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

@@ -41,12 +41,7 @@ class BillApp extends Component{
     console.log(page)
     console.log(page)
     this.setState({page})
     this.setState({page})
   }
   }
-  renderBottom(){
-    let page=this.state.page
-    if(page==='home'||page==='assets'||page==='my'){
-      return(<TabBarBottom changePage={this.changePage}/>)
-    }
-  }
+  
 
 
   setDetail(detail){
   setDetail(detail){
     this.setState({detail})
     this.setState({detail})
@@ -113,6 +108,13 @@ class BillApp extends Component{
           )
           )
     }
     }
   }
   }
+  //是否渲染底部bar
+  renderBottom(){
+    let page=this.state.page
+    if(page==='home'||page==='assets'||page==='my'){
+      return(<TabBarBottom changePage={this.changePage}/>)
+    }
+  }
 
 
   render(){
   render(){
     const changePage=this.changePage
     const changePage=this.changePage

+ 0 - 1
src/case/BillApp/src/api/billsGraphql.txt

@@ -96,7 +96,6 @@ query tagbyprops($user_id: ID, $account_id: ID, $name: String, $icon: String, $c
         }
         }
         account_id {
         account_id {
             id
             id
-
             accountName
             accountName
             createdAt
             createdAt
             updateAt
             updateAt

+ 51 - 0
src/case/BillApp/src/api/graphql/tag.js

@@ -0,0 +1,51 @@
+export const TAG_BY_PROPS=`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
+
+            accountName
+            createdAt
+            updateAt
+        }
+        name
+        icon
+        createdAt
+        updateAt
+    }
+}`
+
+export const CREATE_TAG=`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
+
+            accountName
+            createdAt
+            updateAt
+        }
+        name
+        icon
+        createdAt
+        updateAt
+    }
+}`

+ 85 - 70
src/case/BillApp/src/components/Bill/Bill.jsx

@@ -1,68 +1,73 @@
 import React, { Component } from 'react'
 import React, { Component } from 'react'
 import TabBar from './TabBar'
 import TabBar from './TabBar'
 import NavBars from '../common/NavBar'
 import NavBars from '../common/NavBar'
+import Pickers from '../common/Picker'
+import Input from '../common/Input'
+import {  WhiteSpace } from 'antd-mobile';
+
 
 
 import {graphqls} from '../../api/graphql_request'
 import {graphqls} from '../../api/graphql_request'
 import {ACCOUNT_BY_PROPS} from '../../api/graphql/account'
 import {ACCOUNT_BY_PROPS} from '../../api/graphql/account'
-import {CLASS_BY_PROPS} from '../../api/graphql/class'
+import {TAG_BY_PROPS} from '../../api/graphql/tag'
 import {CREATE_BILL} from '../../api/graphql/bills'
 import {CREATE_BILL} from '../../api/graphql/bills'
 
 
 import {failToast} from '../common/Toast'
 import {failToast} from '../common/Toast'
 
 
+
+
+
 let user_id=sessionStorage.getItem('openid')
 let user_id=sessionStorage.getItem('openid')
 
 
 export default class Bill extends Component {
 export default class Bill extends Component {
   constructor(props){
   constructor(props){
-      super(props)
-      this.state={
-          tabs:[{title:'收入'},{title:'支出'}],
-          class:'收入',
-          account:[],
-          classs:[],
-          account_id:'',
-          time:'',
-          remark:'',
-          money:'',
-          tag_id:''
-
-      }
+    super(props)
+    this.state={
+        picker:[],
+        tabs:[{title:'收入'},{title:'支出'}],
+        class:'收入',
+        account:[],
+        tags:[],
+        account_id:'',
+        time:'',
+        remark:'',
+        money:'',
+        tag_id:'',
+        showPicker:false
+    }
 
 
     this.tabChange=this.tabChange.bind(this)
     this.tabChange=this.tabChange.bind(this)
     this.handleSubmit=this.handleSubmit.bind(this)
     this.handleSubmit=this.handleSubmit.bind(this)
+    this.setMoney=this.setMoney.bind(this)
+    this.setAccount_id=this.setAccount_id.bind(this)
+    this.setTime=this.setTime.bind(this)
+    this.setRemark=this.setRemark.bind(this)
+    this.handleSubmit=this.handleSubmit.bind(this)
+    this.showAccountPicker=this.showAccountPicker.bind(this)
+    this.showTimetPicker=this.showTimetPicker.bind(this)
+    this.showTagPicker=this.showTagPicker.bind(this)
   }
   }
 
 
   componentDidMount(){
   componentDidMount(){
+    
     this.getAccount()
     this.getAccount()
-    this.getClass()
+    this.getTag()
   }
   }
 
 
   getAccount(){
   getAccount(){
-   
     console.log(user_id)
     console.log(user_id)
     graphqls(ACCOUNT_BY_PROPS,{user_id}).then((e)=>{
     graphqls(ACCOUNT_BY_PROPS,{user_id}).then((e)=>{
-        console.log(e.accountbyprops)
-        this.setState({
-            account:e.accountbyprops
-        })
+        //console.log('account',e.accountbyprops)
+        this.setState({account:e.accountbyprops})
     })
     })
   }
   }
 
 
-  getClass(){
+  getTag(){
     let user_id=sessionStorage.getItem('openid')
     let user_id=sessionStorage.getItem('openid')
-    graphqls(CLASS_BY_PROPS,{user_id}).then((e)=>{
-        console.log(e.classbyprops)
-        this.setState({
-            classs:e.classbyprops
-        })
+    graphqls(TAG_BY_PROPS,{user_id}).then((e)=>{
+        this.setState({account:e.accountbyprops})
     })
     })
   }
   }
 
 
-
-  tabChange(e){
-      console.log(e)
-      this.setState({class:e.title})
-  }
-
   handleSubmit(e){
   handleSubmit(e){
     e.preventDefault()
     e.preventDefault()
     let data={
     let data={
@@ -94,56 +99,66 @@ export default class Bill extends Component {
         failToast('所有选项不能为空',1)
         failToast('所有选项不能为空',1)
     }
     }
   }
   }
+  //picker
+  showAccountPicker(){
+    
+    this.setState({showPicker:true})
+  }
+  showTimetPicker(){
+      
+  }
+  showTagPicker(){
+    
+    this.setState({showPicker:true}) 
+  }
+  //设置state的函数
+  tabChange(e){
+    console.log(e)
+    this.setState({class:e.title})
+  }
+  setMoney(money){
+    console.log(money)
+    this.setState({money})
+  }
+  setAccount_id(account_id){
+    console.log(account_id)
+    this.setState({account_id})
+  }
+  setTime(time){
+    console.log(time)
+    this.setState({time})
+  }  
+  setRemark(remark){
+    console.log(remark)
+    this.setState({remark})
+  }
 
 
 
 
 
 
   render() {
   render() {
     const account=this.state.account
     const account=this.state.account
-    const classs=this.state.classs
+    const classs=this.state.classs  
     return (
     return (
       <div className="billWrap">
       <div className="billWrap">
         <NavBars page='home' navBarText='记一笔' changePage={this.props.changePage}/>
         <NavBars page='home' navBarText='记一笔' changePage={this.props.changePage}/>
         <TabBar tabs={this.state.tabs} tabChange={this.tabChange}/>
         <TabBar tabs={this.state.tabs} tabChange={this.tabChange}/>
         <form onSubmit={this.handleSubmit}>
         <form onSubmit={this.handleSubmit}>
-            <div className="moneyWrap row">
-                <label>金额:</label>
-                <input type="text" name="money" className="input" onChange={(e)=>this.setState({money:e.currentTarget.value})}/>
-            </div>
-            <div className="accountWrap row">
-                <label>账户:</label>
-                <select name="account" className="input" onChange={(e)=>this.setState({account_id:e.currentTarget.value})}>
-                    <option value="0">下拉选择你的账户</option>
-                    {
-                        account.map((item)=>{
-                            return(
-                                <option key={item.id} value={item.id}>{item.accountName}</option> 
-                            )
-                        })            
-                    } 
-                </select>
-            </div>
-
-            <div className="classWrap row">
-                <label>分类:</label>
-                <select name="class" className="input" onChange={(e)=>this.setState({tag_id:e.currentTarget.value})}>
-                    <option value="0">下拉选择你的分类</option>
-                    {
-                        classs.map((item)=>{
-                            return(
-                                <option key={item.id} value={item.id}>{item.name}</option> 
-                            )
-                        })            
-                    } 
-                </select>
-            </div>
-            <div className="timeWrap row">
-                <label>时间:</label><input type="text" name="time" className="input" placeholder="格式:2018/12/1 00:00:00" onChange={(e)=>this.setState({time:e.currentTarget.value})}/>
-            </div> 
-            <div className="remarkWrap row">
-                <label>备注:</label><input type="text" name="remark" className="input" onChange={(e)=>this.setState({remark:e.currentTarget.value})}/>
-            </div> 
+            <Input title="金额" callback={this.setMoney} value={this.state.money} />
+            <WhiteSpace />
+            <div onClick={this.showAccountPicker}><Input title="账户"  disabled={true} callback={this.setAccount_id} value={this.state.account_id} extra={true} /></div>
+            
+            <WhiteSpace />
+            <div onClick={this.showTagPicker}><Input title="分类"  disabled={true} extra={true} onClick={()=>{}}/></div>
+            
+            <WhiteSpace />
+            <div onClick={()=>{console.log('click time')}}><Input title="时间"  disabled={true} callback={this.setTime} value={this.state.time} extra={true} onClick={()=>{}}/></div>
+            
+            <WhiteSpace />
+            <Input title="备注" callback={this.setRemark} value={this.state.remark}/>
             <button className="submit" type="submit">保存</button>
             <button className="submit" type="submit">保存</button>
         </form>
         </form>
+        <div style={this.state.showPicker?{}:{display:"none"}}><Pickers data={this.state.picker}/></div>
+    
       </div>
       </div>
     )
     )
   }
   }

+ 19 - 3
src/case/BillApp/src/components/BillDetail/BillDetail.jsx

@@ -1,10 +1,26 @@
 import React, { Component } from 'react'
 import React, { Component } from 'react'
 
 
 import NavBars from '../common/NavBar'
 import NavBars from '../common/NavBar'
+import Pickers from '../common/Picker'
+
 
 
 //import {setSessionStorage,getSessionStorage} from '../../untils/session_help'
 //import {setSessionStorage,getSessionStorage} from '../../untils/session_help'
 import {collectByDate} from '../../untils/date'
 import {collectByDate} from '../../untils/date'
 
 
+
+
+
+const season = [
+    {
+      label: '春',
+      value: '春',
+    },
+    {
+      label: '夏',
+      value: '夏',
+    },
+  ];
+
 export default class BillDetail extends Component {
 export default class BillDetail extends Component {
     constructor(props){
     constructor(props){
         super(props)
         super(props)
@@ -14,8 +30,8 @@ export default class BillDetail extends Component {
         console.log('detailPage',props)
         console.log('detailPage',props)
     }
     }
 
 
-    componentDidMount(){
-
+    componentDidMount(props){
+        
     }
     }
 
 
     componentWillUnmount(){
     componentWillUnmount(){
@@ -31,7 +47,7 @@ export default class BillDetail extends Component {
         <div>
         <div>
             <NavBars changePage={this.props.changePage} page="home"/>
             <NavBars changePage={this.props.changePage} page="home"/>
             <div className="deatilWrap">
             <div className="deatilWrap">
-                detailPAGE
+                <Pickers data={season}/>
             </div>
             </div>
         </div>
         </div>
         )
         )

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

@@ -37,7 +37,7 @@ export default class IconList extends Component{
 
 
                 //console.log('todayBill',[item])
                 //console.log('todayBill',[item])
                 //setSessionStorage('todayBill',[item])
                 //setSessionStorage('todayBill',[item])
-
+                
                 if(item.class==='pay'){
                 if(item.class==='pay'){
                     this.setState({
                     this.setState({
                         dayPay:item.money
                         dayPay:item.money
@@ -55,7 +55,6 @@ export default class IconList extends Component{
     }
     }
 
 
     getWeekCollect(bills,week){
     getWeekCollect(bills,week){
-
         let bottom=new Date(week.weekBottom).getTime(),
         let bottom=new Date(week.weekBottom).getTime(),
             top=new Date(week.weekTop).getTime();
             top=new Date(week.weekTop).getTime();
        // console.log(bottom,top)
        // console.log(bottom,top)

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

@@ -5,6 +5,7 @@ import {collectByDate} from '../../untils/date'
 const Item = List.Item;
 const Item = List.Item;
 
 
 export default class Lists extends React.Component {
 export default class Lists extends React.Component {
+  
   state = {
   state = {
     disabled: false,
     disabled: false,
     monthPay:0.00,
     monthPay:0.00,
@@ -19,7 +20,6 @@ export default class Lists extends React.Component {
     let collect=collectByDate(bills,bottom,top)
     let collect=collectByDate(bills,bottom,top)
     
     
     this.setState({monthPay:collect.Pay,monthIncome:collect.Income})
     this.setState({monthPay:collect.Pay,monthIncome:collect.Income})
-    
     //console.log('---',collect)
     //console.log('---',collect)
   }
   }
 
 

+ 28 - 0
src/case/BillApp/src/components/common/Input.jsx

@@ -0,0 +1,28 @@
+import React, { Component } from 'react'
+import { List, InputItem, WhiteSpace } from 'antd-mobile';
+import { createForm } from 'rc-form';
+
+export default class Input extends Component {
+  render() {
+    const placeholder=this.props.placeholder||''
+    const extra=this.props.extra?{display:"block",background:"url(https://wly-1254337200.cos.ap-guangzhou.myqcloud.com/right.svg)",backgroundSize:"cover",width:"14px",height:"14px"}:{display:"block",background:"transparent",backgroundSize:"cover",width:"14px",height:"14px"}
+    const disabled =this.props.disabled||false
+    const callback=this.props.callback
+    const value=this.props.value
+    return (
+      <div style={{width:"246px"}}>
+        <List>
+            <InputItem
+                clear
+                value={value}
+                placeholder={placeholder}
+                ref={el => this.autoFocusInst = el}
+                extra={<span style={extra}></span>}
+                disabled={disabled}
+                onChange={(e)=>{callback(e)}}
+            >{this.props.title}</InputItem>
+        </List>
+      </div>
+    )
+  }
+}

+ 18 - 0
src/case/BillApp/src/components/common/Picker.jsx

@@ -0,0 +1,18 @@
+import React, { Component } from 'react'
+import { PickerView, WhiteSpace } from 'antd-mobile';
+
+export default class Pickers extends Component {
+  render() {
+    const data=this.props.data
+    return (
+        <div style={{position:"absolute",bottom:"0",left:"0",width:"100%",background:"#fff"}}>
+            <PickerView
+                data={data}
+                cascade={false}
+                indicatorStyle={{bottom:"0"}}
+                onScrollChange={(e)=>{console.log(e)}}
+            />
+        </div>
+    )
+  }
+}

+ 1 - 1
src/case/BillApp/src/components/context.js

@@ -1,5 +1,5 @@
 import React from 'react'
 import React from 'react'
 
 
 export const PageContext=React.createContext()
 export const PageContext=React.createContext()
-export const NumContext=React.createContext()
+
 
 

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

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

+ 1 - 2
src/case/OrderApp/src/components/UserPage/userPage.jsx

@@ -13,8 +13,7 @@ class UserPage extends Component{
         this.state={
         this.state={
 
 
         }
         }
-
-
+        
         this.toOrder=this.toOrder.bind(this)
         this.toOrder=this.toOrder.bind(this)
     }
     }
 
 

+ 0 - 13
src/case/ShopApp/src/api/graphql/order.js

@@ -2,19 +2,6 @@ export const getOrderByProps=`query orderbyprops($deliveryTime: String, $updated
     orderbyprops: order_by_props(deliveryTime: $deliveryTime updatedAt: $updatedAt orderLogistics_id: $orderLogistics_id payTime: $payTime orderTotalPay: $orderTotalPay createdAt: $createdAt orderStatus: $orderStatus userAddress_id: $userAddress_id orderShipFee: $orderShipFee count: $count user_id: $user_id productTotalPay: $productTotalPay orderPay_id: $orderPay_id) {
     orderbyprops: order_by_props(deliveryTime: $deliveryTime updatedAt: $updatedAt orderLogistics_id: $orderLogistics_id payTime: $payTime orderTotalPay: $orderTotalPay createdAt: $createdAt orderStatus: $orderStatus userAddress_id: $userAddress_id orderShipFee: $orderShipFee count: $count user_id: $user_id productTotalPay: $productTotalPay orderPay_id: $orderPay_id) {
         deliveryTime
         deliveryTime
         updatedAt
         updatedAt
-        orderLogistics_id {
-            updatedAt
-            logisticsFee
-            expressId
-            createdAt
-
-            consigneeTel
-            id
-            consignAddress
-            LogisticsStatus
-
-            consigneeName
-        }
         payTime
         payTime
         orderTotalPay
         orderTotalPay
         createdAt
         createdAt

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

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

+ 1 - 1
src/case/ShopApp/src/components/AddressPage/AddressPage.jsx

@@ -31,7 +31,7 @@ class AddressPage extends Component {
 
 
   getAddress(data){
   getAddress(data){
     graphqls(getAddressByProps,data).then((res)=>{
     graphqls(getAddressByProps,data).then((res)=>{
-        console.log(res.userAddressbyprops)
+        //console.log(res.userAddressbyprops)
         this.setState({
         this.setState({
           addressList:res.userAddressbyprops
           addressList:res.userAddressbyprops
         })
         })

+ 1 - 1
src/case/ShopApp/src/components/AddressPage/FormAddress.jsx

@@ -84,7 +84,7 @@ export default class FormAddress extends Component {
     })
     })
   }
   }
 
 
-  areaChange(e){
+  areaChange(e=[0]){
     console.log('e',e)
     console.log('e',e)
     console.log(district)
     console.log(district)
 
 

+ 7 - 4
src/case/ShopApp/src/components/OrderCenterPage/OrderCenterPage.jsx

@@ -11,6 +11,8 @@ import {PageContext} from '../../context/context'
 import {graphqls} from '../../api/graphql_request'
 import {graphqls} from '../../api/graphql_request'
 import {getOrderByProps,getProductByProps,DELETE_ORDER,DELETE_ORDER_PRODUCT} from '../../api/graphql/order'
 import {getOrderByProps,getProductByProps,DELETE_ORDER,DELETE_ORDER_PRODUCT} from '../../api/graphql/order'
 
 
+import config from "../../api/url_config";
+
 class OrderCenterPage extends Component {
 class OrderCenterPage extends Component {
   constructor(props){
   constructor(props){
     super(props)
     super(props)
@@ -27,19 +29,18 @@ class OrderCenterPage extends Component {
   }
   }
 
 
   componentDidMount(){
   componentDidMount(){
-    let user_id=sessionStorage.getItem('openid')
+    let user_id='ovtkn4zONC3IzhpykQ7cSLZ85YFg'
     this.getOrder({user_id})
     this.getOrder({user_id})
   }
   }
   //获取订单,并根据订单id获取订单产品信息,之后重构数据结构
   //获取订单,并根据订单id获取订单产品信息,之后重构数据结构
   getOrder(data){
   getOrder(data){
     graphqls(getOrderByProps,data).then((res)=>{
     graphqls(getOrderByProps,data).then((res)=>{
-        //console.log(res.orderbyprops)
+        console.log('order',res)
         let orderArr=res.orderbyprops||[]
         let orderArr=res.orderbyprops||[]
         for(let i=0;i<orderArr.length;i++){
         for(let i=0;i<orderArr.length;i++){
             //根据order_id获取订单产品信息,可以优化,可以只发出一次请求获取所有订单产品信息之后再经行处理
             //根据order_id获取订单产品信息,可以优化,可以只发出一次请求获取所有订单产品信息之后再经行处理
             graphqls(getProductByProps,{order_id:orderArr[i].id}).then((res)=>{
             graphqls(getProductByProps,{order_id:orderArr[i].id}).then((res)=>{
-                //console.log('order_id',orderArr[i].id)
-                //console.log('getProductByProps',res)
+                console.log('getProductByProps',res)
                 orderArr[i].orderProducts=res.orderProductbyprops
                 orderArr[i].orderProducts=res.orderProductbyprops
                 
                 
                 if(i===orderArr.length-1){
                 if(i===orderArr.length-1){
@@ -55,6 +56,8 @@ class OrderCenterPage extends Component {
                 }
                 }
             })
             })
         }
         }
+    }).catch((e)=>{
+        console.log('catct',e)
     })
     })
   }
   }
 
 

+ 1 - 1
src/case/ShopApp/src/components/ProductDetailPage/Card.jsx

@@ -23,7 +23,7 @@ export default class Card extends Component{
         const product =this.state.product
         const product =this.state.product
         return (
         return (
             <div className="card">
             <div className="card">
-                <img src={product.img} alt="Avatar" style={{width:"100%",height:'200px'}}/>
+                <img src={product.img||''} alt="Avatar" style={{width:"100%",height:'200px'}}/>
                 <div className="container">
                 <div className="container">
                     <h4>{product.name}</h4> 
                     <h4>{product.name}</h4> 
                     <p style={{fontSize:"12px"}}>{product.intro}</p>
                     <p style={{fontSize:"12px"}}>{product.intro}</p>