import React, {Component} from 'react' import './index.css' import {NavBar, Icon, ActivityIndicator, Button} from 'antd-mobile' import {Row, Col} from 'antd' import {withRouter} from 'react-router-dom' import {orderbyprops, orderProduct_by_props} from "../../../../utils/gql" import {Query} from "react-apollo" import gql from "graphql-tag" class Display extends Component { constructor(props) { super(props) this.state = { navTitle: '待付款', kind: 'pay', 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 }) } } render() { let {navTitle, orderStatus} = this.state return (
} onLeftClick={() => { this.props.history.go(-2) }} >{navTitle}
{ ({loading, error, data}) => { if (loading) { return (
) } if (error) { return 'error!' } return ( ) } }
) } } export default withRouter(Display) class DisplayRender extends Component { constructor(props) { super(props) this.state = {} } orderCardContentRender = (data) => { if (data.length === 1) { return (
{data[0].product_id.name}
) } else { return (data.map(data => (
))) } } orderCardBottomRender = (order) => { let {orderStatus} = this.props switch (orderStatus) { case '0': return (
共{order.count}件商品  需付款:
¥{order.productTotalPay}
) case '1': return (
共{order.count}件商品  实付款:
¥{order.productTotalPay}
) case '2': return (
共{order.count}件商品  实付款:
¥{order.productTotalPay}
) case '3': return (
共{order.count}件商品  实付款:
¥{order.productTotalPay}
) default: return (
1
) } } orderCardButtonGroupRender = () => { let {orderStatus} = this.props switch (orderStatus) { case '0': return (
) case '1': return (
  
) case '2': return (
  
) case '3': return (
  
) default: return (
ok
) } } render() { let {data} = this.props return (
{ data.length === 0 ?
还没有这种订单呢
: data.map(order => (
JD
{ ({loading, error, data}) => { if (loading) { return (
) } if (error) { return 'error!' } data = data.orderProductbyprops return (
{ this.props.history.push({ pathname: '/my/order/detail', state: { data: order, tabHidden:true } }) }}> { this.orderCardContentRender(data) }
) } }
{this.orderCardBottomRender(order)} {this.orderCardButtonGroupRender()}
)) }
) } }