Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/pages/cart/orders/index.js
Csy817 6 years ago
parent
commit
adcfb9d98d

+ 1 - 1
src/pages/home/detail/index.css

@@ -8,7 +8,7 @@
 
 .detail-navbar-wrap {
     width: 100%;
-    height: 5%
+    height: 5%;
 }
 
 .detail-navbar {

+ 8 - 6
src/pages/home/kind/index.css

@@ -2,13 +2,13 @@
 }
 
 .kind-search-wrap {
-    height: 8%;
+    height: 60px;
     position: relative;
-    z-index: 100;
+    z-index: -1;
 }
 
 .kind-search {
-    height: 65%;
+    height: 40px;
     width: 90%;
     position: absolute;
     left: 50%;
@@ -20,16 +20,18 @@
     height: 100%;
     background-color: white;
     position: relative;
+    z-index: -1;
 }
 
 .kind-navbar-wrap {
     width: 100%;
-    /*height: 5%*/
+    height: 45px;
+    z-index: 1
 }
 
 .kind-navbar {
-    /*position: fixed;*/
-    /*top: 0;*/
+    position: fixed;
+    top: 0;
     width: 100%;
 }
 

+ 1 - 1
src/pages/home/kind/index.js

@@ -28,7 +28,7 @@ class Kind extends Component {
 
     render() {
         let {id} = this.state
-        let contentHeight = window.innerHeight
+        let contentHeight = window.innerHeight - 105
         return (
             <div className='kind-wrap'  style={{height: contentHeight}}>
                 <div className='kind-navbar-wrap'>

+ 59 - 6
src/pages/my/order/index.js

@@ -1,34 +1,43 @@
 import React, {Component} from 'react'
 import './index.css'
-import {NavBar, Icon} from 'antd-mobile'
+import {NavBar, Icon, ActivityIndicator} from 'antd-mobile'
 import {withRouter} from 'react-router-dom'
+import {orderbyprops} from "../../../utils/gql"
+import {Query} from "react-apollo"
+import gql from "graphql-tag"
 
 class Order extends Component {
     constructor(props) {
         super(props)
         this.state = {
             navTitle: '',
-            page: 'pay'
+            page: 'pay',
+            orderStatus: ''
         }
     }
 
     componentWillMount() {
         let {location} = this.props
         if (location && location.state) {
-            let navTitle = ''
+            let navTitle = '',
+                orderStatus = '0'
             let page = location.state.page
             switch (page) {
                 case 'pay':
                     navTitle = '待付款'
+                    orderStatus = '0'
                     break
                 case 'ship':
                     navTitle = '待发货'
+                    orderStatus = '1'
                     break
                 case 'unbox':
                     navTitle = '待收货'
+                    orderStatus = '2'
                     break
                 case 'judge':
                     navTitle = '待评价'
+                    orderStatus = '3'
                     break
                 default:
                     navTitle = '无效页面'
@@ -36,13 +45,14 @@ class Order extends Component {
             }
             this.setState({
                 navTitle,
-                page
+                page,
+                orderStatus
             })
         }
     }
 
     render() {
-        let {navTitle} = this.state
+        let {navTitle, orderStatus} = this.state
         return (
             <div className='order-wrap'>
                 <div className='order-navbar-wrap'>
@@ -55,9 +65,52 @@ class Order extends Component {
                         }}
                     >{navTitle}</NavBar>
                 </div>
+                <Query query={gql(orderbyprops)} variables={{user_id: "obR_j5ILjLjFSuBjj_UymjQjMNZc", orderStatus}}>
+                    {
+                        ({loading, error, data}) => {
+                            if (loading) {
+                                return (
+                                    <div className="loading-center">
+                                        <ActivityIndicator text="Loading..." size="large"/>
+                                    </div>
+                                )
+                            }
+                            if (error) {
+                                return 'error!'
+                            }
+                            return (
+                                <OrderRender data={data.orderbyprops}/>
+                            )
+                        }
+                    }
+                </Query>
+
             </div>
         )
     }
 }
 
-export default withRouter(Order)
+export default withRouter(Order)
+
+class OrderRender extends Component {
+    constructor(props) {
+        super(props)
+        this.state = {}
+    }
+
+    render() {
+        let {data} = this.props
+        console.log(data)
+        return (
+            <div>
+                {
+                    data.map(order=>(
+                        <div key={order.id}>
+                            {order.productTotalPay}
+                        </div>
+                    ))
+                }
+            </div>
+        )
+    }
+}

+ 49 - 1
src/utils/gql.js

@@ -85,9 +85,57 @@ default: $default city: $city username: $username postcode: $postcode createdAt:
     }
 }
 `
+const orderbyprops = `
+    query orderbyprops($deliveryTime: String, $updatedAt: String, $orderLogistics_id: ID, $payTime: String, $orderTotalPay: Float, $createdAt: String, $orderStatus: String, $userAddress_id: ID, $orderShipFee: Float, $count: Int, $user_id: ID, $productTotalPay: Float, $orderPay_id: 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
+            updatedAt
+            orderLogistics_id {
+                updatedAt
+                logisticsFee
+                expressId
+                createdAt
+                consigneeTel
+                id
+                consignAddress
+                LogisticsStatus
+                consigneeName
+            }
+            payTime
+            orderTotalPay
+            createdAt
+            orderStatus
+            userAddress_id {
+                address
+                updatedAt
+                telephone
+            default
+                city
+                username
+                postcode
+                createdAt
+                deletedAt
+                id
+                area
+                province
+            }
+            id
+            orderShipFee
+            count
+            productTotalPay
+            orderPay_id {
+                id
+                totalPay
+                transactionId
+                payTime
+            }
+        }
+    }
+`
 export {
     productbyprops,
     productbyid,
     cart_by_userid,
-    userAddressbyprops
+    userAddressbyprops,
+    orderbyprops
 }