Csy817 6 роки тому
батько
коміт
368140c04e

+ 2 - 1
ecommerce.csv

@@ -129,6 +129,7 @@ id,ID,key
 user_id,ID,non-null
 order_id,ID,non-null
 expressName,string,non-null
+expressDetailName,string,
 expressId,string,non-null
 serviceStore,string,
 consigneeName,string,non-null
@@ -169,4 +170,4 @@ name,string,
 img,string,non-null
 status,int,non-null
 createdAt,string,non-null
-updatedAt,string,
+updatedAt,string,

+ 21 - 14
src/pages/my/all/index.js

@@ -137,20 +137,7 @@ class All extends Component {
                     <div className='card-title'>
                       电商订单
                     </div>
-                    <div className='card-icons'>
-                      <Grid data={orderIcon}
-                            columnNum={4}
-                            hasLine={false}
-                            onClick={(order) => {
-                              this.props.history.push({
-                                pathname: '/my/order',
-                                state: {
-                                  kind: order.id
-                                }
-                              })
-                            }}
-                      />
-                    </div>
+                    <OrderTab history={this.props.history}/>
                   </div>
 
                   <div className='my-card tools-card'>
@@ -266,3 +253,23 @@ class All extends Component {
 }
 
 export default withRouter(All)
+
+
+export const OrderTab = (props) => {
+  return (
+    <div className='card-icons'>
+      <Grid data={orderIcon}
+            columnNum={4}
+            hasLine={false}
+            onClick={(order) => {
+              props.history.push({
+                pathname: '/my/order',
+                state: {
+                  kind: order.id
+                }
+              })
+            }}
+      />
+    </div>
+  )
+}

+ 5 - 1
src/pages/my/manage/orders/index.css

@@ -9,7 +9,7 @@
 
 .order-tip-wrap {
     position: relative;
-    height: inherit;
+    height: 500px;
     width: 100%;
     background-color: transparent;
 }
@@ -24,3 +24,7 @@
 .search-query {
     min-height: 200px;
 }
+
+.am-accordion-content {
+    background: #f5f5f9!important;
+}

+ 2 - 54
src/pages/my/manage/orders/index.js

@@ -58,14 +58,10 @@ class Orders extends Component {
                                          className={classNames({'hidden': accordionKey !== undefined && accordionKey !== '2'})}>
                             <Unbox/>
                         </Accordion.Panel>
-                        <Accordion.Panel header="待评价"
+                        <Accordion.Panel header="已完成"
                                          className={classNames({'hidden': accordionKey !== undefined && accordionKey !== '3'})}>
                             <Completed/>
                         </Accordion.Panel>
-                        <Accordion.Panel header="已完成"
-                                         className={classNames({'hidden': accordionKey !== undefined && accordionKey !== '4'})}>
-                            <Commented/>
-                        </Accordion.Panel>
                     </Accordion>
                 </div>
             </div>
@@ -350,52 +346,4 @@ class Completed extends Component {
     }
 }
 
-class Commented extends Component {
-    constructor(props) {
-        super(props)
-        this.state = {}
-    }
-
-    render() {
-        return (
-            <Query query={gql(orderbyprops)} variables={{orderStatus: '4'}}>
-                {
-                    ({loading, error, data}) => {
-                        if (loading) {
-                            return (
-                                <div className="loading-center">
-                                    <ActivityIndicator text="加载中..." size="large"/>
-                                </div>
-                            )
-                        }
-                        if (error) {
-                            return 'error!'
-                        }
-                        data = data.orderbyprops
-                        // console.log(data)
-                        return (
-                            <div>
-                                {
-                                    data.length === 0 ?
-                                        <div className='order-tip-wrap'>
-                                            <div className='order-tip'>还没有这种订单</div>
-                                        </div>
-                                        :
-                                        <DisplayRender
-                                            data={data}
-                                            orderStatus='4'
-                                            button={false}
-                                            history={this.props.history}
-                                        />
-                                }
-                            </div>
-                        )
-                    }
-                }
-            </Query>
-        )
-    }
-}
-
-
-export default withRouter(Orders)
+export default withRouter(Orders)

+ 158 - 157
src/pages/my/order/detail/index.js

@@ -10,180 +10,181 @@ import {ButtonGroupRender} from '../display'
 import './index.css'
 
 class Detail extends Component {
-    constructor(props) {
-        super(props)
-        this.state = {
-            data: {}
-        }
+  constructor(props) {
+    super(props)
+    this.state = {
+      data: {}
     }
+  }
 
-    componentWillMount() {
-        let {location} = this.props
-        if (location && location.state) {
-            this.setState({
-                data: location.state.data
-            })
-        }
+  componentWillMount() {
+    let {location} = this.props
+    if (location && location.state) {
+      this.setState({
+        data: location.state.data
+      })
     }
+  }
 
-    statusRender = (status) => {
-        switch (status) {
-            case '0':
-                return (
-                    <div className='detail-status'>
-                        <Icon type="clock-circle"/>&nbsp;
-                        <span>等待付款</span>
-                    </div>
-                )
-            case '1':
-                return (
-                    <div className='detail-status'>
-                        <Icon type="shop"/>&nbsp;
-                        <span>等待发货</span>
-                    </div>
-                )
-            case '2':
-                return (
-                    <div className='detail-status'>
-                        <Icon type="gift"/>&nbsp;
-                        <span>等待收货</span>
-                    </div>
-                )
-            case '3':
-                return (
-                    <div className='detail-status'>
-                        <Icon type="like"/>&nbsp;
-                        <span>完成</span>
-                    </div>
-                )
-            default:
-                return (
-                    <div className='detail-status'>
-                        <Icon type="clock-circle"/>&nbsp;
-                        <span>等待确认</span>
-                    </div>
-                )
-        }
-    }
-
-    productsRender = (data) => {
+  statusRender = (status) => {
+    switch (status) {
+      case '0':
         return (
-            data.map(data => (
-                <div key={'orders-detail-'+data.id}>
-                    <div className="cart-list">
-                        <div className="cart-list-image">
-                            <img src={data.product_id.img} alt=""/>
-                        </div>
-                        <div className="cart-orders-intro">
-                            <div className='hide-extra-text'>{data.product_id.name}</div>
-                            <div>{data.productColor}  {data.productSize}</div>
-                            <div>¥ {data.product_id.price}</div>
-                        </div>
-                        <div className="cart-orders-count">
-                            x {data.count}
-                        </div>
-                    </div>
-                </div>
-            ))
+          <div className='detail-status'>
+            <Icon type="clock-circle"/>&nbsp;
+            <span>等待付款</span>
+          </div>
+        )
+      case '1':
+        return (
+          <div className='detail-status'>
+            <Icon type="shop"/>&nbsp;
+            <span>等待发货</span>
+          </div>
+        )
+      case '2':
+        return (
+          <div className='detail-status'>
+            <Icon type="gift"/>&nbsp;
+            <span>等待收货</span>
+          </div>
+        )
+      case '3':
+        return (
+          <div className='detail-status'>
+            <Icon type="like"/>&nbsp;
+            <span>完成</span>
+          </div>
+        )
+      default:
+        return (
+          <div className='detail-status'>
+            <Icon type="clock-circle"/>&nbsp;
+            <span>等待确认</span>
+          </div>
         )
     }
+  }
 
-    render() {
-        let {data} = this.state
-      console.log("detail data",data)
-      let {consigneeName, consigneeTel, consignAddress} = data.orderLogistics_id
+  productsRender = (data) => {
+    return (
+      data.map(data => (
+        <div key={'orders-detail-'+data.id}>
+          <div className="cart-list">
+            <div className="cart-list-image">
+              <img src={data.product_id.img} alt=""/>
+            </div>
+            <div className="cart-orders-intro">
+              <div className='hide-extra-text'>{data.product_id.name}</div>
+              <div>{data.productColor}  {data.productSize}</div>
+              <div>¥ {data.product_id.price}</div>
+            </div>
+            <div className="cart-orders-count">
+              x {data.count}
+            </div>
+          </div>
+        </div>
+      ))
+    )
+  }
 
-      return (
-            <div>
-                <div className='detail-wrap'>
-                    <div className='navbar'>
-                        <NavBar
-                            mode="light"
-                            icon={<Icon type="left"/>}
-                            onLeftClick={() => {
-                                this.props.history.go(-1)
-                            }}
-                        >订单详情</NavBar>
-                    </div>
-                    {/*内容*/}
-                    <div className='content-wrap'>
-                        <div className='detail-address-wrap'>
-                            <div className='detail-address-backgroud-top'>
-                                {this.statusRender(data.orderStatus)}
-                                <div className='detail-pay'>
-                                    ¥{data.productTotalPay}
-                                </div>
-                            </div>
-                            <div className='detail-address-backgroud-bottom'/>
-                            <div className='detail-address-content'>
-                                <Row>
-                                    <Col span={4} className='detail-address-content-icon'>
-                                        <Icon type="pushpin"/>
-                                    </Col>
-                                    <Col span={20}>
-                                        <div className='detail-address-content-username-phone'>
-                                            {consigneeName}&nbsp;&nbsp;{consigneeTel}
-                                        </div>
-                                        <div>
-                                            收货地址:{consignAddress}
-                                        </div>
-                                    </Col>
-                                </Row>
-                            </div>
-                        </div>
-                        <div className='detail-goods-wrap'>
-                            <div className='detail-store-name'>订单号: {data.id}</div>
-                            <Query query={gql(orderProduct_by_props)} variables={{order_id: data.id}}>
-                                {
-                                    ({loading, error, data}) => {
-                                        if (error) {
-                                            return 'error!'
-                                        }
-                                        data = data.orderProductbyprops
-                                        return (
-                                            <div>{this.productsRender(data)}</div>
-                                        )
-                                    }
-                                }
-                            </Query>
-                            <div className='detail-contact'>联系客服</div>
-                        </div>
-                        <div className='detail-order-wrap'>
-                            <Order data={data}/>
-                        </div>
+  render() {
+    let {data} = this.state
+    // console.log("detail data",data)
+    let {consigneeName, consigneeTel, consignAddress} = data.orderLogistics_id
+
+    return (
+      <div>
+        <div className='detail-wrap'>
+          <div className='navbar'>
+            <NavBar
+              mode="light"
+              icon={<Icon type="left"/>}
+              onLeftClick={() => {
+                this.props.history.go(-1)
+                sessionStorage.setItem('select_orderStatus',data.orderStatus)
+              }}
+            >订单详情</NavBar>
+          </div>
+          {/*内容*/}
+          <div className='content-wrap'>
+            <div className='detail-address-wrap'>
+              <div className='detail-address-backgroud-top'>
+                {this.statusRender(data.orderStatus)}
+                <div className='detail-pay'>
+                  ¥{data.productTotalPay}
+                </div>
+              </div>
+              <div className='detail-address-backgroud-bottom'/>
+              <div className='detail-address-content'>
+                <Row>
+                  <Col span={4} className='detail-address-content-icon'>
+                    <Icon type="pushpin"/>
+                  </Col>
+                  <Col span={20}>
+                    <div className='detail-address-content-username-phone'>
+                      {consigneeName}&nbsp;&nbsp;{consigneeTel}
                     </div>
-                    <div className='detail-footer-wrap'>
-                        <ButtonGroupRender orderStatus={data.orderStatus}/>
+                    <div>
+                      收货地址:{consignAddress}
                     </div>
-                </div>
+                  </Col>
+                </Row>
+              </div>
             </div>
-        )
-    }
+            <div className='detail-goods-wrap'>
+              <div className='detail-store-name'>订单号: {data.id}</div>
+              <Query query={gql(orderProduct_by_props)} variables={{order_id: data.id}}>
+                {
+                  ({loading, error, data}) => {
+                    if (error) {
+                      return 'error!'
+                    }
+                    data = data.orderProductbyprops
+                    return (
+                      <div>{this.productsRender(data)}</div>
+                    )
+                  }
+                }
+              </Query>
+              {/*<div className='detail-contact'>联系客服</div>*/}
+            </div>
+            <div className='detail-order-wrap'>
+              <Order data={data}/>
+            </div>
+          </div>
+          <div className='detail-footer-wrap'>
+            <ButtonGroupRender order={data} orderStatus={data.orderStatus}/>
+          </div>
+        </div>
+      </div>
+    )
+  }
 }
 
 export default Detail
 
 class Order extends Component {
-    constructor(props) {
-        super(props)
-        this.state = {
+  constructor(props) {
+    super(props)
+    this.state = {
 
-        }
     }
+  }
 
-    render() {
-        let {data} = this.props
-        return (
-            <div className='detail-order-wrapper'>
-                <div className='detail-order-item'>
-                    <span className='detail-order-title'>订单编号:</span>
-                    <span>{data.id}</span>
-                </div>
-                <div className='detail-order-item'>
-                    <span className='detail-order-title'>下单时间:</span>
-                    <span>{data.createdAt}</span>
-                </div>
-            </div>
-        )
-    }
-}
+  render() {
+    let {data} = this.props
+    return (
+      <div className='detail-order-wrapper'>
+        <div className='detail-order-item'>
+          <span className='detail-order-title'>订单编号:</span>
+          <span>{data.id}</span>
+        </div>
+        <div className='detail-order-item'>
+          <span className='detail-order-title'>下单时间:</span>
+          <span>{data.createdAt}</span>
+        </div>
+      </div>
+    )
+  }
+}

+ 22 - 0
src/pages/my/order/display/index.css

@@ -23,6 +23,11 @@
     height: 100%;
 }
 
+.order-body {
+    height: inherit;
+    margin-top: 50px;
+}
+
 .order-card-bottom {
     display: flex;
     justify-content: flex-end;
@@ -91,3 +96,20 @@
 .more-button {
 
 }
+
+.express-info {
+    font-weight: bold;
+    padding-left: 5px;
+    color: #0a0a0a;
+}
+
+.am-tabs-tab-bar-wrap {
+    position: fixed;
+    width: 100%;
+    z-index: 3;
+    margin-top: 46px;
+}
+
+.am-tabs-pane-wrap-active {
+    height: 100%!important;
+}

+ 358 - 243
src/pages/my/order/display/index.js

@@ -1,285 +1,400 @@
 import React, {Component} from 'react'
 import {withRouter} from 'react-router-dom'
 import {Row, Col, message} from 'antd'
-import {NavBar, Icon, ActivityIndicator, Button} from 'antd-mobile'
+import moment from 'moment'
+import {NavBar, Icon, ActivityIndicator, Button, Modal, Tabs} from 'antd-mobile'
 import {Query} from "react-apollo"
 import {Mutation} from "react-apollo"
 import gql from "graphql-tag"
 import classNames from 'classnames'
 
-import {delete_order, orderbyprops, orderProduct_by_props} from "../../../../utils/gql"
+import {delete_order, orderbyprops, orderProduct_by_props, update_order} from "../../../../utils/gql"
 import {getCookie} from "../../../../utils/cookie"
 import './index.css'
 
+const alert = Modal.alert
+const tabs = [
+  {
+    key: '0',
+    orderStatus: '0',
+    title: '待付款',
+    id: 'pay'
+  },
+  {
+    key: '1',
+    orderStatus: '1',
+    title: '待发货',
+    id: 'ship'
+  },
+  {
+    key: '2',
+    orderStatus: '2',
+    title: '待收货',
+    id: 'unbox'
+  },
+  {
+    key: '3',
+    orderStatus: '3',
+    title: '已完成',
+    id: 'judge'
+  }
+];
+
 class Display extends Component {
-    constructor(props) {
-        super(props)
-        this.state = {
-            navTitle: '待付款',
-            kind: 'pay',
-            orderStatus: '0'
-        }
+  constructor(props) {
+    super(props)
+    this.state = {
+      orderStatus: sessionStorage.getItem('select_orderStatus') || '0'
     }
+  }
 
-    componentWillMount() {
-        let {location} = this.props
-        if (location && location.state) {
-            let navTitle = '',
-                orderStatus = '0'
-            let kind = location.state.kind
-            switch (kind) {
-                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 = '无效页面'
-                    break
-            }
-            this.setState({
-                navTitle,
-                kind,
-                orderStatus
-            })
-        }
+  componentWillMount() {
+    const {location} = this.props
+    this.getOrderStatus(location)
+  }
+
+  getOrderStatus = (location) => {
+    let orderStatus = sessionStorage.getItem('select_orderStatus')
+    if(orderStatus){
+      this.setState({
+        orderStatus
+      })
+    }else if (location && location.state) {
+      let orderStatus = '0'
+      const kind = location.state.kind
+      switch (kind) {
+        case 'pay':
+          orderStatus = '0'
+          break
+        case 'ship':
+          orderStatus = '1'
+          break
+        case 'unbox':
+          orderStatus = '2'
+          break
+        case 'judge':
+          orderStatus = '3'
+          break
+        default:
+          break
+      }
+      this.setState({
+        orderStatus
+      })
     }
+  }
 
-    render() {
-        let {navTitle, orderStatus} = this.state
-        let user_id = getCookie('user_id')
+  changeOrderStatus = (value) => {
+    this.setState({
+      orderStatus: value.orderStatus
+    })
+  }
 
-        return (
-            <div className='order-wrap'>
-                <div className='navbar'>
-                    <NavBar
-                        mode="light"
-                        icon={<Icon type="left"/>}
-                        onLeftClick={() => {
-                            this.props.history.go(-1)
-                        }}
-                    >{navTitle}</NavBar>
-                </div>
-                <Query query={gql(orderbyprops)} variables={{user_id, orderStatus}}>
-                    {
-                        ({loading, error, data}) => {
-                            if (loading) {
-                                return (
-                                    <div className="loading-center">
-                                        <ActivityIndicator text="加载中..." size="large"/>
-                                    </div>
-                                )
-                            }
-                            if (error) {
-                                return 'error!'
-                            }
-                            return (
-                                <DisplayRender data={data.orderbyprops} orderStatus={orderStatus}
-                                               history={this.props.history}/>
-                            )
-                        }
-                    }
-                </Query>
-            </div>
-        )
-    }
+  render() {
+    const { history } = this.props
+    let {orderStatus} = this.state
+    let user_id = getCookie('user_id')
+
+    return (
+      <div className='order-wrap'>
+        <div className='navbar'>
+          <NavBar
+            mode="light"
+            icon={<Icon type="left"/>}
+            onLeftClick={() => {
+              history.go(-1)
+            }}
+          >我的订单</NavBar>
+        </div>
+        <Tabs
+          tabs={tabs}
+          initialPage={orderStatus}
+          onChange={(tabValue, index) => {
+            // console.log('onChange', index, tabValue);
+            this.changeOrderStatus(tabValue)
+          }}
+        >
+          <Query query={gql(orderbyprops)} variables={{user_id, orderStatus}}>
+            {
+              ({loading, error, data}) => {
+                if (loading) {
+                  return (
+                    <div className="loading-center">
+                      <ActivityIndicator text="加载中..." size="large"/>
+                    </div>
+                  )
+                }
+                if (error) {
+                  return 'error!'
+                }
+                data = data.orderbyprops
+                // console.log("orderbyprops data",data)
+                return (
+                  <DisplayRender
+                    data={data}
+                    orderStatus={orderStatus}
+                    history={history}
+                  />
+                )
+              }
+            }
+          </Query>
+        </Tabs>
+      </div>
+    )
+  }
 }
 
 class DisplayRender extends Component {
-    constructor(props) {
-        super(props)
-        this.state = {}
+  constructor(props) {
+    super(props)
+    this.state = {
     }
+  }
 
-    orderCardContentRender = (data) => {
-        if (data.length === 1) {
-            return (
-                <Row style={{width: '100%'}}>
-                    <Col span={6} style={{height: '100%'}}>
-                        <div className='order-product-img'
-                             style={{backgroundImage: `url('${data[0].product_id.img}')`}}/>
-                    </Col>
-                    <Col span={16} offset={2}>
-                        <div className='order-product-name'>{data[0].product_id.name}</div>
-                    </Col>
-                </Row>
-            )
-        } else {
-            return (data.map(data => (
-                <div className='order-product-img' style={{backgroundImage: `url('${data.product_id.img}')`}}
-                     key={data.id}/>
-            )))
-        }
+  orderCardContentRender = (data) => {
+    if (data.length === 1) {
+      return (
+        <Row style={{width: '100%'}}>
+          <Col span={6} style={{height: '100%'}}>
+            <div className='order-product-img'
+                 style={{backgroundImage: `url('${data[0].product_id.img}')`}}/>
+          </Col>
+          <Col span={16} offset={2}>
+            <div className='order-product-name'>{data[0].product_id.name}</div>
+          </Col>
+        </Row>
+      )
+    } else {
+      return (data.map(data => (
+        <div className='order-product-img' style={{backgroundImage: `url('${data.product_id.img}')`}}
+             key={data.id}/>
+      )))
     }
+  }
 
-    render() {
-        let {data, orderStatus, button = true} = this.props
-        let content = orderStatus === '0' ? '需付款' : '实付款'
+  render() {
+    const { data, orderStatus, button = true, history } = this.props
+    // console.log("DisplayRender orderStatus",orderStatus)
+    let content = orderStatus === '0' ? '需付款' : '实付款'
 
-        return (
-            <div className={classNames({'content-wrap': button})} style={{height: window.innerHeight - 45}}>
-                {
-                    data.length === 0 ?
-                        <div className='order-tip-wrap'>
-                            <div className='order-tip'>暂无此类订单</div>
-                        </div>
-                        :
-                        data.map(order => (
-                            <div key={order.id} className='order-card'>
-                                <div className='order-card-top'>订单号: {order.id}</div>
+    return (
+      <div className={classNames({'content-wrap': button})}>
+        <div className='order-body'>
+          {
+            data.length === 0 ?
+              <div className='order-tip-wrap'>
+                <div className='order-tip'>暂无此类订单</div>
+              </div>
+              :
+              data.map(order => (
+                <div key={order.id} className='order-card'>
+                  <div className='order-card-top'>订单号: {order.id}</div>
 
-                                <Query query={gql(orderProduct_by_props)} variables={{order_id: order.id}}>
-                                    {
-                                        ({loading, error, data}) => {
-                                            if (loading) {
-                                                return (
-                                                    <div className="loading-center">
-                                                        <ActivityIndicator text="加载中..." size="large"/>
-                                                    </div>
-                                                )
-                                            }
-                                            if (error) {
-                                                return 'error!'
-                                            }
-                                            data = data.orderProductbyprops
-                                            return (
-                                                <div>
-                                                    {
-                                                        button ?
-                                                            <div className='order-card-content' onClick={() => {
-                                                                this.props.history.push({
-                                                                    pathname: '/my/order/detail',
-                                                                    state: {
-                                                                        data: order
-                                                                    }
-                                                                })
-                                                            }}>
-                                                                {
-                                                                    this.orderCardContentRender(data)
-                                                                }
-                                                            </div>
-                                                            :
-                                                            <div className='order-card-content'>
-                                                                {
-                                                                    this.orderCardContentRender(data)
-                                                                }
-                                                            </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="加载中..." size="large"/>
+                            </div>
+                          )
+                        }
+                        if (error) {
+                          return 'error!'
+                        }
+                        data = data.orderProductbyprops
+                        return (
+                          <div>
+                            {
+                              button ?
+                                <div className='order-card-content' onClick={() => {
+                                  history.push({
+                                    pathname: '/my/order/detail',
+                                    state: {
+                                      data: order
                                     }
-                                </Query>
-
-                                <div className='order-card-bottom'>
-                                    <div
-                                        className='order-card-count'>共{order.count}件商品&nbsp;&nbsp;{content}:
-                                    </div>
-                                    <div
-                                        className='order-card-pay'>¥{Math.round(order.productTotalPay * 100) / 100}</div>
+                                  })
+                                }}>
+                                  {this.orderCardContentRender(data)}
                                 </div>
+                                :
+                                <div className='order-card-content'>
+                                  {this.orderCardContentRender(data)}
+                                </div>
+                            }
+                          </div>
+                        )
+                      }
+                    }
+                  </Query>
 
-                                {
-                                    button ?
-                                        <ButtonGroupRender id={order.id} order={order} orderStatus={this.props.orderStatus}
-                                                           history={this.props.history}/>
-                                        :
-                                        ''
-                                }
+                  <div className='order-card-bottom'>
+                    <div className='order-card-count'>共{order.count}件商品&nbsp;&nbsp;{content}:</div>
+                    <div className='order-card-pay'>¥{Math.round(order.productTotalPay * 100) / 100}</div>
+                  </div>
+                  {
+                    button ?
+                      <ButtonGroupRender order={order} orderStatus={orderStatus} history={history}/> : ''
+                  }
+                </div>
+              ))
+          }
+        </div>
+      </div>
+    )
+  }
+}
 
-                            </div>
-                        ))
-                }
-            </div>
-        )
+class ButtonGroupRender extends Component {
+  constructor(props) {
+    super(props)
+    this.state = {
+      modal: false
     }
-}
+  }
 
-const ButtonGroupRender = (props) => {
-    let {orderStatus, id, order} = props
-    let user_id = getCookie('user_id')
-    switch (orderStatus) {
-        case '0':
-            return (
-                <div className='order-card-button-group'>
-                    <Mutation
-                        mutation={gql(delete_order)}
-                        refetchQueries={[{query: gql(orderbyprops), variables: {user_id, orderStatus}}]}
-                    >
-                        {(delete_order, {loading, error}) => {
-                            if (loading) {
-                                return (
-                                    <div className="loading-center">
-                                        <ActivityIndicator text="加载中..." size="large"/>
-                                    </div>
-                                )
-                            }
-                            if (error) {
-                                return 'error!'
-                            }
-                            return (
-                                <Button size="small" className='pay-button order-button' onClick={() => {
-                                    delete_order({variables: {id}})
-                                }}>取消</Button>
-                            )
-                        }}
-                    </Mutation>
+  showModal = (key,e) => {
+    e.preventDefault(); // 修复 Android 上点击穿透
+    this.setState({
+      [key]: true,
+    });
+  }
 
+  onClose = key => () => {
+    this.setState({
+      [key]: false,
+    });
+  }
 
-                    <Button size="small" className='pay-button order-button' style={{marginLeft: 5}} onClick={() => {
-                        sessionStorage.setItem('payOrder',JSON.stringify(order))
-                        props.history.push({
-                            pathname: '/cart/pay',
-                            state: {}
-                        })
-                    }}>去支付</Button>
-                </div>
-            )
-        case '1':
-            return (
-                <div className='order-card-button-group'>
-                    <Button size="small" className='ship-button order-button' onClick={() => {
-                      message.success('已提醒')
-                    }}>提醒发货</Button>
-                </div>
-            )
-        case '2':
-            return (
-                <div className='order-card-button-group'>
-                    <Button size="small" className='unbox-button order-button' onClick={() => {
-                      message.info('暂无物流信息')
-                    }}>查看物流</Button>
-                </div>
-            )
-        // case '3':
-        //     return (
-        //         <div className='order-card-button-group'>
-        //             <Button size="small" className='judge-button order-button'>去评价</Button>
-        //         </div>
-        //     )
-        default:
-            return (
-                <div>
+  renderByOrderStatus = () => {
+    const { order, history } = this.props
+    let { modal } = this.state
+    // console.log("renderByOrderStatus order",order)
+    const { id, orderStatus, orderLogistics_id } = order
+    const { expressId, expressDetailName='' } = orderLogistics_id
+    const user_id = getCookie('user_id')
+    switch (orderStatus) {
+      case '0':
+        return (
+          <div className='order-card-button-group'>
+            <Mutation
+              mutation={gql(delete_order)}
+              refetchQueries={[{query: gql(orderbyprops), variables: {user_id, orderStatus}}]}
+            >
+              {(delete_order, {loading, error}) => {
+                if (loading) {
+                  return (
+                    <div className="loading-center">
+                      <ActivityIndicator text="加载中..." size="large"/>
+                    </div>
+                  )
+                }
+                if (error) {
+                  return 'error!'
+                }
+                return (
+                  <Button size="small" className='pay-button order-button' onClick={() => {
+                    delete_order({variables: {id}})
+                  }}>取消</Button>
+                )
+              }}
+            </Mutation>
 
-                </div>
-            )
+            <Button size="small" className='pay-button order-button' style={{marginLeft: 5}} onClick={() => {
+              sessionStorage.setItem('payOrder',JSON.stringify(order))
+              history.push({
+                pathname: '/cart/pay',
+                state: {}
+              })
+            }}>去支付</Button>
+          </div>
+        )
+      case '1':
+        return (
+          <div className='order-card-button-group'>
+            <Button size="small" className='ship-button order-button' onClick={() => {
+              message.success('已提醒')
+            }}>提醒发货</Button>
+          </div>
+        )
+      case '2':
+        return (
+          <div className='order-card-button-group'>
+            <Button size="small" className='unbox-button order-button' onClick={(e) => {
+              if(expressId){
+                this.showModal('modal',e)
+              }else {
+                message.info('暂无物流信息')
+              }
+            }}>查看物流</Button>
+            <Modal
+              visible={modal}
+              transparent
+              onClose={this.onClose('modal')}
+              title="物流信息"
+            >
+              <div>
+                {expressDetailName ?
+                  <div>快递名称:<span className='express-info'>{expressDetailName}</span></div>:''
+                }
+                <div>快递单号:<span className='express-info'>{expressId}</span></div>
+              </div>
+            </Modal>
+            &nbsp;&nbsp;
+            <Mutation
+              mutation={gql(update_order)}
+              refetchQueries={[{query: gql(orderbyprops), variables: {user_id, orderStatus}}]}
+            >
+              {(update_order, {error}) => {
+                if (error) {
+                  return 'error!'
+                }
+                return (
+                  <Button size="small" className='unbox-button order-button' onClick={() => {
+                    console.log("确认收货")
+                    alert('确认收货', `确定确认收货吗?`, [
+                      { text: '取消', onPress: () => console.log('cancel') },
+                      {
+                        text: '确定',
+                        onPress: () => {
+                          const updatedAt = moment().format('YYYY-MM-DD HH:mm:ss')
+                          update_order({variables: {id, orderStatus:'3', updatedAt}})
+                        }
+                      }
+                    ])
+                  }}>确认收货</Button>
+                )
+              }}
+            </Mutation>
+          </div>
+        )
+      // case '3':
+      //     return (
+      //         <div className='order-card-button-group'>
+      //             <Button size="small" className='judge-button order-button'>去评价</Button>
+      //         </div>
+      //     )
+      default:
+        return (
+          <div> </div>
+        )
     }
+  }
+
+  render() {
+    return (
+      <div>
+        {this.renderByOrderStatus()}
+      </div>
+    )
+  }
 }
 
 
 export default withRouter(Display)
 export {
-    DisplayRender,
-    ButtonGroupRender
+  DisplayRender,
+  ButtonGroupRender
 }

+ 21 - 4
src/utils/gql.js

@@ -638,14 +638,11 @@ const update_order = `
             order {
                 remark
                 updatedAt
-    
                 orderTotalPay
                 createdAt
                 orderStatus
-    
                 id
                 count
-    
                 productTotalPay
             }
         }
@@ -953,6 +950,25 @@ const slideshow_by_shop = `
     }
 `
 
+const logisticsExpressId = `
+    query logisticsExpressId($id: ID) {
+        logisticsExpressId: orderLogistics_by_id(id: $id) {
+            deliveryTime
+            serviceStore
+            updatedAt
+            logisticsFee
+            expressId
+            createdAt
+            consigneeTel
+            id
+            expressName
+            consignAddress
+            LogisticsStatus
+            consigneeName
+        }
+    }
+`
+
 export {
     create_user,
     find_user_by_openid,
@@ -996,5 +1012,6 @@ export {
     admin_by_id,
     create_admin,
     update_admin,
-    delete_admin
+    delete_admin,
+    logisticsExpressId
 }