kulley 6 anos atrás
pai
commit
704b9e1654
2 arquivos alterados com 84 adições e 9 exclusões
  1. 28 8
      src/pages/my/order/index.js
  2. 56 1
      src/utils/gql.js

+ 28 - 8
src/pages/my/order/index.js

@@ -2,7 +2,7 @@ import React, {Component} from 'react'
 import './index.css'
 import {NavBar, Icon, ActivityIndicator} from 'antd-mobile'
 import {withRouter} from 'react-router-dom'
-import {orderbyprops} from "../../../utils/gql"
+import {orderbyprops, orderProduct_by_props} from "../../../utils/gql"
 import {Query} from "react-apollo"
 import gql from "graphql-tag"
 
@@ -98,7 +98,6 @@ class OrderRender extends Component {
 
     render() {
         let {data} = this.props
-        console.log(data)
         return (
             <div className='order-my-content'>
                 {
@@ -109,12 +108,33 @@ class OrderRender extends Component {
                         :
                         data.map(order => (
                             <div key={order.id} className='order-card'>
-                                <div className='order-card-top'>JD</div>
-                                <div className='order-card-content'></div>
-                                <div className='order-card-bottom'>
-                                    <div className='order-card-count'>共{order.count}件商品&nbsp;&nbsp;实付款:</div>
-                                    <div className='order-card-pay'>¥{order.productTotalPay}</div>
-                                    </div>
+                                <Query query={gql(orderProduct_by_props)} variables={{order_id: order.id}}>
+                                    {
+                                        ({loading, error, data}) => {
+                                            if (loading) {
+                                                return (
+                                                    <div className="loading-center">
+                                                        <ActivityIndicator text="Loading..." size="large"/>
+                                                    </div>
+                                                )
+                                            }
+                                            if (error) {
+                                                return 'error!'
+                                            }
+                                            console.log(data)
+                                            return (
+                                                <div>
+                                                    <div className='order-card-top'>JD</div>
+                                                    <div className='order-card-content'></div>
+                                                    <div className='order-card-bottom'>
+                                                        <div className='order-card-count'>共{order.count}件商品&nbsp;&nbsp;实付款:</div>
+                                                        <div className='order-card-pay'>¥{order.productTotalPay}</div>
+                                                    </div>
+                                                </div>
+                                            )
+                                        }
+                                    }
+                                </Query>
                             </div>
                         ))
                 }

+ 56 - 1
src/utils/gql.js

@@ -141,11 +141,66 @@ const orderbyprops = `
         }
     }
 `
+const orderProduct_by_props = `
+    query orderProductbyprops($remark: String, $updatedAt: String, $product_id: ID, $orderPay: Float, $createdAt: String, $order_id: ID, $count: Int, $productPay: Float, $user_id: ID) {
+        orderProductbyprops: orderProduct_by_props(remark: $remark updatedAt: $updatedAt product_id: $product_id orderPay: $orderPay createdAt: $createdAt order_id: $order_id count: $count productPay: $productPay user_id: $user_id) {
+            remark
+            updatedAt
+            unit
+            product_id {
+                category
+                updatedAt
+                unit
+                name
+                createdAt
+                status
+                id
+                intro
+                price
+                img
+                stock
+            }
+            orderPay
+            createdAt
+            order_id {
+                deliveryTime
+                updatedAt
+    
+                payTime
+                orderTotalPay
+                createdAt
+                orderStatus
+    
+                id
+                orderShipFee
+                count
+    
+                productTotalPay
+            }
+            id
+            count
+            productPay
+            user_id {
+                email
+                updatedAt
+                password
+                telephone
+                username
+                createdAt
+                openid
+                id
+            }
+        }
+    }
+`
+
+
 export {
     productbyprops,
     productbyid,
     cart_by_userid,
     delete_userCart_by_id,
     userAddressbyprops,
-    orderbyprops
+    orderbyprops,
+    orderProduct_by_props
 }